-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (27 loc) · 866 Bytes
/
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
# Stage 1: Build the application
FROM node:lts-slim AS build
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy the package.json and package-lock.json files to the container
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application source code
COPY . .
# Build the TypeScript application
RUN npm run build
# Stage 2: Create the production image
FROM node:lts-slim
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy only the necessary files from the build stage
COPY --from=build /usr/src/app/package*.json ./
COPY --from=build /usr/src/app/dist ./dist
# Install only production dependencies
RUN npm install --production
# Make port 80 available
EXPOSE 80
# Define environment variable
ENV NODE_ENV=production
# Run the app when the container launches
CMD ["npm", "start"]