Skip to content

Commit

Permalink
fi dockerfile and urls
Browse files Browse the repository at this point in the history
  • Loading branch information
keshav2010 committed Mar 7, 2024
1 parent ef897a3 commit fa00b82
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ COUNTDOWN_SPAWN_SELECTION=10000
COUNTDOWN_DEFAULT=15000
MAX_SESSION_PER_WORKER=10
MINIMUM_PLAYERS_PER_SESSION=2
COLYSEUS_SERVER_URL=localhost:2567
COLYSEUS_SERVER_URL=localhost
COLYSEUS_SERVER_PORT=3000
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM node:18
WORKDIR /rtsApp
COPY package*.json ./
RUN npm install -g tsx
RUN npm install
COPY . .
EXPOSE 3000
EXPOSE 3007
EXPOSE 2567
CMD ["npm", "run", "deploy"]
3 changes: 2 additions & 1 deletion gameserver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import path from "path";
import fs from "fs";
import dotenv from 'dotenv';
dotenv.config();
const PORT = process.env.COLYSEUS_SERVER_PORT;
const app = express();
app.use(express.json());
app.use(cors());
Expand Down Expand Up @@ -64,4 +65,4 @@ const gameServer = new Server({
// presence: new RedisPresence(),
});
gameServer.define("session_room", SessionRoom);
gameServer.listen(2567);
gameServer.listen(Number(PORT));
4 changes: 2 additions & 2 deletions public/NetworkManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Colyseus from "colyseus.js";
import Phaser from "phaser";
import { SessionState } from "../gameserver/schema/SessionState";
const URL = `${process.env.COLYSEUS_SERVER_URL}`;
const URL = `${process.env.COLYSEUS_SERVER_URL}:${process.env.COLYSEUS_SERVER_PORT}`;
export type RoomEventHandlerCallbackType = (
type: "onStateChange" | "onMessage" | "onLeave" | "onError",
data: any
Expand All @@ -18,7 +18,7 @@ export class NetworkManager {
phaserGame: Phaser.Game,
phaserRegistry: Phaser.Data.DataManager
) {
this.client = new Colyseus.Client(`ws://${URL}` || `ws://localhost:2567`);
this.client = new Colyseus.Client(`ws://${URL}`);
this.room = null;

this.game = phaserGame;
Expand Down
2 changes: 1 addition & 1 deletion public/scenes/MenuScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import CONSTANT from "../constant";
import { BaseScene } from "./BaseScene";
import { NetworkManager } from "../NetworkManager";
import { addBackgroundImage } from "../helpers/addBackgroundImage";
const URL = `${process.env.COLYSEUS_SERVER_URL}`;
const URL = `${process.env.COLYSEUS_SERVER_URL}:${process.env.COLYSEUS_SERVER_PORT}`;
export class MenuScene extends BaseScene {
constructor() {
super(CONSTANT.SCENES.MENU);
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
new HtmlWebpackPlugin({ template: './public/index.html' }),
new webpack.DefinePlugin({
'process.env.COLYSEUS_SERVER_URL': JSON.stringify(process.env.COLYSEUS_SERVER_URL),
'process.env.COLYSEUS_SERVER_PORT': JSON.stringify(process.env.COLYSEUS_SERVER_PORT),
})
],
mode: "development"
Expand Down

0 comments on commit fa00b82

Please sign in to comment.