forked from ccdcoe/Providentia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.prod
59 lines (46 loc) · 1.67 KB
/
Dockerfile.prod
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
# ruby builder image
FROM ruby:3.1.1-alpine as builder
RUN apk add --no-cache --update build-base \
linux-headers \
git \
postgresql-dev \
tzdata \
less \
sudo
RUN gem install bundler --no-document
COPY Gemfile Gemfile.lock /srv/
WORKDIR /srv
RUN bundle config --global frozen 1 && bundle install --no-binstubs --without development test --jobs $(nproc) --retry 3
# real image
FROM ruby:3.1.1-alpine
ARG CONTAINER_USER_ID
ARG CONTAINER_GROUP_ID
ARG CONTAINER_USER_NAME
ENV CONTAINER_USER_NAME=${CONTAINER_USER_NAME:-app}
ENV CONTAINER_USER_ID=${CONTAINER_USER_ID:-1000}
ENV CONTAINER_GROUP_ID=${CONTAINER_GROUP_ID:-1000}
ENV APP_PATH /srv/app
ENV RAILS_ENV production
ENV NODE_ENV production
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES true
ENV RUBY_GC_HEAP_INIT_SLOTS 2000000
ENV RUBY_HEAP_FREE_MIN 20000
ENV RUBY_GC_MALLOC_LIMIT 100000000
RUN apk add --no-cache --update \
postgresql-dev \
nodejs-current \
tzdata \
less
RUN corepack enable && yarn set version stable
RUN addgroup -S -g ${CONTAINER_GROUP_ID} $CONTAINER_USER_NAME && adduser -S -u ${CONTAINER_USER_ID} -g $CONTAINER_USER_NAME -h /home/$CONTAINER_USER_NAME -s /bin/bash $CONTAINER_USER_NAME
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
RUN mkdir -p $APP_PATH
WORKDIR $APP_PATH
COPY --chown=$CONTAINER_USER_NAME:$CONTAINER_USER_NAME . $APP_PATH
ADD ./docker/prod/docker-entrypoint.sh $APP_PATH
RUN chown $CONTAINER_USER_NAME:$CONTAINER_USER_NAME $APP_PATH
USER $CONTAINER_USER_NAME
RUN yarn --immutable
RUN DATABASE_URL=postgresql://db SECRET_KEY_BASE=`bin/rake secret` bundle exec rake assets:precompile
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]