-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
69 lines (52 loc) · 1.69 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
ARG ALPINE_VERSION
ARG RUBY_VERSION
# Defines base image which builder and final stage use
FROM ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION} as base
ARG BUNDLER_VERSION
RUN apk add --update \
bash \
coreutils \
git \
nodejs \
tzdata \
yarn \
&& rm -rf /var/cache/apk/* \
&& gem update --system \
&& gem install bundler:$BUNDLER_VERSION \
&& bundle config --global frozen 1
FROM base as builder
RUN apk add --update build-base
WORKDIR /usr/src/app
COPY config.ru Gemfile Gemfile.lock Rakefile ./
COPY package.json babel.config.js postcss.config.js yarn.lock ./
COPY .bundle/config /root/.bundle/config
COPY bin bin
RUN ./bin/bundle config set --local without 'development test' && ./bin/bundle install && mkdir log
COPY app app
COPY config config
COPY lib lib
COPY public public
# Compile
RUN yarn install --production && RAILS_ENV=production NODE_OPTIONS=--openssl-legacy-provider bundle exec rake assets:precompile \
&& mkdir -m 777 /usr/src/app/coverage
# Start a new stage to minimise the final image size
FROM base
ARG image_name
ARG git_branch
ARG git_commit_hash
ARG github_run_number
ARG VERSION
LABEL com.epimorphics.name=$image_name \
com.epimorphics.branch=$git_branch \
com.epimorphics.build=$github_run_number \
com.epimorphics.commit=$git_commit_hash \
com.epimorphics.version=$VERSION
RUN addgroup -S app && adduser -S -G app app
EXPOSE 3000
WORKDIR /usr/src/app
COPY --from=builder --chown=app /usr/local/bundle /usr/local/bundle
COPY --from=builder --chown=app /usr/src/app .
USER app
# Add a script to be executed every time the container starts.
COPY entrypoint.sh "/app/entrypoint.sh"
ENTRYPOINT ["sh", "/app/entrypoint.sh"]