-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (40 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
50 lines (40 loc) · 1.2 KB
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
# Use Node.js 24 (LTS) as base image
FROM node:24-alpine AS base
# Enable corepack for Yarn 4
RUN corepack enable
# Set working directory
WORKDIR /app
# Install dependencies only when needed
FROM base AS deps
# Copy package files
COPY package.json yarn.lock ./
# Copy .yarnrc.yml to use node_modules instead of PnP
COPY .yarnrc.yml ./
# Install dependencies
RUN yarn install --immutable
# Build the application
FROM base AS builder
# Enable corepack in builder stage
RUN corepack enable
# Copy node_modules and package files from deps
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/package.json ./package.json
COPY --from=deps /app/yarn.lock ./yarn.lock
COPY --from=deps /app/.yarnrc.yml ./.yarnrc.yml
# Copy source files
COPY tsconfig.json ./
COPY src ./src
# Build TypeScript
RUN yarn build
# Production image
FROM base AS runner
ENV NODE_ENV=production
# Copy built application
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json
# Copy only production dependencies
COPY --from=builder /app/node_modules ./node_modules
# Expose port
EXPOSE 3000
# Start the application directly with node (no need for yarn in production)
CMD ["node", "dist/index.js"]