-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
42 lines (28 loc) · 832 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
40
41
# Stage 1: Build the application
FROM node:18-alpine AS builder
# Set the working directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build
# Stage 2: Create the production image
FROM node:18-alpine AS production
# Set the working directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy built application from the builder stage
COPY --from=builder /usr/src/app/dist ./dist
# Set the environment to production
ENV NODE_ENV=production
# Expose the application port
EXPOSE 8080
# Command to run the application
CMD ["node", "dist/main.js"]