-
Notifications
You must be signed in to change notification settings - Fork 21
/
Dockerfile.backend
68 lines (53 loc) · 2.01 KB
/
Dockerfile.backend
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
# Stage backend
# This describes the stage backend image, which contains a nodejs app
# acting as the server proxy and widgets backend.
# Build this with e.g.: `docker build -f Dockerfile.backend . -t stage_backend`
FROM node:18.20.4
ARG username=cfyuser
ARG groupname=cfyuser
ARG MAPS_ACCESS_TOKEN
# envvars are used in the entrypoint script
# db settings
ENV POSTGRES_DB=cloudify_db
ENV POSTGRES_HOST=postgresql
ENV POSTGRES_USER=cloudify
ENV POSTGRES_PASSWORD=cloudify
ENV MAPS_ACCESS_TOKEN=$MAPS_ACCESS_TOKEN
# stage backend needs to be able to reach restservice at this address, port & proto
ENV RESTSERVICE_ADDRESS=localhost
ENV RESTSERVICE_PROTOCOL=https
ENV RESTSERVICE_PORT=443
# by default, listen on all interfaces
ENV LISTEN_HOST="0.0.0.0"
WORKDIR /app
# Install build dependencies up front, so that those layers can still be cached
# if just the backend source code changes. This will only need to be rebuilt
# when the dependencies themselves change.
COPY package.json /app/
COPY package-lock.json /app/
COPY backend/package.json /app/backend/
COPY backend/package-lock.json /app/backend/
# We do need node_modules to be stored in the resulting image, hence not
# mounting node_modules as cache here.
RUN npm run ci:backend
# We'll also need to build frontend code here, because the stage backend is what
# serves the actual widget code.
# First, install prerequisities - those don't need to be in the resulting image,
# because they're only build-time dependencies (e.g. webpack).
RUN --mount=type=cache,target=/app/node_modules \
npm run ci:frontend
# Copy the actual source code - backend and frontend - and build frontend
# artifacts, including widgets and templates.
COPY . /app
RUN --mount=type=cache,target=/app/node_modules \
npm run build
RUN mkdir -p \
/etc/cloudify \
/var/log/cloudify/stage
RUN groupadd $groupname && useradd -u 1500 -m -g $groupname $username
RUN chown -R $username:$groupname \
/app \
/etc/cloudify \
/var/log/cloudify
USER 1500
ENTRYPOINT /app/packaging/entrypoint.sh