-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update Dockerfile for Rails 7.1 - Update Nodejs install script - Add Rails credentials and secret_key_base - Update Gemfile
- Loading branch information
Showing
16 changed files
with
113 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 |
---|---|---|
|
@@ -4,3 +4,5 @@ tmp | |
vendor/ruby | ||
.env.rb | ||
.env | ||
|
||
/config/master.key |
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,20 +1,73 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM ruby:3.2.3 | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile | ||
ARG RUBY_VERSION=3.2.3 | ||
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
# Rails app lives here | ||
WORKDIR /rails | ||
|
||
# Set production environment | ||
ENV RAILS_ENV="production" \ | ||
BUNDLE_DEPLOYMENT="1" \ | ||
BUNDLE_PATH="/usr/local/bundle" \ | ||
BUNDLE_WITHOUT="development" | ||
|
||
ENV NODE_VERSION=20.x | ||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# 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 | ||
|
||
# Install application gems | ||
COPY Gemfile Gemfile.lock ./ | ||
RUN bundle install && \ | ||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ | ||
bundle exec bootsnap precompile --gemfile | ||
|
||
# Copy application code | ||
COPY . . | ||
|
||
# Install nodejs for precompilation | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential curl gpg | ||
|
||
COPY script/install_node.sh /tmp | ||
RUN /tmp/install_node.sh | ||
|
||
RUN mkdir /srv/phasers | ||
WORKDIR /srv/phasers | ||
ENV EXECJS_RUNTIME=Node | ||
|
||
# Precompile bootsnap code for faster boot times | ||
RUN bundle exec bootsnap precompile app/ lib/ | ||
|
||
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY | ||
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile | ||
|
||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
# Install packages needed for deployment | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y curl libvips postgresql-client && \ | ||
rm -rf /var/lib/apt/lists /var/cache/apt/archives | ||
|
||
# Copy built artifacts: gems, application, nodejs | ||
COPY --from=build /usr/local/bundle /usr/local/bundle | ||
COPY --from=build /rails /rails | ||
COPY --from=build /usr/bin/node /usr/bin/node | ||
COPY --from=build /usr/include/node /usr/include/node | ||
|
||
COPY Gemfile /srv/phasers/Gemfile | ||
COPY Gemfile.lock /srv/phasers/Gemfile.lock | ||
COPY vendor/ /srv/phasers/vendor | ||
RUN gem install bundler | ||
RUN bundle install --local | ||
COPY ./ /srv/phasers | ||
# 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 tmp | ||
USER rails:rails | ||
|
||
EXPOSE 3000/tcp | ||
ENTRYPOINT ["/usr/local/bundle/bin/bundle", "exec", "rails", "server", "-b", "0.0.0.0"] | ||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 3000 | ||
CMD ["./bin/rails", "server"] |
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 @@ | ||
ByZ6u2+hw01DPQr15rPfSniOwDGW3HttkjvcdTMoLOJ9itOhRUTK51vUuqkOY58v1V47nU/0LxPlUgPwYrkXSZaCUpD3myj7GbGMWRB09Ce6j2trwpoUJzEoSeUnSNuSDs7ktHQEheSFURPj+qIy0kHOK7nTTLeCMDjTZap+NoWFXzbLecpG3xIbNJ4UXx3QucTfGW4TsivP26nvG+qFaNTk9nSlZJ+wB37OfVqnHrGVycRVTVkNf6hsaS8QUiSG5CqkmOtCUzGYPrfMqLYojMLpZfCfnVCkqzPqh1bq5GGjtI242AgymYDqEcuQktcd5YAydJ3qyCYUFu1HOcK9V90HI/elj/kNmtViaJLD0nOnfngUy72ozoWrjCnl7o0jxg+TllBo3xKslU1y+WR063sX3GRF--smhrP6N+XzCPnSMl--Dg8np93VVJrWnVoOav8GJQ== |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.