|
1 | 1 | # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile |
2 | 2 | ARG RUBY_VERSION=3.4.6 |
3 | | -FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base |
| 3 | +FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base |
4 | 4 |
|
5 | 5 | # Current commit hash environment variable |
6 | 6 | ARG GIT_COMMIT |
@@ -32,7 +32,7 @@ ENV RAILS_ENV="production" \ |
32 | 32 |
|
33 | 33 |
|
34 | 34 | # Throw-away build stage to reduce size of final image |
35 | | -FROM base as build |
| 35 | +FROM base AS build |
36 | 36 |
|
37 | 37 | # Install application gems |
38 | 38 | COPY Gemfile Gemfile.lock ./ |
@@ -60,23 +60,26 @@ COPY --from=build /app /app |
60 | 60 |
|
61 | 61 | RUN chmod +x /app/.controlplane/*.sh |
62 | 62 |
|
| 63 | +# Set environment variables for asset compilation |
63 | 64 | ENV RAILS_ENV=production \ |
64 | | - NODE_ENV=production \ |
65 | | - SECRET_KEY_BASE=NOT_USED_NON_BLANK |
66 | | -# compiling assets requires any value for ENV of SECRET_KEY_BASE |
| 65 | + NODE_ENV=production |
67 | 66 |
|
68 | 67 | # These files hardly ever change |
69 | 68 | RUN bin/rails react_on_rails:locale |
70 | 69 |
|
71 | 70 | # These files change together, /app/lib/bs are temp build files for rescript, |
72 | 71 | # and /app/client/app are the client assets that are bundled, so not needed once built |
73 | 72 | # Helps to have smaller images b/c of smaller Docker Layer Caches and smaller final images |
74 | | -RUN yarn res:build && bin/rails assets:precompile && rm -rf /app/lib/bs /app/client/app |
| 73 | +# SECRET_KEY_BASE is required for asset precompilation but is not persisted in the image |
| 74 | +RUN SECRET_KEY_BASE=precompile_placeholder yarn res:build && \ |
| 75 | + SECRET_KEY_BASE=precompile_placeholder bin/rails assets:precompile && \ |
| 76 | + rm -rf /app/lib/bs /app/client/app |
75 | 77 |
|
76 | 78 | # This is like the shell initialization that will take the CMD as args |
77 | 79 | # For Kubernetes and ControlPlane, this is the command on the workload. |
78 | 80 | ENTRYPOINT ["./.controlplane/entrypoint.sh"] |
79 | 81 |
|
80 | 82 | # Default args to pass to the entry point that can be overridden |
81 | 83 | # For Kubernetes and ControlPlane, these are the "workload args" |
82 | | -CMD ["./bin/rails", "server"] |
| 84 | +# Use Thruster HTTP/2 proxy for optimized performance |
| 85 | +CMD ["bundle", "exec", "thrust", "bin/rails", "server"] |
0 commit comments