Skip to content

Commit 76741ba

Browse files
authored
build: add multi stage Dockerfile (#2)
1 parent ee37561 commit 76741ba

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
FROM node:alpine
1+
FROM node:alpine as base
22

33
WORKDIR /usr/src/app
44

5-
COPY package*.json .
6-
COPY dist dist
5+
COPY . .
76

8-
RUN npm install --ignore-scripts
7+
RUN npm ci
98

10-
EXPOSE 9000
9+
RUN npm run build
10+
11+
FROM node:alpine
12+
13+
WORKDIR /usr/src/app
1114

1215
ENV PORT=""
1316
ENV TARGET=""
1417
ENV EXPIRY=""
1518

19+
COPY --from=base --chown=nobody:nogroup /usr/src/app/dist dist
20+
COPY --from=base --chown=nobody:nogroup /usr/src/app/node_modules node_modules
21+
USER nobody
22+
EXPOSE 9000
23+
1624
CMD sh -c "node dist/index.js --port $PORT --target $TARGET --expiry $EXPIRY"

0 commit comments

Comments
 (0)