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
This commit is contained in:
Adrian Priestley
2025-01-01 16:14:35 -03:30
committed by Adrian Priestley
parent d80d297d97
commit b07a0a7c28
3 changed files with 40 additions and 18 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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 {