-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
66 lines (45 loc) · 1.17 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Stage 1: Build
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /usr/src/app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Stage 2: Production
FROM node:20-alpine AS production
# Set working directory
WORKDIR /usr/src/app
# Copy package files
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy built artifacts from builder stage
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/node_modules ./node_modules
# Expose the port the app runs on
EXPOSE 3000
# Set environment to production
ENV NODE_ENV=production
# Command to run the application
CMD ["node", "dist/main"]
# Stage 3: Development
FROM node:20-alpine AS development
# Set working directory
WORKDIR /usr/src/app
# Copy package files
COPY package*.json ./
# Install all dependencies (including dev)
RUN npm ci
# Copy source code
COPY . .
# Expose the port the app runs on
EXPOSE 3000
# Set environment to development
ENV NODE_ENV=development
# Use nodemon for development with hot reloading
CMD ["npm", "run", "start:dev"]