-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
69 lines (50 loc) · 1.38 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
66
67
68
69
# syntax=docker/dockerfile:1.12
##################
## common
##################
FROM --platform=$BUILDPLATFORM node:20-alpine as common
WORKDIR /app
##################
## build-api
##################
FROM common as build-api
LABEL stage="build-api"
COPY *.json /app/
RUN --mount=type=cache,target=/home/root/.npm \
npm set cache /usr/src/app/.npm && \
npm ci
COPY src/ /app/src/
RUN NODE_ENV=production npm run build
##################
## build-frontend
##################
FROM common as build-frontend
LABEL stage="build-frontend"
ARG VERSION=unknown
WORKDIR /app/frontend
COPY frontend/package*.json /app/frontend/
RUN --mount=type=cache,target=/home/root/.npm \
npm set cache /usr/src/app/.npm && \
npm ci
COPY frontend/ /app/frontend/
RUN NODE_ENV=production npm run build
##################
## app
##################
FROM node:20-alpine as app
ARG VERSION=unknown
ARG GIT_COMMIT=unknown
LABEL org.opencontainers.image.title="listory" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.revision=$GIT_COMMIT \
stage="common"
WORKDIR /app
ENV NODE_ENV=production
COPY package.json /app/
COPY package-lock.json /app/
RUN --mount=type=cache,target=/home/root/.npm \
npm set cache /usr/src/app/.npm && \
npm ci --omit=dev
COPY --from=build-api /app/dist/ /app/dist/
COPY --from=build-frontend /app/frontend/build /app/static/
CMD ["dist/main"]