-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.production
71 lines (54 loc) · 1.8 KB
/
Dockerfile.production
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
71
FROM ruby:3.2.0-alpine3.16 AS builder
RUN apk add --no-cache --update --repository=http://dl-cdn.alpinelinux.org/alpine/v3.13/main \
--repository=http://dl-cdn.alpinelinux.org/alpine/v3.14/community \
# --repository=http://dl-cdn.alpinelinux.org/alpine/v3.16/community \
# --repository http://dl-3.alpinelinux.org/alpine/edge/community \
# --repository http://dl-3.alpinelinux.org/alpine/edge/main \
build-base \
linux-headers \
git \
nodejs \
yarn \
libpq-dev \
ruby-dev \
libxml2-dev \
postgresql-dev=~13 \
postgresql=~13 \
postgresql-client=~13 \
# python2 \
tzdata
ENV BUNDLER_VERSION 2.2.24
ENV BUNDLE_JOBS 8
ENV BUNDLE_RETRY 5
ENV BUNDLE_WITHOUT development:test
ENV BUNDLE_CACHE_ALL true
ENV RAILS_ENV production
ENV RACK_ENV production
ENV NODE_ENV production
ENV APP_PATH /opt/webapps/app
WORKDIR $APP_PATH
COPY Gemfile Gemfile.lock ./
RUN gem install bundler -v $BUNDLER_VERSION
RUN bundle config --global frozen 1 && \
bundle install && \
rm -rf /usr/local/bundle/cache/*.gem && \
find /usr/local/bundle/gems/ -name "*.c" -delete && \
find /usr/local/bundle/gems/ -name "*.o" -delete
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --non-interactive --production
ADD . $APP_PATH
RUN rails assets:clobber assets:precompile --trace && \
yarn cache clean && \
rm -rf node_modules tmp/cache vendor/assets test
FROM ruby:3.2.0-alpine3.16
RUN mkdir -p /opt/webapps/app
WORKDIR /opt/webapps/app
ENV RAILS_ENV production
ENV NODE_ENV production
ENV RAILS_SERVE_STATIC_FILES true
COPY --from=builder /usr/lib /usr/lib
COPY --from=builder /usr/share/zoneinfo/ /usr/share/zoneinfo/
COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder /opt/webapps/app /opt/webapps/app
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]