-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.worker
86 lines (68 loc) · 2.17 KB
/
Dockerfile.worker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM ruby:3.2.2-alpine AS builder
ENV RAILS_ENV=production
ARG RAILS_MASTER_KEY
# Add Alpine packages
RUN apk add --no-cache --update \
build-base zlib-dev git yarn gcompat \
postgresql-dev libffi-dev vips-dev tzdata \
&& mkdir app
WORKDIR /app
COPY Gemfile* package.json yarn.lock esbuild.config.js ./
# Add the Rails app
ADD . /app
RUN gem install --no-document --no-user-install rails -v 7.0.4 \
&& gem install --no-document --no-user-install bundler \
&& bundle config set deployment 'true' \
&& bundle config set --local without 'development test' \
&& bundle config set path 'vendor/bundle' \
&& bundle install -j4 --retry 3 \
&& yarn install \
&& bundle exec rake assets:precompile \
&& bundle clean --force \
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete \
&& rm -rf node_modules tmp/cache \
&& apk del --rdepends --purge build-base
# Production image based on the build image
FROM ruby:3.2.2-alpine AS runner
ENV RAILS_ENV=production \
NODE_ENV=production \
RAILS_LOG_TO_STDOUT=true \
RAILS_SERVE_STATIC_FILES=true \
EXECJS_RUNTIME=Disabled \
RUBY_YJIT_ENABLE=true
ARG DATABASE_POOL \
DATABASE_URL \
DEFAULT_URL \
DISABLE_DATABASE_ENVIRONMENT_CHECK \
DO_ACCESS_KEY_ID \
DO_BUCKET \
DO_ENDPOINT \
DO_SECRET_ACCESS_KEY \
GOOGLE_CLIENT_ID \
GOOGLE_CLIENT_SECRET \
HONEYBADGER_API_KEY \
OPENAI_ACCESS_TOKEN \
OPENAI_ORGANIZATION_ID \
RAILS_MASTER_KEY \
REDISCLOUD_URL \
SENDGRID_API_KEY \
SIDEKIQ_AUTH_PASSWORD \
SIDEKIQ_AUTH_USERNAME
# Add Alpine packages
RUN apk add --no-cache --update \
tzdata nodejs vips-dev ca-certificates \
libffi-dev postgresql-client \
&& bundle config set --local without 'development test' \
&& bundle config set path 'vendor/bundle' \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
RUN mkdir app
# Copy app with gems from former build stage
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder /app /app
WORKDIR /app
EXPOSE 3000
# Save timestamp of image building
RUN date -u > BUILD_TIME
CMD ["bundle exec sidekiq", " -e production", " -C config/sidekiq.yml"]