11# syntax = docker/dockerfile:1
22
33# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
4- ARG RUBY_VERSION=3.1.2
5- FROM ruby:$RUBY_VERSION-slim as base
4+ ARG RUBY_VERSION=3.1
5+ FROM ruby:$RUBY_VERSION-slim AS base
66
77LABEL fly_launch_runtime="rails"
88
@@ -30,17 +30,18 @@ RUN apt-get update -qq && \
3030# rm -rf /tmp/node-build-master
3131
3232# Throw-away build stage to reduce size of final image
33- FROM base as build
33+ FROM base AS build
3434
3535# Install packages needed to build gems and node modules
3636RUN apt-get update -qq && \
37- apt-get install --no-install-recommends -y build-essential default-libmysqlclient-dev git libpq-dev libvips node-gyp pkg-config python-is-python3
37+ apt-get install --no-install-recommends -y build-essential default-libmysqlclient-dev git libpq-dev libvips libyaml-dev node-gyp pkg-config python-is-python3
3838
3939# Build options
4040ENV PATH="/usr/local/node/bin:$PATH"
4141
42- # Install application gems
43- COPY --link Gemfile ./
42+ # Copy application code
43+ COPY --link . .
44+
4445RUN sed -i "s/, path: '..\/ ..\/ '//" Gemfile
4546RUN bundle install && \
4647 rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
@@ -49,21 +50,16 @@ RUN bundle install && \
4950# COPY --link package.json ./
5051# RUN npm install
5152
52- # Copy application code
53- COPY --link . .
54- RUN sed -i "s/, path: '..\/ ..\/ '//" Gemfile
55-
5653# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
5754RUN sed -i "/link_tree ..\/ ..\/ ..\/ /d" app/assets/config/manifest.js
58- RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
59-
55+ RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile db:setup
6056
6157# Final stage for app image
6258FROM base
6359
6460# Install packages needed for deployment
6561RUN apt-get update -qq && \
66- apt-get install --no-install-recommends -y curl default-mysql-client imagemagick libsqlite3-0 libvips postgresql-client && \
62+ apt-get install --no-install-recommends -y curl imagemagick libsqlite3-0 libvips && \
6763 rm -rf /var/lib/apt/lists /var/cache/apt/archives
6864
6965# Copy built artifacts: gems, application
@@ -72,12 +68,14 @@ COPY --from=build /rails /rails
7268
7369# Run and own only the runtime files as a non-root user for security
7470RUN useradd rails --create-home --shell /bin/bash && \
71+ mkdir public/system public/uploads && \
7572 chown -R rails:rails db log tmp public/system public/uploads
7673USER rails:rails
7774
7875# Deployment options
7976ENV RAILS_LOG_TO_STDOUT="1" \
80- RAILS_SERVE_STATIC_FILES="true"
77+ RAILS_SERVE_STATIC_FILES="true" \
78+ RAILS_MAX_THREADS="1"
8179
8280# Entrypoint prepares the database.
8381ENTRYPOINT ["/rails/bin/docker-entrypoint" ]
0 commit comments