-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
80 lines (60 loc) · 1.91 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM ruby:3.0.3-alpine3.13 AS builder
# Minimal requirements to run a Rails app
RUN apk add --no-cache --update build-base \
linux-headers \
git \
postgresql-dev=~13 \
# Rails SQL schema format requires `pg_dump(1)` and `psql(1)`
postgresql=~13 \
# Install same version of pg_dump
postgresql-client=~13 \
nodejs \
yarn \
# Needed for nodejs / node-gyp
python2 \
tzdata \
imagemagick
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 /work
WORKDIR $APP_PATH
# Gems installation
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
# NPM packages installation
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --non-interactive --production
ADD . $APP_PATH
# RUN bin/rails stimulus:manifest:update
RUN SECRET_KEY_BASE=`bin/rake secret` rails assets:clobber assets:precompile --trace && \
yarn cache clean && \
rm -rf node_modules tmp/cache vendor/assets test
FROM ruby:3.0.3-alpine3.13
RUN mkdir -p /work
WORKDIR /work
ENV RAILS_ENV production
ENV NODE_ENV production
ENV RAILS_SERVE_STATIC_FILES true
# Some native extensions required by gems such as pg or mysql2.
COPY --from=builder /usr/lib /usr/lib
# Timezone data is required at runtime
COPY --from=builder /usr/share/zoneinfo/ /usr/share/zoneinfo/
# Ruby gems
COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder /work /work
RUN apk add --no-cache --update imagemagick
# COPY docker-entrypoint.sh ./
# ENTRYPOINT ["./docker-entrypoint.sh"]
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]