-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathDockerfile
54 lines (40 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
52
53
54
ARG IMG=node:22.11-alpine3.19
FROM $IMG as builder
WORKDIR /usr/src/app/
COPY .babelrc package.json package-lock.json ./
# Install build dependencies
# We use `npm install` so we install dev deps e.g. babel
RUN apk add --no-cache --virtual .gyp python3 make g++ &&\
npm install &&\
apk del .gyp
COPY ./src/ ./src/
COPY ./scripts/ ./scripts/
COPY config.js.docker ./src/config.js
RUN npm run build && npm run build-scripts
FROM $IMG as deps
WORKDIR /usr/src/app/
ENV NODE_ENV=production
# Install only production dependencies with `npm ci`
# We will only use the node_modules folder from this step
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .gyp python3 make g++ &&\
npm ci --only=production &&\
apk del .gyp &&\
npm cache clean --force &&\
rm -rf /tmp/* /var/cache/apk/*
FROM $IMG
WORKDIR /usr/src/app/
ENV NODE_ENV=production
ENV HEADLESS_SCRIPTS_SKIP_BUILD=1
ENV HEADLESS_SCRIPTS_SKIP_CLEAN=1
# Get built source code from `builder` and dependencies from `deps`
COPY --from=builder /usr/src/app/dist/ ./dist/
COPY --from=builder /usr/src/app/dist-scripts/ ./dist-scripts/
COPY --from=deps /usr/src/app/node_modules/ ./node_modules/
COPY --from=deps /usr/src/app/package.json ./
COPY Makefile ./
# Install the process supervisor
RUN apk add --no-cache dumb-init make &&\
rm -rf /tmp/* /var/cache/apk/*
EXPOSE 8000
ENTRYPOINT ["dumb-init", "node", "dist/index.js"]