-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
107 lines (79 loc) · 2.51 KB
/
Dockerfile
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Base
FROM ruby:3.0.0-alpine AS base
LABEL maintainer="Tobias Bohn <[email protected]>"
ARG APP_PATH=/application/
ENV APP_PATH=$APP_PATH
WORKDIR $APP_PATH
# Builder
FROM base AS builder
RUN bundle config --global frozen 1 \
&& apk --no-cache --update add \
build-base \
ruby-dev \
postgresql-dev \
tzdata \
bash \
git \
# for tailwindcss (https://github.com/rails/tailwindcss-rails/issues/115):
gcompat \
&& gem install bundler:2.2.3
COPY Gemfile* $APP_PATH
# Developer Bundle
FROM builder AS dev_bundle
RUN bundle install -j4 --retry 3 \
&& 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
COPY . $APP_PATH
# Production Bundle
FROM builder AS prod_bundle
RUN bundle install --without development test -j4 --retry 3 \
&& 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
COPY . $APP_PATH
ARG RAILS_MASTER_KEY
RUN RAILS_ENV=production bundle exec rake assets:precompile \
&& rm -rf tmp/cache app/assets/builds app/assets/images app/assets/stylesheets vendor/assets lib/assets spec
# Developer Final
FROM base AS development
EXPOSE 3000
COPY entrypoints/web-entrypoint.sh /usr/bin/entrypoint.sh
COPY entrypoints/job-entrypoint.sh /usr/bin/job-entrypoint.sh
RUN apk --update --no-cache add \
postgresql-client \
chromium-chromedriver \
chromium \
tzdata \
bash \
vips \
# for tailwindcss (https://github.com/rails/tailwindcss-rails/issues/115):
gcompat \
&& chmod +x /usr/bin/entrypoint.sh \
&& chmod +x /usr/bin/job-entrypoint.sh
COPY --from=dev_bundle /usr/local/bundle/ /usr/local/bundle/
COPY --from=dev_bundle $APP_PATH $APP_PATH
ENTRYPOINT ["entrypoint.sh"]
CMD ["rails", "server", "-b", "0.0.0.0"]
# Production Final
FROM base AS production
ENV RAILS_ENV=production \
RAILS_LOG_TO_STDOUT=true \
RAILS_SERVE_STATIC_FILES=true \
EXECJS_RUNTIME=Disabled
EXPOSE 3000
COPY entrypoints/web-entrypoint.sh /usr/bin/entrypoint.sh
COPY entrypoints/job-entrypoint.sh /usr/bin/job-entrypoint.sh
RUN apk --update --no-cache add \
postgresql-client \
tzdata \
bash \
vips \
&& chmod +x /usr/bin/entrypoint.sh \
&& chmod +x /usr/bin/job-entrypoint.sh
COPY --from=prod_bundle /usr/local/bundle/ /usr/local/bundle/
COPY --from=prod_bundle $APP_PATH $APP_PATH
ENTRYPOINT ["entrypoint.sh"]
CMD ["rails", "server", "-b", "0.0.0.0"]