-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (36 loc) · 1.08 KB
/
Dockerfile
File metadata and controls
48 lines (36 loc) · 1.08 KB
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
FROM node:24-alpine as ci
ENV NODE_ENV=test
ENV BLUEBIRD_DEBUG=0
ENV HUSKY_SKIP_INSTALL=true
ARG CI=true
RUN mkdir /app
WORKDIR /app
COPY . .* ./
RUN npm ci
RUN npm run build
RUN npm run lint
RUN npm run test
# --------------- Cleanup
FROM ci as clean
# below command removes the packages specified in devDependencies and set NODE_ENV to production
RUN npm prune --production
# --------------- Production stage
FROM node:24-alpine AS prod
ENV NODE_ENV=production
ENV NODE_PATH='dist'
# Install dependencies
RUN apk --no-cache add python3 git jq openssh tini
# Install app
RUN mkdir /app
WORKDIR /app
COPY --from=clean /app/node_modules node_modules
COPY --from=ci /app/dist dist
COPY package.json .
# Add nouser to /etc/passwd for ssh connection
RUN echo 'nouser:x:999:999::/home/nouser:/bin/sh' >> /etc/passwd
USER node
EXPOSE 8080
# tini is used as PID 1 to reap zombie child processes (e.g. git-remote-http)
# that Node.js would otherwise leave unreaped, causing PID exhaustion over time
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "--max-http-header-size", "16384", "dist/src/app.js"]