Skip to content

Commit 25c1831

Browse files
committed
fix #96
1 parent db6ad30 commit 25c1831

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

.env.sample

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
NODE_PORT=5000
77
NODE_ENV=production
88
NODE_COMMAND=npm start
9+
# Set to <your-domain>:port
10+
# Local testing example: localhost:5000
11+
# Production server example: <domain>:443
12+
NODE_SERVER_ADDR=localhost:5000
913

10-
# PostgreSQL
14+
# PostgreSQL (don't change these unless you know what you're doing)
1115
PG_USER=cah
1216
PG_HOST=postgres
1317
PG_PORT=5432

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ services:
1515
environment:
1616
NODE_PORT: ${NODE_PORT}
1717
NODE_ENV: ${NODE_ENV}
18+
NODE_SERVER_ADDR: ${NODE_SERVER_ADDR}
1819
PG_USER: ${PG_USER}
1920
PG_HOST: ${PG_HOST}
2021
PG_PORT: ${PG_PORT}

scripts/setup.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ docker exec $(docker ps | grep ${NAME}_postgres | rev | cut -d ' ' -f 1 | rev) "
2424

2525
# Restart the containers
2626
docker-compose down
27-
docker-compose up -d
27+
# docker-compose up -d
28+
# PORT=$(cat .env | grep NODE_PORT | cut -b 11-15)
29+
# echo "Done. Running on port $PORT"
2830

29-
PORT=$(cat .env | grep NODE_PORT | cut -b 11-15)
30-
echo "Done. Running on port $PORT"
31+
echo "Done"

server/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const server = app.listen(port, () => {
2121
});
2222

2323
const io = socketio(server, {
24-
origins: env.NODE_ENV === 'production' ? ['cah.ninja:443'] : ['*:*']
24+
origins: env.NODE_ENV === 'production' && typeof env.NODE_SERVER_ADDR === 'string' ? [env.NODE_SERVER_ADDR] : ['*:*']
2525
});
2626

2727
const games: Games = {};

setup.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
1. Make sure that `docker`, `docker-compose` and `node` is installed.
55
2. Clone this repo. `git clone [email protected]:olback/cah cah && cd cah`.
66
3. Run `scripts/setup.sh`.
7-
4. That's it. You can now access the game on [localhost:5000](http://localhost:5000).
7+
4. Look over and edit `.env` to your liking.
8+
5. Run `docker-compose up` to start the server. (add `-d` to run in the background)
9+
6. That's it. You can now access the game on [localhost:5000](http://localhost:5000).
810

911
## Development:
1012
1. Make sure that `docker`, `docker-compose` and `node` is installed.

0 commit comments

Comments
 (0)