docker. minor updates that don't really need any message.

This commit is contained in:
Elizabeth Hunt 2023-09-02 17:46:03 -06:00
parent 29ba1c29d7
commit 19bea535ec
Signed by: simponic
GPG Key ID: 52B3774857EB24B1
9 changed files with 79 additions and 6 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
**/.git
**/.DS_Store
**/node_modules

20
Dockerfile.client Normal file
View File

@ -0,0 +1,20 @@
# build
FROM node:18-alpine as build
COPY . /app
WORKDIR /app/client
RUN npm install --save-dev
RUN npm run build
# serve via nginx
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/
COPY --from=build /app/client/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

9
Dockerfile.server Normal file
View File

@ -0,0 +1,9 @@
FROM oven/bun
COPY . /app
WORKDIR /app/server
RUN bun install
CMD bun run /app/server/src/main.ts

View File

@ -10,7 +10,7 @@
<body> <body>
<noscript> <noscript>
<div style="text-align: center"> <div style="text-align: center">
<h1>yeah, unfortunately you need javascript :)</h1> <h1>yeah, unfortunately you need javascript :3</h1>
</div> </div>
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>

25
docker-compose.yml Normal file
View File

@ -0,0 +1,25 @@
version: '3'
services:
client:
build:
dockerfile: Dockerfile.client
networks:
- webapp
ports:
- 1337:80
restart: always
container_name: jumpstorm-client
hostname: client
server:
build:
dockerfile: Dockerfile.server
networks:
- webapp
restart: always
container_name: jumpstorm-server
networks:
webapp:
driver: bridge

View File

@ -92,7 +92,7 @@ export class Player extends Entity {
const distance = Math.sqrt( const distance = Math.sqrt(
Math.pow(center.y - myCenter.y, 2) + Math.pow(center.x - myCenter.x, 2) Math.pow(center.y - myCenter.y, 2) + Math.pow(center.x - myCenter.x, 2)
); );
const clientServerPredictionCenterThreshold = 30; const clientServerPredictionCenterThreshold = 20;
if (distance < clientServerPredictionCenterThreshold) center = myCenter; if (distance < clientServerPredictionCenterThreshold) center = myCenter;
[ [

View File

@ -67,9 +67,6 @@ export class Grid implements RefreshingCollisionFinderBehavior {
const yBoxes = Math.ceil( const yBoxes = Math.ceil(
this.gridDimension.height / this.cellDimension.height this.gridDimension.height / this.cellDimension.height
); );
const xBoxes = Math.ceil(
this.gridDimension.width / this.cellDimension.width
);
const translated: Coord2D = { const translated: Coord2D = {
y: center.y - this.topLeft.y, y: center.y - this.topLeft.y,

View File

@ -32,7 +32,7 @@ export class NetworkUpdate extends System {
this.messageProcessor = messageProcessor; this.messageProcessor = messageProcessor;
this.entityUpdateInfo = new Map(); this.entityUpdateInfo = new Map();
this.nextPublishInterval = 0; this.nextPublishInterval = this.getNextUpdateInterval();
} }
public update(dt: number, game: Game) { public update(dt: number, game: Game) {

19
nginx.conf Normal file
View File

@ -0,0 +1,19 @@
server {
listen 80;
location / {
root /usr/share/nginx/html/;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://server:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}