-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (33 loc) · 1.21 KB
/
Dockerfile
File metadata and controls
36 lines (33 loc) · 1.21 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
# this is a baseImage we write it at first to help us creating other elements
FROM node:16 as development
# create a new folder called /app
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# install nodejs packages which exists in the container
RUN npm install
# Copy the rest of the application code and put it inside the folder we did create "app"
COPY . /app/
# COPY . . ➡ this command can works too !
# Build the TypeScript code
RUN npm run build
# Define the network ports that this container will listen on at runtime
EXPOSE 4000
CMD ["npm", "run", "start:dev"]
# this is a baseImage we write it at first to help us creating other elements
FROM node:16 as production
# create a new folder called /app
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# install nodejs packages which exists in the container
RUN npm install --only=production
# Copy the rest of the application code and put it inside the folder we did create "app"
COPY . /app/
# COPY . . ➡ this command can works too !
# Build the TypeScript code
RUN npm run build
# Define the network ports that this container will listen on at runtime
EXPOSE 4000
#! Production mode
CMD ["node", "dist/index.js"]