-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updated project to work with Docker * docker working with turbo-track and auto asset reloading * reverted theme-show-notifications to true * merged in main, updates to Dockerfile which install node_modules directly into the container * added x86_64-linux platform * restored db defaults for local development * updated docker defaults to ensure that local setup still works * removed comments in Gem file * moved the debugging gems to the development only env * migrated to an arm64 safe version of debase for debugging * ran bundle lock --add-platform x86_64-linux * set debase require to false * added steps to remove debugging info from Gem file * updated file path for Gemfile * reverted brakeman-analysis.yml, added new workflow to remove debugging gems * converted cleanup-gemfile to be reusable action * added gem cleanup * updated cleanup action to include run * running bundle install after removing debase * moved gemcleanup to setup-languages step * temporarily disabling the bundler cache * minor formatting fixes * No username --------- Co-authored-by: Matt Gardner <[email protected]>
- Loading branch information
1 parent
37548ca
commit 3f70472
Showing
18 changed files
with
281 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ -f /rails/tmp/pids/server.pid ]; then | ||
rm /rails/tmp/pids/server.pid | ||
fi | ||
|
||
/rails/bin/rails db:migrate | ||
/rails/bin/dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE DATABASE "app_rails"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# action.yml file for a custom composite action | ||
name: 'Remove Debug Gems' | ||
description: 'Removes debug-related gems from the Gemfile' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Remove Debug Gems | ||
shell: bash | ||
run: | | ||
sed -i '/debase-ruby_core_source/d' ./Gemfile | ||
sed -i '/debase/d' ./Gemfile | ||
sed -i '/ruby-debug-ide/d' ./Gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile | ||
ARG RUBY_VERSION=3.1.0 | ||
|
||
FROM node:20.12.0-bullseye-slim AS node-stage | ||
WORKDIR /rails | ||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | ||
|
||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential git | ||
|
||
RUN apt-get install --reinstall ca-certificates -y && \ | ||
update-ca-certificates | ||
|
||
# print the node version | ||
RUN node --version | ||
COPY package.json ./ | ||
RUN yarn install | ||
|
||
########################################################################################## | ||
# BASE: Shared base docker image | ||
########################################################################################## | ||
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base | ||
|
||
# Set production environment | ||
ENV RAILS_ENV="production" \ | ||
BUNDLE_DEPLOYMENT="1" \ | ||
BUNDLE_PATH="/usr/local/bundle" | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 3000 | ||
|
||
########################################################################################## | ||
# BUILD: Throw-away build stage | ||
########################################################################################## | ||
FROM base as build | ||
ARG DOCKERIZE_VERSION=v0.7.0 | ||
#copy the node binary from the node-stage to the base image | ||
COPY --from=node-stage /usr/local/bin/node /usr/local/bin/node | ||
|
||
# Install dockerize | ||
RUN apt-get update \ | ||
&& apt-get install -y wget \ | ||
&& wget -O - https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz | tar xzf - -C /usr/local/bin \ | ||
&& apt-get autoremove -yqq --purge wget && rm -rf /var/lib/apt/lists/* | ||
|
||
# Install packages needed to build gems | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config redis jq rbenv cu npm | ||
|
||
|
||
# Clean up | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
########################################################################################## | ||
# DEV: Used for development and test | ||
########################################################################################## | ||
FROM build as dev | ||
|
||
WORKDIR /rails | ||
|
||
ENV RAILS_ENV="development" | ||
|
||
# Install packages needed for development | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y postgresql-client graphviz && \ | ||
rm -rf /var/lib/apt/lists /var/cache/apt/archives | ||
|
||
RUN gem install bundler | ||
|
||
# Install application gems for development | ||
COPY Gemfile Gemfile.lock ./ | ||
|
||
RUN gem update --system | ||
RUN bundle lock --add-platform ruby && \ | ||
bundle lock --add-platform x86_64-linux | ||
|
||
RUN bundle config set --local without production && \ | ||
bundle install && \ | ||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git | ||
|
||
# copy node from node-stage to dev | ||
COPY --from=node-stage /usr/local/bin/node /usr/local/bin/node | ||
# Copy application code | ||
COPY . . | ||
# Copy node_modules from node-stage | ||
COPY --from=node-stage /rails/node_modules ./ | ||
ENTRYPOINT [".docker/.entrypoints/docker-rails.sh"] | ||
|
||
########################################################################################## | ||
# RELEASE-BUILD: Throw-away build stage for RELEASE | ||
########################################################################################## | ||
FROM build as release-build | ||
|
||
# Install application gems for production | ||
COPY Gemfile Gemfile.lock ./ | ||
|
||
RUN bundle config set --local without development test && \ | ||
bundle install && \ | ||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git | ||
|
||
# Precompile bootsnap code for faster boot times | ||
RUN bundle exec bootsnap precompile --gemfile app/ lib/ | ||
|
||
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY | ||
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile | ||
|
||
|
||
########################################################################################## | ||
# RELEASE: Used for production | ||
########################################################################################## | ||
FROM base as release | ||
|
||
# Install packages needed for deployment | ||
RUN apt-get update -qq && \ | ||
apt-get install -y --no-install-recommends unzip python3-venv python-is-python3 curl libvips postgresql-client && \ | ||
rm -rf /var/lib/apt/lists /var/cache/apt/archives && \ | ||
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" && \ | ||
unzip awscli-bundle.zip && \ | ||
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \ | ||
rm -rf ./awscli-bundle awscli-bundle.zip | ||
|
||
# Install custom db migrate script | ||
COPY bin/db-migrate /usr/bin/ | ||
|
||
# Copy built artifacts: gems, application | ||
COPY --from=release-build /usr/local/bundle /usr/local/bundle | ||
COPY --from=release-build /rails /rails | ||
|
||
RUN rm /rails/tmp/pids/server.pid | ||
|
||
# Run and own only the runtime files as a non-root user for security | ||
RUN useradd rails --create-home --shell /bin/bash && \ | ||
chown -R rails:rails db log storage tmp | ||
USER rails:rails | ||
|
||
ENTRYPOINT [".docker/.entrypoints/docker-rails.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
web: env RUBY_DEBUG_OPEN=true bin/rails server | ||
web: env RUBY_DEBUG_PORT=1234 RUBY_DEBUG_STOP_AT_LOAD=true RUBY_DEBUG_OPEN=true RUBY_DEBUG_HOST=0.0.0.0 bin/rails server -p 3000 -b 0.0.0.0 | ||
js: yarn build --watch | ||
css: yarn build:css --verbose --watch | ||
worker: bundle exec sidekiq | ||
css: yarn build:css --watch | ||
worker: RUBY_DEBUG_OPEN=true bundle exec sidekiq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
//= link_tree ../images | ||
//= link_tree ../builds | ||
//= link application.postcss.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Btn0OVg1L730VpNEbQ+H15cFKg1y3q/z6IwIaDc9c4iExboCtzTUsYU/NO4sXKVZ0m0ShItWOKR4IxwCqw7GrIRKckilMnNhJKKMZJ9clj6CieYC9efIb8WeUe3c11AA--KLu1KB+ynGorNBrB--+jEPdTuPzExEtrlSeJzR9g== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.