-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathDockerfile
36 lines (25 loc) · 861 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
# Use the official Node.js 20 Alpine image as a parent image for building
FROM node:20-alpine AS builder
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the TypeScript project
RUN npm run build
# Use a smaller image for the runtime
FROM node:20-alpine
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy the built application from the builder stage
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/package*.json ./
# Install only production dependencies
RUN npm install --only=production
# Expose the port the app runs on
EXPOSE 3001
# Command to run the application
CMD ["node", "dist/index.js"]