-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (30 loc) · 913 Bytes
/
Dockerfile
File metadata and controls
45 lines (30 loc) · 913 Bytes
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
FROM node:20-alpine AS builder
WORKDIR /app
# Install pnpm first
RUN npm install -g pnpm
# Copy package files and install dependencies using pnpm
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Build the application
RUN pnpm build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Create a minimal package.json to avoid prepare scripts
RUN echo '{}' > package.json
# Copy built application from builder stage FIRST
COPY --from=builder /app/dist ./dist
# Then copy the real package files
COPY package.json pnpm-lock.yaml ./
# Install production dependencies without running scripts
RUN pnpm install --frozen-lockfile --prod --ignore-scripts
# Copy .env.example file
COPY .env.example .env.example
# Set environment variables
ENV NODE_ENV=production
# Start the application
CMD ["node", "dist/index.js"]