-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
63 lines (48 loc) · 1.95 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
FROM ministryofjustice/apply-base:latest-3.4.1
LABEL org.opencontainers.image.vendor="Ministry of Justice" \
org.opencontainers.image.authors="Apply for civil legal aid team ([email protected])" \
org.opencontainers.image.title="Apply for civil legal aid" \
org.opencontainers.image.description="Web service to apply for legal aid in civil matters" \
org.opencontainers.image.url="https://github.com/ministryofjustice/laa-apply-for-legal-aid"
# add non-root user and group with alpine first available uid, 1000
RUN addgroup -g 1000 -S appgroup \
&& adduser -u 1000 -S appuser -G appgroup
# create app directory in conventional, existing dir /usr/src
RUN mkdir -p /usr/src/app && mkdir -p /usr/src/app/tmp
WORKDIR /usr/src/app
######################
# DEPENDENCIES START #
######################
# Env vars needed for dependency install and asset precompilation
COPY .ruby-version Gemfile Gemfile.lock ./
# only install production dependencies,
# build nokogiri using libxml2-dev, libxslt-dev
RUN gem update --system \
&& bundle config --local without 'test development' \
&& bundle config build.nokogiri --use-system-libraries \
&& bundle install
COPY package.json yarn.lock ./
RUN yarn --prod
####################
# DEPENDENCIES END #
####################
ENV RAILS_ENV production
ENV NODE_ENV production
ENV RAILS_SERVE_STATIC_FILES true
EXPOSE 3002
COPY . .
RUN NODE_OPTIONS=--openssl-legacy-provider bundle exec rake assets:precompile SECRET_KEY_BASE=a-real-secret-key-is-not-needed-here
# tidy up installation - these are installed in the apply-base image
RUN apk del build-dependencies
# non-root/appuser should own only what they need to
RUN chown -R appuser:appgroup log tmp db
# expect ping environment variablesARG COMMIT_ID
ARG BUILD_DATE
ARG BUILD_TAG
ARG APP_BRANCH
# set ping environment variables
ENV BUILD_DATE=${BUILD_DATE}
ENV BUILD_TAG=${BUILD_TAG}
ENV APP_BRANCH=${APP_BRANCH}
USER 1000
CMD "./docker/run"