-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDockerfile-prod
More file actions
41 lines (30 loc) · 1.32 KB
/
Dockerfile-prod
File metadata and controls
41 lines (30 loc) · 1.32 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
FROM node:20-alpine@sha256:6178e78b972f79c335df281f4b7674a2d85071aae2af020ffa39f0a770265435 AS appbuild
RUN apk update
RUN apk add --no-cache build-base python3 && ln -sf python3 /usr/bin/python
RUN npm install -g npm@10 typescript@3.5.2
WORKDIR /build
# use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
COPY package*.json ./
# install dev dependencies for building
RUN npm i
# copy the code into the image for building
COPY . ./
# compile typescript
RUN tsc
# make a 2 part Dockerfile in order reduce overall image size of the final prod image
FROM node:20-alpine@sha256:6178e78b972f79c335df281f4b7674a2d85071aae2af020ffa39f0a770265435
RUN apk update && apk upgrade && apk add curl --no-cache && apk add --no-cache build-base python3 && ln -sf python3 /usr/bin/python
# create dirs in the container & set permissions so node user can access them
RUN mkdir -p /web && chown -R node:node /web
USER node
WORKDIR /web
# copy the package.jsons to prepare for install
COPY --chown=node:node package*.json ./
# install dependencies only for prod
RUN npm i --only=production
# copy the built code from the build image into the prod image
COPY --from=appbuild --chown=node:node /build /web/
EXPOSE 1342
CMD ["node", "/web/dist/bin/main.js"]
#CMD ["tail", "-f", "/dev/null"]