-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
70 lines (52 loc) · 2.01 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
ARG APP_ROOT=/src/app
ARG RUBY_VERSION=2.7.8
FROM ruby:${RUBY_VERSION}-alpine AS gem
ARG APP_ROOT
RUN apk add --no-cache build-base postgresql-dev gcompat git
RUN mkdir -p ${APP_ROOT}
COPY Gemfile Gemfile.lock ${APP_ROOT}/
ENV BUNDLE_GITLAB__COM=${GITLAB_TOKEN_NAME}:${GITLAB_TOKEN_TOKEN}
WORKDIR ${APP_ROOT}
RUN gem install bundler:2.3.27 \
&& bundle config --local deployment 'true' \
&& bundle config --local frozen 'true' \
&& bundle config --local no-cache 'true' \
&& bundle config --local without 'development test' \
&& bundle install \
&& find ${APP_ROOT}/vendor/bundle -type f -name '*.c' -delete \
&& find ${APP_ROOT}/vendor/bundle -type f -name '*.h' -delete \
&& find ${APP_ROOT}/vendor/bundle -type f -name '*.o' -delete \
&& find ${APP_ROOT}/vendor/bundle -type f -name '*.gem' -delete
FROM ruby:${RUBY_VERSION}-alpine
ARG APP_ROOT
RUN apk add --no-cache curl imagemagick shared-mime-info tzdata postgresql-libs pkgconf pkgconf-dev poppler-utils mupdf-tools nodejs
RUN cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
COPY --from=gem /usr/local/bundle/config /usr/local/bundle/config
COPY --from=gem /usr/local/bundle /usr/local/bundle
COPY --from=gem ${APP_ROOT}/vendor/bundle ${APP_ROOT}/vendor/bundle
RUN mkdir -p ${APP_ROOT}
ENV RAILS_ENV=production
ENV RAILS_LOG_TO_STDOUT=true
ENV RAILS_SERVE_STATIC_FILES=yes
ENV APP_ROOT=$APP_ROOT
COPY . ${APP_ROOT}
ARG REVISION
ENV REVISION $REVISION
ENV COMMIT_SHORT_SHA $REVISION
RUN echo "${REVISION}" > ${APP_ROOT}/REVISION
ARG SENTRY_RELEASE
ENV SENTRY_RELEASE $SENTRY_RELEASE
# Apply Execute Permission
RUN adduser -h ${APP_ROOT} -D -s /bin/nologin ruby ruby && \
chown ruby:ruby ${APP_ROOT} && \
chown -R ruby:ruby ${APP_ROOT}/log && \
chown -R ruby:ruby ${APP_ROOT}/tmp && \
chmod -R +r ${APP_ROOT}
RUN chown -R ruby:ruby ${APP_ROOT}
USER ruby
WORKDIR ${APP_ROOT}
RUN bundle exec rake assets:precompile
EXPOSE 3000
HEALTHCHECK CMD curl -f http://localhost:3000/status || exit 1
ENTRYPOINT ["bin/openbox"]
CMD ["server"]