-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Dockerfile
46 lines (40 loc) · 1.19 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
FROM ruby:alpine3.17 AS base
ARG RAILS_ROOT=/usr/src/app
ENV RAILS_ROOT=${RAILS_ROOT}
ARG RAILS_ENV
ENV RAILS_ENV=${RAILS_ENV:-production}
ARG NODE_ENV
ENV NODE_ENV=${RAILS_ENV}
ARG RAILS_LOG_TO_STDOUT
ENV RAILS_LOG_TO_STDOUT=${RAILS_LOG_TO_STDOUT:-true}
ARG RAILS_SERVE_STATIC_FILES
ENV RAILS_SERVE_STATIC_FILES=${RAILS_SERVE_STATIC_FILES:-true}
ARG PORT
ENV PORT=${PORT:-3000}
ARG VERSION_TAG
ENV VERSION_TAG=$VERSION_TAG
ENV PATH=$PATH:$RAILS_ROOT/bin
WORKDIR $RAILS_ROOT
RUN bundle config --local deployment 'true' \
&& bundle config --local without 'development:test'
FROM base as build
ARG PACKAGES='alpine-sdk libpq-dev'
COPY Gemfile Gemfile.lock ./
RUN apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& bundle install --no-cache \
&& bundle doctor
FROM base as prod
ARG PACKAGES='libpq-dev tzdata imagemagick yarn bash'
COPY --from=build $RAILS_ROOT/vendor/bundle ./vendor/bundle
COPY package.json yarn.lock ./
RUN apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& yarn install --production --frozen-lockfile \
&& yarn cache clean
COPY . ./
RUN apk update \
&& apk upgrade \
&& update-ca-certificates
EXPOSE ${PORT}
ENTRYPOINT [ "./bin/start" ]