-
Notifications
You must be signed in to change notification settings - Fork 19
/
Dockerfile
49 lines (38 loc) · 1.27 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
FROM node:lts AS base
RUN apt-get update && apt-get -y install autoconf gcc make
WORKDIR /app
FROM base AS staging-build
COPY package.json package.json
COPY package-lock.json package-lock.json
COPY .husky/install.mjs .husky/install.mjs
RUN npm ci
COPY docs docs
COPY src src
COPY package package
COPY .eleventy.js .eleventy.js
COPY gulp gulp
COPY gulpfile.js gulpfile.js
COPY README.md README.md
COPY webpack.config.js webpack.config.js
RUN STAGING=1 npm run build:docs
FROM base AS production-build
RUN apt-get -y install git
ARG GITHUB_DEPLOY_KEY
RUN mkdir /root/.ssh/
RUN echo "${GITHUB_DEPLOY_KEY}" > /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
RUN git clone git@github.com:ministryofjustice/moj-frontend.git .
run npm install
RUN npm run build:docs
RUN rm /root/.ssh/id_rsa
FROM nginxinc/nginx-unprivileged:alpine AS staging
EXPOSE 3000
COPY docker/htpasswd /etc/nginx/.htpasswd
COPY docker/nginx-staging.conf /etc/nginx/conf.d/default.conf
COPY --from=staging-build /app/public /usr/share/nginx/html
FROM nginxinc/nginx-unprivileged:alpine AS production
EXPOSE 3000
COPY docker/nginx-production.conf /etc/nginx/conf.d/default.conf
COPY --from=production-build /app/public /usr/share/nginx/html