Skip to content

Commit

Permalink
fix docker file for session service
Browse files Browse the repository at this point in the history
  • Loading branch information
simbayippy committed Nov 3, 2024
1 parent 7d84102 commit 385957f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
11 changes: 6 additions & 5 deletions session-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ RUN npm install -g pnpm
WORKDIR /app

# Copy package.json and pnpm-lock.yaml
COPY package.json ./
COPY package.json pnpm-lock.yaml ./

# Install all dependencies
RUN pnpm install

# Development stage
Expand All @@ -28,13 +29,13 @@ FROM base AS production
ENV NODE_ENV=production
ENV PORT=4444

# Install typescript for production build
RUN npm install -g typescript
RUN pnpm add -D typescript

# Copy source files
COPY src ./src
COPY tsconfig.json ./

# Build the TypeScript code
RUN pnpm build

EXPOSE ${PORT}

CMD ["pnpm", "start"]
5 changes: 3 additions & 2 deletions session-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "nodemon src/server.ts",
"start": "tsc && node dist/server.js",
"build": "tsc",
"build": "tsc && echo \"Build completed successfully.\"",
"format": "prettier --write \"src/**/*.ts\"",
"pre-commit": "pnpm format && git add -u",
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -25,6 +25,7 @@
"y-websocket": "^2.0.4"
},
"devDependencies": {
"@types/ws": "^8.5.12"
"@types/ws": "^8.5.12",
"typescript": "^5.6.3"
}
}
4 changes: 3 additions & 1 deletion session-service/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion session-service/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function onListening() {
httpServer.on("error", onError);
httpServer.on("listening", onListening);

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

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

0 comments on commit 385957f

Please sign in to comment.