This repository has been archived by the owner on May 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
65 lines (49 loc) · 1.82 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
FROM ruby:3.0.0-alpine3.13 as build
ARG RAILS_ENV=production
ENV RAILS_ENV=$RAILS_ENV
RUN apk add --no-cache libxml2-dev libxslt-dev build-base postgresql-dev yarn tzdata
RUN mkdir -p /usr/src/garrison
WORKDIR /usr/src/garrison
COPY Gemfile Gemfile.lock /usr/src/garrison/
RUN set -ex; \
if [ "$RAILS_ENV" = "production" ]; then \
bundle install --jobs "$(getconf _NPROCESSORS_ONLN)" --retry 5 --without test development; \
elif [ "$RAILS_ENV" = "development" ]; then \
bundle install --jobs "$(getconf _NPROCESSORS_ONLN)" --retry 5; \
fi;
RUN rm /usr/local/bundle/cache/*.gem
COPY package.json yarn.lock /usr/src/garrison/
RUN set -ex; \
if [ "$RAILS_ENV" = "production" ]; then \
yarn install --frozen-lockfile --production && yarn cache clean; \
elif [ "$RAILS_ENV" = "development" ]; then \
yarn install --frozen-lockfile && yarn cache clean; \
fi;
COPY . /usr/src/garrison
RUN SECRET_KEY_BASE=1 bundle exec rake assets:precompile
RUN rm -rf /usr/src/garrison/app/assets
RUN rm -rf /usr/src/garrison/node_modules
RUN rm -rf /usr/src/garrison/tmp
RUN find /usr/local/bundle -iname '*.o' -exec rm {} \;
RUN find /usr/local/bundle -iname '*.a' -exec rm {} \;
# RUNTIME CONTAINER
FROM ruby:3.0.0-alpine3.13
ARG RAILS_ENV=production
ENV RAILS_ENV=$RAILS_ENV
RUN apk upgrade --no-cache
RUN apk add --no-cache libpq tzdata xz-libs
WORKDIR /usr/src/garrison
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /usr/src/garrison /usr/src/garrison
COPY app/assets/config /usr/src/garrison/app/assets/config
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES true
RUN set -ex; \
if [ "$RAILS_ENV" = "production" ]; then \
bundle install --without assets;\
elif [ "$RAILS_ENV" = "development" ]; then \
bundle install;\
apk add --no-cache build-base nodejs; \
fi;
EXPOSE 3000
CMD ["bin/entry"]