-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (46 loc) · 1.72 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
ARG APP_ROOT=/src/app
ARG RUBY_VERSION=3.2.2
FROM ruby:${RUBY_VERSION}-alpine AS gem
ARG APP_ROOT
RUN apk add --no-cache build-base postgresql-dev
RUN mkdir -p ${APP_ROOT}
COPY Gemfile Gemfile.lock ${APP_ROOT}/
WORKDIR ${APP_ROOT}
RUN gem install bundler:2.3.14 \
&& bundle config --local deployment 'true' \
&& bundle config --local frozen 'true' \
&& bundle config --local no-cache 'true' \
&& bundle config --local without 'development test' \
&& bundle install -j "$(getconf _NPROCESSORS_ONLN)" \
&& 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 shared-mime-info tzdata postgresql-libs
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
# 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}
USER ruby
WORKDIR ${APP_ROOT}
EXPOSE 3000
HEALTHCHECK CMD curl -f http://localhost:3000/status || exit 1
ENTRYPOINT ["bin/openbox"]
CMD ["server"]