From c02408a459f27d38f07900b7b3fee0b0e1ed07d1 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Wed, 22 Nov 2023 05:05:58 +0000 Subject: [PATCH] Enhancement (development): Add `traefik` and mount `python` files in `bf2` container in `docker-compose.yml` With this, a `docker-compose up` run the full stack in development. --- docker-compose.yml | 34 ++++++++++++++++--- .../docker-compose.build.yml | 5 +++ .../full-bf2-stack-example/docker-compose.yml | 4 +-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a531762..ab14303 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,14 @@ version: '2.2' services: - # Battlefield 2 1.5 server with bf2stats 3.2.0 python scripts + # Battlefield 2 1.5 server with the bf2stats python scripts bf2: - image: startersclan/docker-bf2:v1.5.3153.0-bf2stats-3.2.0 + image: startersclan/docker-bf2:v1.5.3153.0 volumes: - ./config/bf2/mods/bf2/ai/aidefault-custom.ai:/server/bf2/mods/bf2/ai/aidefault.ai:ro # Customize bots - ./config/bf2/mods/bf2/settings/serversettings-custom.con:/server/bf2/mods/bf2/settings/serversettings.con:ro # Server config - ./config/bf2/mods/bf2/settings/maplist-custom-coop.con:/server/bf2/mods/bf2/settings/maplist.con:ro # Maplist (coop) + # - ./config/bf2/mods/bf2/settings/maplist-custom-cq.con:/server/bf2/mods/bf2/settings/maplist.con:ro # Maplist (cq) + - ./src/python:/server/bf2/python # Mount the python files - ./config/bf2/python/bf2/BF2StatisticsConfig-custom.py:/server/bf2/python/bf2/BF2StatisticsConfig.py:ro # bf2stats python config ports: - 16567:16567/udp @@ -43,7 +45,27 @@ services: - gpsp.gamespy.com - gpcm.gamespy.com - gamespy.com + + # The reverse proxy for our web containers + # This is needed only for the BF2 client BFHQ to work properly (i.e. access the ASP via http://bf2web.gamespy.com) + traefik: + image: traefik:v2.7 + volumes: + # Allow traefik to listen to the Docker events + - /var/run/docker.sock:/var/run/docker.sock:ro + ports: + - 80:80 + networks: + - traefik-public-network + - traefik-network restart: unless-stopped + command: + - --global.checknewversion=false + - --global.sendanonymoususage=false + # - --log.level=DEBUG + - --providers.docker=true + - --providers.docker.exposedbydefault=false + - --entrypoints.web.address=:80 init-container: image: alpine:latest @@ -81,7 +103,7 @@ services: - DB_USER=root - DB_PASS=ascent volumes: - - ./src:/src + - ./src/ASP:/src/ASP - backups-volume:/src/ASP/system/backups # This volume is effectively unused since ASP doesn't allow DB backups for a remote DB, but mount it anyway to avoid errors. - cache-volume:/src/ASP/system/cache - config-volume:/src/ASP/system/config # For a stateful config file @@ -91,6 +113,7 @@ services: - 8081:80 - 9000 networks: + traefik-network: bf2-network: aliases: - bf2web.gamespy.com # Spoof gamespy DNS for the BF2 server connected to this network @@ -127,8 +150,11 @@ services: - bf2-network networks: - bf2-network: gamespy-network: + bf2-network: + traefik-public-network: + traefik-network: + internal: true volumes: prmasterserver-volume: diff --git a/docs/full-bf2-stack-example/docker-compose.build.yml b/docs/full-bf2-stack-example/docker-compose.build.yml index a44bf95..a12e6ae 100644 --- a/docs/full-bf2-stack-example/docker-compose.build.yml +++ b/docs/full-bf2-stack-example/docker-compose.build.yml @@ -1,5 +1,10 @@ # This is a docker compose override file, for production builds with caching for CI environments services: + bf2: + image: startersclan/docker-bf2:v1.5.3153.0 + volumes: + - ../../src/python:/server/bf2/python # Mount the python files + asp: build: dockerfile: Dockerfile diff --git a/docs/full-bf2-stack-example/docker-compose.yml b/docs/full-bf2-stack-example/docker-compose.yml index 92f8b54..7f49730 100644 --- a/docs/full-bf2-stack-example/docker-compose.yml +++ b/docs/full-bf2-stack-example/docker-compose.yml @@ -148,8 +148,8 @@ services: - DB_HOST=db - DB_PORT=3306 - DB_NAME=bf2stats - - DB_USER=admin - - DB_PASS=admin + - DB_USER=root + - DB_PASS=ascent # ports: # - 8081:80 volumes: