-
Notifications
You must be signed in to change notification settings - Fork 23
/
Dockerfile
72 lines (57 loc) · 1.9 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
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 ENV="staging" npm run build:docs
FROM base AS preview-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 ENV="staging" 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 [email protected]:ministryofjustice/moj-frontend.git .
run npm install
RUN ENV="production" 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 preview
EXPOSE 3000
COPY docker/htpasswd-preview /etc/nginx/.htpasswd
COPY docker/nginx-preview.conf /etc/nginx/conf.d/default.conf
COPY --from=preview-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