-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
41 lines (38 loc) · 1.2 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
# BASE: a base image with updated packages
FROM node:lts-alpine AS base
RUN apk upgrade --no-cache --available
# BUILDER: a container to build the service dist directory
FROM base AS builder
# install pnpm
RUN corepack prepare [email protected] --activate
RUN npm install -g pnpm
# install static web server
RUN apk add curl sudo which
RUN curl --proto '=https' --tlsv1.2 -sSfL https://get.static-web-server.net | sed "s/cp -ax/cp -a/g" | sh
# build the service
WORKDIR /service
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
COPY . .
RUN npm run build
# RUNNER: a container to run the service
FROM base AS runner
RUN adduser -D appuser
WORKDIR /home/appuser
USER appuser
# install dist directory and run script
COPY --from=builder /service/dist/data-portal/browser ./dist
# install static web server
COPY --from=builder /usr/local/bin/static-web-server /usr/local/bin
# make the config file writeable to the appuser
USER root
RUN touch ./dist/config.js && chown appuser ./dist/config.js
USER appuser
# install run script
COPY ./run.js ./run.mjs
# install dependencies for run script
RUN npm install js-yaml
# install default configuration file
COPY ./data-portal.default.yaml .
ENTRYPOINT ["node"]
CMD ["/home/appuser/run.mjs"]