k-l-lambda commited on
Commit
172c3de
·
1 Parent(s): 006b994

Fix: Docker-specific entry point with correct paths

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -3
Dockerfile CHANGED
@@ -2,7 +2,7 @@ FROM node:20-slim
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
5
- # Build timestamp: 2026-01-13T04:10
6
 
7
  WORKDIR /app
8
 
@@ -23,11 +23,30 @@ COPY trigo-web/app/dist/ ./app/dist/
23
  COPY trigo-web/backend/.env ./backend/.env
24
  COPY trigo-web/backend/.env.local ./backend/.env.local
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ENV PORT=7860
27
  ENV HOST=0.0.0.0
28
  ENV NODE_ENV=production
29
 
30
  EXPOSE 7860
31
 
32
- # Run TypeScript directly with tsx
33
- CMD ["npx", "tsx", "backend/src/server.ts"]
 
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
5
+ # Build timestamp: 2026-01-13T04:20
6
 
7
  WORKDIR /app
8
 
 
23
  COPY trigo-web/backend/.env ./backend/.env
24
  COPY trigo-web/backend/.env.local ./backend/.env.local
25
 
26
+ # Create a Docker-specific entry point that sets correct paths
27
+ RUN echo 'import express from "express"; \
28
+ import { createServer } from "http"; \
29
+ import { Server } from "socket.io"; \
30
+ import cors from "cors"; \
31
+ import { GameManager } from "./backend/src/services/gameManager"; \
32
+ import { setupSocketHandlers } from "./backend/src/sockets/gameSocket"; \
33
+ const app = express(); \
34
+ const httpServer = createServer(app); \
35
+ const io = new Server(httpServer, { cors: { origin: true, methods: ["GET", "POST"], credentials: true } }); \
36
+ const gameManager = new GameManager(); \
37
+ const PORT = parseInt(process.env.PORT || "7860", 10); \
38
+ app.use(cors()); \
39
+ app.use(express.json()); \
40
+ app.use(express.static("app/dist")); \
41
+ app.get("/health", (req, res) => res.json({status: "ok", timestamp: new Date().toISOString()})); \
42
+ app.get("*", (req, res, next) => { if (req.path.startsWith("/health") || req.path.startsWith("/socket.io")) return next(); res.sendFile("app/dist/index.html", {root: "/app"}); }); \
43
+ io.on("connection", (socket) => { console.log("Client connected:", socket.id); setupSocketHandlers(io, socket, gameManager); socket.on("disconnect", () => console.log("Client disconnected:", socket.id)); }); \
44
+ httpServer.listen(PORT, "0.0.0.0", () => console.log("Server running on port " + PORT));' > docker-entry.ts
45
+
46
  ENV PORT=7860
47
  ENV HOST=0.0.0.0
48
  ENV NODE_ENV=production
49
 
50
  EXPOSE 7860
51
 
52
+ CMD ["npx", "tsx", "docker-entry.ts"]