-
Notifications
You must be signed in to change notification settings - Fork 84
/
Dockerfile.development
72 lines (60 loc) · 2.93 KB
/
Dockerfile.development
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:hydrogen-alpine3.19
LABEL maintainer=FormSG<[email protected]>
WORKDIR /opt/formsg
RUN mkdir /mongodb_data
RUN chown 1001:1001 /mongodb_data
ENV CHROMIUM_BIN=/usr/bin/chromium-browser
ENV NODE_ENV=development
ENV NODE_OPTIONS="--max-old-space-size=2048"
RUN apk update && apk upgrade && \
# Build dependencies for node_modules
apk add --virtual native-deps \
# Python version must be specified starting in alpine3.12
g++ gcc libgcc libstdc++ linux-headers autoconf automake make nasm python3 git curl \
# Runtime dependencies
# Note that each alpine version supports a specific version of chromium
# Note that chromium and puppeteer-core are released together and it is the only version
# that is guaranteed to work. Upgrades must be done in lockstep.
# https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#running-on-alpine
# https://www.npmjs.com/package/puppeteer-core?activeTab=versions for corresponding versions
# Compatible chromium versions can be found here https://pkgs.alpinelinux.org/packages?name=chromium&branch=v3.19&repo=&arch=&maintainer=
chromium=124.0.6367.78-r0 \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
tini \
# Localstack - these are necessary in order to initialise local S3 buckets
# jq is a package for easily parsing Localstack health endpoint's JSON output
jq \
py-pip && \
npm install --quiet node-gyp -g && \
# [ver1] ensures that the underlying AWS CLI version is also installed
pip install awscli-local[ver1] --break-system-packages
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# This package is needed to render Chinese characters in autoreply PDFs
RUN apk add font-wqy-zenhei --repository https://dl-cdn.alpinelinux.org/alpine/edge/community
# Avoid using globs as there seems to be some inconsistency in the way dockerfile handles globs
# * https://github.com/moby/moby/issues/15858
COPY package.json package-lock.json ./
COPY shared/package.json shared/package-lock.json ./shared/
COPY frontend/package.json frontend/package-lock.json ./frontend/
# --legacy-peer-deps flag
# A breaking change in the peer dependency resolution strategy was introduced in
# npm 7. This resulted in npm throwing an error when installing packages:
# npm ERR! code ERESOLVE
# npm ERR! ERESOLVE unable to resolve dependency tree
# See also:
# * https://stackoverflow.com/questions/66239691/what-does-npm-install-legacy-peer-deps-do-exactly-when-is-it-recommended-wh
RUN npm install --legacy-peer-deps
COPY . ./
EXPOSE 5000
# tini is the init process that will adopt orphaned zombie processes
# e.g. chromium when launched to create a new PDF
ENTRYPOINT [ "tini", "--" ]
# Create local AWS resources before building the app
CMD sh init-localstack.sh && npm run dev:backend