File tree Expand file tree Collapse file tree 4 files changed +13
-9
lines changed
Expand file tree Collapse file tree 4 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,9 @@ RUN npm install -g pnpm
88WORKDIR /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
1314RUN pnpm install
1415
1516# Development stage
@@ -28,13 +29,13 @@ FROM base AS production
2829ENV NODE_ENV=production
2930ENV 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
3533COPY src ./src
3634COPY tsconfig.json ./
3735
36+ # Build the TypeScript code
37+ RUN pnpm build
38+
3839EXPOSE ${PORT}
3940
4041CMD ["pnpm" , "start" ]
Original file line number Diff line number Diff line change 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"
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}
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ function onListening() {
4646httpServer . on ( "error" , onError ) ;
4747httpServer . 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
5151httpServer . listen ( PORT , ( ) => {
5252 console . log ( `Server is running on ${ PORT } ` ) ;
You can’t perform that action at this time.
0 commit comments