-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (40 loc) · 1.27 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
FROM ruby:3.1.2 AS builder
WORKDIR /builder
ARG RAILS_MASTER_KEY
ARG RAILS_ENV="production"
ARG APPLICATION_VERSION
ENV RAILS_ENV="${RAILS_ENV}" \
RAILS_MASTER_KEY=${RAILS_MASTER_KEY} \
APPLICATION_VERSION=${APPLICATION_VERSION}
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev
COPY Gemfile Gemfile.lock ./
RUN bundle install --jobs "$(nproc)"
COPY . .
RUN if [ "${RAILS_ENV}" != "development" ]; then \
SECRET_KEY_BASE=dummyvalue rails assets:precompile; fi
FROM ruby:3.1.2 AS app
WORKDIR /app
ARG UID=1000
ARG GID=1000
ARG RAILS_MASTER_KEY
ARG RAILS_ENV="production"
ARG APPLICATION_VERSION
RUN apt-get update \
&& apt-get install -y --no-install-recommends imagemagick
RUN groupadd -g "${GID}" ruby \
&& useradd --create-home --no-log-init -u "${UID}" -g "${GID}" ruby \
&& chown ruby:ruby -R /app
USER ruby
ENV RAILS_ENV="${RAILS_ENV}" \
USER="ruby" \
RAILS_MASTER_KEY=${RAILS_MASTER_KEY} \
APPLICATION_VERSION=${APPLICATION_VERSION}
# Installed gems
COPY --chown=ruby:ruby --from=builder /usr/local/bundle /usr/local/bundle
# Rails
COPY --chown=ruby:ruby --from=builder /builder/public /public
COPY --chown=ruby:ruby --from=builder /builder ./
ENTRYPOINT ["/app/bin/docker-entrypoint-web"]
EXPOSE 3000
CMD rails s