|
| 1 | +# Kamal 2: deploys the gateway and its MariaDB to one Docker host. A push to main deploys it |
| 2 | +# from GitHub Actions (.github/workflows/deploy.yml). By hand: kamal setup, with the secrets |
| 3 | +# .kamal/secrets reads set in your shell. |
| 4 | +service: caesar4-online |
| 5 | +image: caesar4-online |
| 6 | + |
| 7 | +servers: |
| 8 | + web: |
| 9 | + hosts: |
| 10 | + - 167.235.138.73 |
| 11 | + options: |
| 12 | + # The game speaks raw MySQL, which kamal-proxy can't carry, so the container publishes |
| 13 | + # it. Only one container can hold the port: .kamal/hooks/pre-app-boot stops the running |
| 14 | + # gateway before each deploy boots the new one, so a deploy has a few seconds of downtime. |
| 15 | + publish: "3310:3306" |
| 16 | + |
| 17 | +# The website. c4.xetera.dev is a DNS-only record for this server, so kamal-proxy gets a |
| 18 | +# Let's Encrypt certificate for it. Other apps on the server keep their own hosts. |
| 19 | +proxy: |
| 20 | + host: c4.xetera.dev |
| 21 | + ssl: true |
| 22 | + app_port: 8080 |
| 23 | + healthcheck: |
| 24 | + path: / |
| 25 | + |
| 26 | +# Kamal runs a registry on your machine for the push and tunnels it to the server over SSH. |
| 27 | +registry: |
| 28 | + server: localhost:5555 |
| 29 | + |
| 30 | +builder: |
| 31 | + arch: amd64 |
| 32 | + # build the working directory (the default is a clean git clone) |
| 33 | + context: . |
| 34 | + |
| 35 | +env: |
| 36 | + clear: |
| 37 | + C4GW_LISTEN: ":3306" |
| 38 | + C4GW_WEB: ":8080" |
| 39 | + # debug endpoints, reachable only inside the kamal network |
| 40 | + C4GW_ADMIN: ":8081" |
| 41 | + # Written into players' NewConstants.txt. The game connects here on 3310 directly, so the |
| 42 | + # DNS record must stay DNS-only: Cloudflare's proxy only carries HTTP. |
| 43 | + C4GW_PUBLIC_SERVER: "c4.xetera.dev" |
| 44 | + C4GW_PUBLIC_PORT: "3310" |
| 45 | + C4GW_PUBLIC_URL: "https://c4.xetera.dev" |
| 46 | + C4GW_CAPTURE: /logs/capture.jsonl |
| 47 | + secret: |
| 48 | + - C4GW_DB_DSN |
| 49 | + - C4GW_WEB_SECRET |
| 50 | + |
| 51 | +volumes: |
| 52 | + - caesar4-online-logs:/logs |
| 53 | + |
| 54 | +accessories: |
| 55 | + db: |
| 56 | + image: mariadb:11.4 |
| 57 | + host: 167.235.138.73 |
| 58 | + cmd: --sql-mode=NO_ENGINE_SUBSTITUTION --character-set-server=latin1 |
| 59 | + env: |
| 60 | + clear: |
| 61 | + MARIADB_DATABASE: caesar4 |
| 62 | + secret: |
| 63 | + - MARIADB_ROOT_PASSWORD |
| 64 | + # read by 99-production.sh |
| 65 | + - C4GW_DB_PASSWORD |
| 66 | + # Run only when the data directory is empty. 0644 so the entrypoint sources the .sh |
| 67 | + # (it needs the entrypoint's docker_process_sql). init/02-leaderboards.sql is test data. |
| 68 | + files: |
| 69 | + - local: init/01-init.sql |
| 70 | + remote: /docker-entrypoint-initdb.d/01-init.sql |
| 71 | + mode: "0644" |
| 72 | + - local: config/mariadb/99-production.sh |
| 73 | + remote: /docker-entrypoint-initdb.d/99-production.sh |
| 74 | + mode: "0644" |
| 75 | + directories: |
| 76 | + - data:/var/lib/mysql |
0 commit comments