Skip to content

Commit ef17c77

Browse files
committed
Change dockerfile and fly.toml
1 parent e0a8c68 commit ef17c77

5 files changed

Lines changed: 13 additions & 10 deletions

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Use an official Node runtime as the base image
22
FROM node:24-slim
3+
ENV GAME_ENV=Dev
34

45
# 1) Installer Git pour que build-prod (webpack) puisse faire git rev-parse
56
RUN apt-get update \
@@ -14,7 +15,7 @@ RUN npm ci
1415

1516
# 3) Copier le code et builder le front
1617
COPY . .
17-
RUN npm run build-prod
18+
RUN npm run build-dev
1819

1920
# 4) Ouvrir le port exposé par Fly
2021
EXPOSE 3000

fly.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ primary_region = "cdg"
77

88
[env]
99
PORT = "3000"
10-
NODE_ENV = "production"
10+
NODE_ENV = "development"
1111

1212
[[services]]
1313
internal_port = 3000

src/server/Master.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ app.post(
172172

173173
try {
174174
const response = await fetch(
175-
`http://0.0.0.0:${config.workerPort(gameID)}/api/kick_player/${gameID}/${clientID}`,
175+
`http://localhost:${config.workerPort(gameID)}/api/kick_player/${gameID}/${clientID}`,
176176
{
177177
method: "POST",
178178
headers: {
@@ -200,7 +200,7 @@ async function fetchLobbies(): Promise<number> {
200200
const controller = new AbortController();
201201
setTimeout(() => controller.abort(), 5000); // 5 second timeout
202202
const port = config.workerPort(gameID);
203-
const promise = fetch(`http://0.0.0.0:${port}/api/game/${gameID}`, {
203+
const promise = fetch(`http://localhost:${port}/api/game/${gameID}`, {
204204
headers: { [config.adminHeader()]: config.adminToken() },
205205
signal: controller.signal,
206206
})
@@ -275,7 +275,7 @@ async function schedulePublicGame(playlist: MapPlaylist) {
275275
// Send request to the worker to start the game
276276
try {
277277
const response = await fetch(
278-
`http://0.0.0.0:${config.workerPort(gameID)}/api/create_game/${gameID}`,
278+
`http://localhost:${config.workerPort(gameID)}/api/create_game/${gameID}`,
279279
{
280280
method: "POST",
281281
headers: {

src/server/Server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { getServerConfigFromServer } from "../core/configuration/ConfigLoader";
55
import { Cloudflare, TunnelConfig } from "./Cloudflare";
66
import { startMaster } from "./Master";
77
import { startWorker } from "./Worker";
8-
9-
const config = getServerConfigFromServer();
10-
118
dotenv.config();
9+
const config = getServerConfigFromServer();
10+
const isFly = Boolean(process.env.FLY_ALLOC_ID);
11+
const test = false;
1212

1313
// Main entry point of the application
1414
async function main() {
1515
// Check if this is the primary (master) process
16-
if (cluster.isPrimary) {
16+
if (test && cluster.isPrimary) {
1717
if (config.env() !== GameEnv.Dev) {
1818
await setupTunnels();
1919
}

src/server/Worker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,10 @@ export function startWorker() {
380380
});
381381

382382
// The load balancer will handle routing to this server based on path
383-
const PORT = config.workerPortByIndex(workerId);
383+
//const PORT = config.workerPortByIndex(workerId);
384+
const PORT = parseInt(process.env.PORT || "") || 3000;
384385
const HOST = "0.0.0.0";
386+
console.log("PORT + HOST", PORT, HOST);
385387
server.listen(PORT, HOST, () => {
386388
log.info(`running on http://${HOST}:${PORT}`);
387389
log.info(`Handling requests with path prefix /w${workerId}/`);

0 commit comments

Comments
 (0)