File tree Expand file tree Collapse file tree 1 file changed +40
-15
lines changed
Expand file tree Collapse file tree 1 file changed +40
-15
lines changed Original file line number Diff line number Diff line change 1- # Base stage for both dev and prod
2- FROM node:18-alpine AS base
1+ # Build stage
2+ FROM node:18-alpine AS builder
33
44# Install pnpm globally
55RUN npm install -g pnpm
66
7- # Set the working directory in the container
87WORKDIR /app
98
10- # Copy package.json and pnpm-lock.yaml
9+ # Copy package files
1110COPY package.json ./
1211
12+ # Install all dependencies (including devDependencies)
1313RUN pnpm install
1414
15- # Development stage
16- FROM base AS development
17-
15+ # Copy source code and tsconfig
1816COPY src ./src
1917COPY tsconfig.json ./
2018
21- # Note: Don't expose ports here, Compose will handle that for us
22-
23- CMD ["pnpm" , "dev" ]
24-
19+ # Build the TypeScript code
20+ RUN pnpm build
2521
2622# Production stage
27- FROM base AS production
23+ FROM node:18-alpine AS production
2824ENV NODE_ENV=production
2925ENV PORT=4444
3026
31- COPY src ./src
32- COPY tsconfig.json ./
27+ # Install pnpm globally
28+ RUN npm install -g pnpm
29+
30+ WORKDIR /app
31+
32+ # Copy package files
33+ COPY package.json ./
34+
35+ # Install only production dependencies
36+ RUN pnpm install --prod
37+
38+ # Copy built files from builder stage
39+ COPY --from=builder /app/dist ./dist
3340
3441EXPOSE ${PORT}
3542
36- CMD ["pnpm" , "start" ]
43+ # Run the compiled JavaScript
44+ CMD ["node" , "dist/server.js" ]
45+
46+ # Development stage
47+ FROM node:18-alpine AS development
48+
49+ # Install pnpm globally
50+ RUN npm install -g pnpm
51+
52+ WORKDIR /app
53+
54+ COPY package.json ./
55+
56+ RUN pnpm install
57+
58+ COPY src ./src
59+ COPY tsconfig.json ./
60+
61+ CMD ["pnpm" , "dev" ]
You can’t perform that action at this time.
0 commit comments