Use APP_PORT consistently
This commit is contained in:
@@ -8,6 +8,6 @@ pnpm-debug.log*
|
||||
*.log
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
Dockerfile
|
||||
compose.yaml
|
||||
|
||||
|
||||
2
.env.example
Normal file
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
APP_PORT=8787
|
||||
|
||||
@@ -3,15 +3,14 @@ FROM node:24-alpine
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV APP_PORT=8787
|
||||
|
||||
COPY package.json ./
|
||||
COPY index.html styles.css game.js server.js ./
|
||||
|
||||
EXPOSE 3000
|
||||
EXPOSE 8787
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD node -e "fetch('http://127.0.0.1:' + (process.env.PORT || 3000) + '/healthz').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"
|
||||
CMD node -e "fetch('http://127.0.0.1:' + (process.env.APP_PORT || 8787) + '/healthz').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ A notepad-playable browser game that combines Tic Tac Toe's line-making goal wit
|
||||
|
||||
## Run With Docker Compose
|
||||
|
||||
Optional: copy `.env.example` to `.env` and change `APP_PORT`.
|
||||
|
||||
```powershell
|
||||
docker compose up --build
|
||||
```
|
||||
@@ -37,12 +39,12 @@ docker compose down
|
||||
npm start
|
||||
```
|
||||
|
||||
Then open `http://localhost:3000` in two browser windows.
|
||||
Then open `http://localhost:8787` in two browser windows.
|
||||
|
||||
Set a different port with:
|
||||
|
||||
```powershell
|
||||
$env:PORT=4000; npm start
|
||||
$env:APP_PORT=9090; npm start
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
@@ -6,6 +6,6 @@ services:
|
||||
container_name: tictactics
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
PORT: 3000
|
||||
APP_PORT: ${APP_PORT:-8787}
|
||||
ports:
|
||||
- "${APP_PORT:-8787}:3000"
|
||||
- "${APP_PORT:-8787}:${APP_PORT:-8787}"
|
||||
|
||||
@@ -3,7 +3,7 @@ const fs = require("fs");
|
||||
const http = require("http");
|
||||
const path = require("path");
|
||||
|
||||
const port = Number(process.env.PORT || 3000);
|
||||
const appPort = Number(process.env.APP_PORT || 8787);
|
||||
const root = __dirname;
|
||||
const clients = new Map();
|
||||
const rooms = new Map();
|
||||
@@ -286,6 +286,6 @@ function encodeFrame(message) {
|
||||
return Buffer.concat([header, payload]);
|
||||
}
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log(`Tictactics multiplayer server running at http://localhost:${port}`);
|
||||
server.listen(appPort, () => {
|
||||
console.log(`Tictactics multiplayer server running at http://localhost:${appPort}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user