mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 07:47:50 +01:00
add second web server, work around docker compose bug
This commit is contained in:
3
.env
Normal file
3
.env
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CONTAINER_PORT_1=5000
|
||||||
|
CONTAINER_PORT_2=5001
|
||||||
|
WEB_PORT=5000
|
||||||
@@ -9,7 +9,7 @@ RUN npm install
|
|||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
ENV NODE_ENV development
|
ENV NODE_ENV development
|
||||||
ENV REDIS_HOST redis
|
ENV REDIS_URL_DEV "redis://redis:6379"
|
||||||
ENV REDIS_PORT 6379
|
ENV WEB_PORT 5000
|
||||||
|
|
||||||
CMD [ "npm", "run", "start:dev:docker" ]
|
CMD [ "npm", "run", "start:dev:docker" ]
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ Instances of this app are part of a stateless architecture that scales up and do
|
|||||||
|
|
||||||
### Running Locally
|
### Running Locally
|
||||||
|
|
||||||
|
#### Using Docker
|
||||||
|
|
||||||
|
If you have Docker Desktop installed, running `docker compose up` will spin up, by default, two
|
||||||
|
web servers and one redis server for them to connect to. The app can then be accessed at `localhost:5000`
|
||||||
|
or `localhost:5001`. Otherwise, read below for setup that does not use Docker.
|
||||||
|
|
||||||
|
#### Without Docker
|
||||||
|
|
||||||
The entrypoint for the application is `index.js` at the root.
|
The entrypoint for the application is `index.js` at the root.
|
||||||
|
|
||||||
Before starting the Node.js server, you'll need a Redis server running locally on the default port. This is what's used
|
Before starting the Node.js server, you'll need a Redis server running locally on the default port. This is what's used
|
||||||
|
|||||||
@@ -7,4 +7,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
dockerfile: Dockerfile.dev
|
dockerfile: Dockerfile.dev
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "${CONTAINER_PORT_1}:${WEB_PORT}"
|
||||||
|
web-2:
|
||||||
|
build:
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
ports:
|
||||||
|
- "${CONTAINER_PORT_2}:${WEB_PORT}"
|
||||||
|
|||||||
12
package.json
12
package.json
@@ -7,12 +7,12 @@
|
|||||||
"bundle": "webpack --config client/webpack/webpack-prod.config.js",
|
"bundle": "webpack --config client/webpack/webpack-prod.config.js",
|
||||||
"gcp-build": "webpack --config client/webpack/webpack-prod.config.js",
|
"gcp-build": "webpack --config client/webpack/webpack-prod.config.js",
|
||||||
"build:dev": "webpack --watch --config client/webpack/webpack-dev.config.js --mode=development",
|
"build:dev": "webpack --watch --config client/webpack/webpack-dev.config.js --mode=development",
|
||||||
"start:dev:docker": "webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js",
|
"start:dev:docker": "webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js -- loglevel=debug",
|
||||||
"start:dev": "REDIS_HOST=localhost REDIS_PORT=6379 NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && nodemon index.js",
|
"start:dev": "NODE_ENV=development REDIS_URL_DEV=redis://127.0.0.1:6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && nodemon index.js",
|
||||||
"start:dev:no-hot-reload": "REDIS_HOST=localhost REDIS_PORT=6379 NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js",
|
"start:dev:no-hot-reload": "NODE_ENV=development REDIS_URL_DEV=redis://127.0.0.1:6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js",
|
||||||
"start:dev:windows": "SET NODE_ENV=development REDIS_HOST=localhost REDIS_PORT=6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && nodemon index.js -- loglevel=debug",
|
"start:dev:windows": "SET NODE_ENV=development & SET REDIS_URL_DEV=redis://127.0.0.1:6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && nodemon index.js -- loglevel=debug",
|
||||||
"start:dev:windows:no-hot-reload:debug": "SET NODE_ENV=development REDIS_HOST=localhost REDIS_PORT=6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && node --inspect index.js",
|
"start:dev:windows:no-hot-reload:debug": "SET NODE_ENV=development & SET REDIS_URL_DEV=redis://127.0.0.1:6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && node --inspect index.js",
|
||||||
"start:dev:windows:no-hot-reload": "SET NODE_ENV=development REDIS_HOST=localhost REDIS_PORT=6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js",
|
"start:dev:windows:no-hot-reload": "SET NODE_ENV=development & SET REDIS_URL_DEV=redis://127.0.0.1:6379 && webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js",
|
||||||
"start": "NODE_ENV=production node index.js -- loglevel=debug",
|
"start": "NODE_ENV=production node index.js -- loglevel=debug",
|
||||||
"start:windows": "SET NODE_ENV=production && node index.js -- loglevel=debug port=8080",
|
"start:windows": "SET NODE_ENV=production && node index.js -- loglevel=debug port=8080",
|
||||||
"test": "jasmine && karma start --single-run --browsers ChromeHeadless karma.conf.js",
|
"test": "jasmine && karma start --single-run --browsers ChromeHeadless karma.conf.js",
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const ServerBootstrapper = {
|
|||||||
try {
|
try {
|
||||||
const args = Array.from(process.argv.map((arg) => arg.trim().toLowerCase()));
|
const args = Array.from(process.argv.map((arg) => arg.trim().toLowerCase()));
|
||||||
const useHttps = args.includes('protocol=https');
|
const useHttps = args.includes('protocol=https');
|
||||||
const port = process.env.PORT || args
|
const port = process.env.WEB_PORT || args
|
||||||
.filter((arg) => {
|
.filter((arg) => {
|
||||||
return /port=\d+/.test(arg);
|
return /port=\d+/.test(arg);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ class EventManager {
|
|||||||
createRedisPublisher = async () => {
|
createRedisPublisher = async () => {
|
||||||
this.publisher = process.env.NODE_ENV.trim() === 'development'
|
this.publisher = process.env.NODE_ENV.trim() === 'development'
|
||||||
? redis.createClient({
|
? redis.createClient({
|
||||||
socket: {
|
url: process.env.REDIS_URL_DEV
|
||||||
host: process.env.REDIS_HOST, port: process.env.REDIS_PORT
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
: redis.createClient({
|
: redis.createClient({
|
||||||
url: process.env.REDIS_URL
|
url: process.env.REDIS_URL
|
||||||
|
|||||||
Reference in New Issue
Block a user