Skip to content

Commit 1c43969

Browse files
authored
Merge pull request #128 from CS3219-AY2425S1/cloud-fix
fix docker file for session service
2 parents 1649d72 + 385957f commit 1c43969

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

session-service/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ RUN npm install -g pnpm
88
WORKDIR /app
99

1010
# Copy package.json and pnpm-lock.yaml
11-
COPY package.json ./
11+
COPY package.json pnpm-lock.yaml ./
1212

13+
# Install all dependencies
1314
RUN pnpm install
1415

1516
# Development stage
@@ -28,13 +29,13 @@ FROM base AS production
2829
ENV NODE_ENV=production
2930
ENV PORT=4444
3031

31-
# Install typescript for production build
32-
RUN npm install -g typescript
33-
RUN pnpm add -D typescript
34-
32+
# Copy source files
3533
COPY src ./src
3634
COPY tsconfig.json ./
3735

36+
# Build the TypeScript code
37+
RUN pnpm build
38+
3839
EXPOSE ${PORT}
3940

4041
CMD ["pnpm", "start"]

session-service/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"dev": "nodemon src/server.ts",
88
"start": "tsc && node dist/server.js",
9-
"build": "tsc",
9+
"build": "tsc && echo \"Build completed successfully.\"",
1010
"format": "prettier --write \"src/**/*.ts\"",
1111
"pre-commit": "pnpm format && git add -u",
1212
"test": "echo \"Error: no test specified\" && exit 1"
@@ -25,6 +25,7 @@
2525
"y-websocket": "^2.0.4"
2626
},
2727
"devDependencies": {
28-
"@types/ws": "^8.5.12"
28+
"@types/ws": "^8.5.12",
29+
"typescript": "^5.6.3"
2930
}
3031
}

session-service/pnpm-lock.yaml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

session-service/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function onListening() {
4646
httpServer.on("error", onError);
4747
httpServer.on("listening", onListening);
4848

49-
const PORT = process.env.PORT; // or any port you prefer
49+
const PORT = process.env.PORT || 4444; // fallback to 4444 if PORT env var is not set
5050

5151
httpServer.listen(PORT, () => {
5252
console.log(`Server is running on ${PORT}`);

0 commit comments

Comments
 (0)