-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
51 lines (34 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
### Build Step
FROM --platform=$BUILDPLATFORM node:20.17.0 as builder
WORKDIR /usr/src/app
COPY package.json ./
COPY package-lock.json ./
ARG TARGETOS
ARG TARGETARCH
RUN npm ci --target_arch=$TARGETARCH --target_platform=$TARGETOS
COPY . .
ENV NX_DAEMON=false
ENV CI=true
RUN npx nx run deep-heating-socketio:build
RUN npx nx run deep-heating-web:build
RUN npm prune --omit=dev
### Serve Step
FROM node:20.17.0-slim
# Add nginx and create the run folder for nginx.
RUN apt-get update && apt-get install -y \
nginx \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /run/nginx
RUN npm i -g pm2
LABEL org.opencontainers.image.source = "https://github.com/GraemeF/home-automation"
WORKDIR /app
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/package.json .
COPY --from=builder /usr/src/app/package-lock.json .
COPY --from=builder /usr/src/app/dist/packages/deep-heating-web ./deep-heating-web
COPY --from=builder /usr/src/app/packages/deep-heating-web/package.json ./deep-heating-web
COPY --from=builder /usr/src/app/dist/packages/deep-heating-socketio ./deep-heating-socketio
COPY --from=builder /usr/src/app/package.json ./deep-heating-socketio
COPY --from=builder /usr/src/app/packages/deep-heating/assets/ingress.conf /etc/nginx/nginx.conf
COPY --from=builder /usr/src/app/packages/deep-heating/assets/process.json .
CMD ["pm2", "start", "--no-daemon", "process.json"]