1
1
# syntax = docker/dockerfile:1
2
2
3
3
# 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
6
6
7
7
LABEL fly_launch_runtime="rails"
8
8
@@ -30,17 +30,18 @@ RUN apt-get update -qq && \
30
30
# rm -rf /tmp/node-build-master
31
31
32
32
# Throw-away build stage to reduce size of final image
33
- FROM base as build
33
+ FROM base AS build
34
34
35
35
# Install packages needed to build gems and node modules
36
36
RUN 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
38
38
39
39
# Build options
40
40
ENV PATH="/usr/local/node/bin:$PATH"
41
41
42
- # Install application gems
43
- COPY --link Gemfile ./
42
+ # Copy application code
43
+ COPY --link . .
44
+
44
45
RUN sed -i "s/, path: '..\/ ..\/ '//" Gemfile
45
46
RUN bundle install && \
46
47
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
@@ -49,21 +50,16 @@ RUN bundle install && \
49
50
# COPY --link package.json ./
50
51
# RUN npm install
51
52
52
- # Copy application code
53
- COPY --link . .
54
- RUN sed -i "s/, path: '..\/ ..\/ '//" Gemfile
55
-
56
53
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
57
54
RUN 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
60
56
61
57
# Final stage for app image
62
58
FROM base
63
59
64
60
# Install packages needed for deployment
65
61
RUN 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 && \
67
63
rm -rf /var/lib/apt/lists /var/cache/apt/archives
68
64
69
65
# Copy built artifacts: gems, application
@@ -72,12 +68,14 @@ COPY --from=build /rails /rails
72
68
73
69
# Run and own only the runtime files as a non-root user for security
74
70
RUN useradd rails --create-home --shell /bin/bash && \
71
+ mkdir public/system public/uploads && \
75
72
chown -R rails:rails db log tmp public/system public/uploads
76
73
USER rails:rails
77
74
78
75
# Deployment options
79
76
ENV RAILS_LOG_TO_STDOUT="1" \
80
- RAILS_SERVE_STATIC_FILES="true"
77
+ RAILS_SERVE_STATIC_FILES="true" \
78
+ RAILS_MAX_THREADS="1"
81
79
82
80
# Entrypoint prepares the database.
83
81
ENTRYPOINT ["/rails/bin/docker-entrypoint" ]
0 commit comments