This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
generated from AMRC-FactoryPlus/acs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (59 loc) · 1.76 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
# syntax=docker/dockerfile:1
# The line above must be the first line in the file!
ARG acs_build=ghcr.io/amrc-factoryplus/utilities-build:v1.0.8
ARG acs_run=ghcr.io/amrc-factoryplus/utilities-run:v1.0.8
FROM ${acs_build} as ts-compiler
# This ARG must go here, in the image that uses it, or it isn't
# available to the shell scripts. Don't ask me why...
ARG acs_npm=NO
USER root
RUN <<'SHELL'
apk add git
install -d -o node /home/node /usr/app
SHELL
USER node
WORKDIR /usr/app
COPY --chown=node . ./
RUN <<'SHELL'
touch /home/node/.npmrc
if [ "${acs_npm}" != NO ]
then
echo "SETTING NPM REGISTRY TO ${acs_npm}" >&2
npm config set @amrc-factoryplus:registry "${acs_npm}"
fi
npm install --save=false
git describe --tags --dirty \
| sed -e's/^/export const GIT_VERSION="/;s/$/";/' \
> ./lib/git-version.js
npm run clean
echo tsc -v
npm run build
SHELL
FROM ${acs_build} as util-build
USER root
RUN <<'SHELL'
# Are these necessary?
apk upgrade --update-cache --available
apk add openssl
rm -rf /var/cache/apk/*
install -d -o node /home/node /usr/app
SHELL
USER node
WORKDIR /usr/app
COPY --chown=node --from=ts-compiler /usr/app/package*.json ./
COPY --chown=node --from=ts-compiler /usr/app/dist ./
COPY --chown=node --from=ts-compiler /home/node/.npmrc /home/node
RUN npm install --save=false --only=production
FROM ${acs_run}
USER root
RUN <<'SHELL'
apk upgrade --update-cache --available
apk add openssl
rm -rf /var/cache/apk/*
SHELL
WORKDIR /usr/app
# This copy leaves the app files owned as root, i.e. read-only to the
# running application. This is a Good Thing.
COPY --from=util-build /usr/app ./
USER node
CMD [ "node", "--es-module-specifier-resolution=node", "bin/ingester.js" ]