Skip to content

Commit b6dd289

Browse files
authored
Merge pull request #122 from CS3219-AY2425S1/cloud-fix
fix docker for session service
2 parents df48b96 + edb8935 commit b6dd289

File tree

1 file changed

+18
-39
lines changed

1 file changed

+18
-39
lines changed

session-service/Dockerfile

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,40 @@
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
55
RUN npm install -g pnpm
66

7+
# Set the working directory in the container
78
WORKDIR /app
89

9-
# Copy package files
10+
# Copy package.json and pnpm-lock.yaml
1011
COPY package.json ./
1112

12-
# Install all dependencies (including devDependencies)
1313
RUN pnpm install
1414

15-
# Copy source code and tsconfig
15+
# Development stage
16+
FROM base AS development
17+
1618
COPY src ./src
1719
COPY 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
2428
ENV NODE_ENV=production
2529
ENV 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

5835
COPY src ./src
5936
COPY tsconfig.json ./
6037

61-
CMD ["pnpm", "dev"]
38+
EXPOSE ${PORT}
39+
40+
CMD ["pnpm", "start"]

0 commit comments

Comments
 (0)