-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
54 lines (42 loc) · 1.4 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
ARG PARENT_VERSION=2.2.2-node20.11.1
FROM defradigital/node:${PARENT_VERSION} AS base
ARG PORT=3000
ENV PORT=${PORT}
USER root
# set -xe : -e abort on error : -x verbose output
RUN set -xe \
&& apk update && apk upgrade \
&& rm -rf /var/cache/apk/* \
&& mkdir -p /home/node/app
# Create app directory
WORKDIR /home/node/app
# Copy the basic directories/files across
RUN mkdir -p dist
COPY --chown=root:root package*.json .
COPY --chown=root:root ./index.js .
COPY --chown=root:root ./client ./client
COPY --chown=root:root ./server ./server
COPY --chown=root:root ./bin ./bin
COPY --chown=root:root ./config ./config
COPY --chown=root:root ./webpack.config.mjs ./webpack.config.mjs
COPY --chown=root:root ./babel.config.json ./babel.config.json
ARG BUILD_VERSION=v3.0.0-1-g6666666
ARG GIT_COMMIT=0
RUN echo -e "module.exports = { version: '$BUILD_VERSION', revision: '$GIT_COMMIT' }" > ./version.js
FROM base AS development
# Temporarily disable the postinstall NPM script
RUN npm pkg set scripts.postinstall="echo no-postinstall" \
&& npm ci --ignore-scripts --omit dev \
&& npm run build
USER node
EXPOSE ${PORT}/tcp
CMD [ "node", "index.js" ]
FROM base AS production
# Temporarily disable the postinstall NPM script
RUN npm pkg set scripts.postinstall="echo no-postinstall" \
&& npm ci --ignore-scripts --omit dev \
&& npm run build \
&& npm run build-map
USER node
EXPOSE ${PORT}/tcp
CMD [ "node", "index.js" ]