From b07a0a7c28ebc7fbc617d9fd371a1dc3387b6bdb Mon Sep 17 00:00:00 2001 From: Adrian Priestley Date: Wed, 1 Jan 2025 16:14:35 -0330 Subject: [PATCH] feat(deploy): Introduce Docker Compose configuration for multi-world deployment - Separate web service into two containers, one for main process and one for gunicorn - Update container configurations for improved security and maintainability - Remove unused volumes and network configurations --- deploy/docker-compose.yml | 54 +++++++++++++++++++++++++++----------- deploy/example_config.yaml | 2 +- deploy/example_nginx.conf | 2 +- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 2dc7c7621f..902229415f 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -1,36 +1,58 @@ services: - web: + multiworld: + # Build only once. Web service uses the same image build build: context: .. - entrypoint: > - sh -c "python WebHost.py --config_override selflaunch.yaml & gunicorn -c gunicorn.conf.py" + # Name image for use in web service + image: archipelago-base + # Use locally-built image + pull_policy: never + # Launch main process without website hosting (config override) + entrypoint: python WebHost.py --config_override selflaunch.yaml volumes: - - static_volume:/app/WebHostLib - - output_volume:/app/output - - sprites_alttpr_volume:/app/sprites/alttpr - - sprites_custom_volume:/app/sprites/custom + # Mount application volume + - app_volume:/app + + # Mount configs - ./example_config.yaml:/app/config.yaml - ./example_selflaunch.yaml:/app/selflaunch.yaml + + # Expose on host network for access to dynamically mapped ports + network_mode: host + + web: + # Use image build by multiworld service + image: archipelago-base + # Use locally-built image + pull_policy: never + # Launch gunicorn targeting WebHost application + entrypoint: gunicorn -c gunicorn.conf.py + volumes: + # Mount application volume + - app_volume:/app + + # Mount configs + - ./example_config.yaml:/app/config.yaml - ./example_gunicorn.conf.py:/app/gunicorn.conf.py environment: - #Bind gunicorn to 0.0.0.0:8000 + # Bind gunicorn on 8000 - PORT=8000 - network_mode: host nginx: image: nginx:stable-alpine volumes: - - static_volume:/app/WebHostLib + # Mount application volume + - app_volume:/app + + # Mount config - ./example_nginx.conf:/etc/nginx/nginx.conf ports: + # Nginx listening internally on port 80 -- mapped to 8080 on host - 8080:80 depends_on: - web - extra_hosts: - - "host.docker.internal:host-gateway" volumes: - static_volume: - output_volume: - sprites_alttpr_volume: - sprites_custom_volume: + # Share application directory amongst multiworld and web services + # (for access to log files and the like), and nginx (for static files) + app_volume: diff --git a/deploy/example_config.yaml b/deploy/example_config.yaml index ef6301a6e8..758ac960e3 100644 --- a/deploy/example_config.yaml +++ b/deploy/example_config.yaml @@ -5,5 +5,5 @@ SELFHOST: false SELFLAUNCH: false # Host Address. This is the address encoded into the patch that will be used for client auto-connect. -# Set as your local IP to serve over LAN. +# Set as your local IP (192.168.x.x) to serve over LAN. HOST_ADDRESS: localhost diff --git a/deploy/example_nginx.conf b/deploy/example_nginx.conf index 2d4d8a6cf4..b0c0e8e5a0 100644 --- a/deploy/example_nginx.conf +++ b/deploy/example_nginx.conf @@ -28,7 +28,7 @@ http { # server unix:/tmp/gunicorn.sock fail_timeout=0; # for a TCP configuration - server host.docker.internal:8000 fail_timeout=0; + server web:8000 fail_timeout=0; } server {