File tree Expand file tree Collapse file tree 1 file changed +18
-39
lines changed
Expand file tree Collapse file tree 1 file changed +18
-39
lines changed Original file line number Diff line number Diff line change 1- # Build stage
2- FROM node:18-alpine AS builder
1+ # Base stage for both dev and prod
2+ FROM node:18-alpine AS base
33
44# Install pnpm globally
55RUN npm install -g pnpm
66
7+ # Set the working directory in the container
78WORKDIR /app
89
9- # Copy package files
10+ # Copy package.json and pnpm-lock.yaml
1011COPY package.json ./
1112
12- # Install all dependencies (including devDependencies)
1313RUN pnpm install
1414
15- # Copy source code and tsconfig
15+ # Development stage
16+ FROM base AS development
17+
1618COPY src ./src
1719COPY tsconfig.json ./
1820
19- # Build the TypeScript code
20- RUN pnpm build
21+ # Note: Don't expose ports here, Compose will handle that for us
22+
23+ CMD ["pnpm" , "dev" ]
24+
2125
2226# Production stage
23- FROM node:18-alpine AS production
27+ FROM base AS production
2428ENV NODE_ENV=production
2529ENV PORT=4444
2630
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
40-
41- EXPOSE ${PORT}
42-
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
31+ # Install typescript for production build
32+ RUN npm install -g typescript
33+ RUN pnpm add -D typescript
5734
5835COPY src ./src
5936COPY tsconfig.json ./
6037
61- CMD ["pnpm" , "dev" ]
38+ EXPOSE ${PORT}
39+
40+ CMD ["pnpm" , "start" ]
You can’t perform that action at this time.
0 commit comments