domain updates
CI / Lint, types, build, tests (push) Canceled after 0s
CI / Docker images build (push) Canceled after 0s

This commit is contained in:
olehhapuk
2026-12-03 12:27:03 +02:00
parent d47863f653
commit ea1f5f8b16
3 changed files with 42 additions and 24 deletions
+4 -2
View File
@@ -38,10 +38,10 @@ pnpm --filter api test:e2e # API end to end; needs the containers abo
## Deploying ## Deploying
`docker-compose.yml` runs the whole app on one server: Caddy in front (HTTPS with certificates it fetches itself), the web app, the API, PostgreSQL, Redis and LiveKit. `docker-compose.yml` runs the app on one server: the web app, the API, PostgreSQL, Redis and LiveKit. The way in is the server's own Caddy, a separate compose project that other projects share: it gets the HTTPS certificates and reaches this one over the external Docker network `web`.
1. Point three DNS names at the server: `example.com`, `api.example.com` and `livekit.example.com` (yours in place of `example.com`). The web app and the API must share a parent domain like this: the session cookie is only sent between pages of one site. 1. Point three DNS names at the server: `example.com`, `api.example.com` and `livekit.example.com` (yours in place of `example.com`). The web app and the API must share a parent domain like this: the session cookie is only sent between pages of one site.
2. Open the firewall for 80 and 443 (TCP), 443 (UDP), and for calls 7881 (TCP) and 7882 (UDP). 2. Let 80 and 443 (TCP) through to Caddy, and for calls 7881 (TCP) and 7882 (UDP) through to this server: on the firewall, and on the router if the server is behind one.
3. On the server, in a checkout of this repository: 3. On the server, in a checkout of this repository:
```bash ```bash
@@ -49,6 +49,8 @@ pnpm --filter api test:e2e # API end to end; needs the containers abo
docker compose up -d --build docker compose up -d --build
``` ```
4. Mount `deploy/Caddyfile` into the shared Caddy as one of its site files (`/etc/caddy/sites/electro4ort.caddy`) and restart it. The three names are written out in that file: change them there if `DOMAIN` is not `electro4ort.com.ua`.
To update: `git pull`, then `docker compose up -d --build` again. Migrations are applied by the `migrate` service before the new API starts. To update: `git pull`, then `docker compose up -d --build` again. Migrations are applied by the `migrate` service before the new API starts.
What to know before relying on it: What to know before relying on it:
+18 -13
View File
@@ -1,7 +1,12 @@
# The one door from the internet: gets and renews the TLS certificates, and # electro4ort's sites for the server's Caddy, which mounts this file among its
# hands each name to its service. DOMAIN comes from .env beside # sites (/etc/caddy/sites/electro4ort.caddy), gets the TLS certificates and
# docker-compose.yml; all three names must point at this server. # reaches the services over the shared "web" network.
(common) { #
# The names are written out because that Caddy doesn't read this project's
# .env; they must match DOMAIN there, and all three must point at the server.
# The snippet is named after the project because every site file shares one
# namespace.
(electro4ort) {
encode zstd gzip encode zstd gzip
header { header {
Strict-Transport-Security "max-age=31536000; includeSubDomains" Strict-Transport-Security "max-age=31536000; includeSubDomains"
@@ -10,8 +15,8 @@
} }
# The web app. # The web app.
{$DOMAIN} { electro4ort.com.ua {
import common import electro4ort
header { header {
X-Content-Type-Options nosniff X-Content-Type-Options nosniff
X-Frame-Options DENY X-Frame-Options DENY
@@ -22,18 +27,18 @@
# Built files carry a hash of their content in their name. # Built files carry a hash of their content in their name.
@built path /assets/* @built path /assets/*
header @built Cache-Control "public, max-age=31536000, immutable" header @built Cache-Control "public, max-age=31536000, immutable"
reverse_proxy web:3000 reverse_proxy electro4ort-web:3000
} }
# The API and its socket. It sets its own security headers. # The API and its socket. It sets its own security headers.
api.{$DOMAIN} { api.electro4ort.com.ua {
import common import electro4ort
reverse_proxy api:3000 reverse_proxy electro4ort-api:3000
} }
# Signalling for calls. The media itself doesn't pass through here: browsers # Signalling for calls. The media itself doesn't pass through here: browsers
# send it straight to LiveKit, on the ports docker-compose.yml opens. # send it straight to LiveKit, on the ports docker-compose.yml opens.
livekit.{$DOMAIN} { livekit.electro4ort.com.ua {
import common import electro4ort
reverse_proxy livekit:7880 reverse_proxy electro4ort-livekit:7880
} }
+20 -9
View File
@@ -2,6 +2,12 @@
# cp .env.example .env # then fill it in # cp .env.example .env # then fill it in
# docker compose up -d --build # docker compose up -d --build
# Development uses docker-compose.local.yml instead. See README.md. # Development uses docker-compose.local.yml instead. See README.md.
#
# The server's own Caddy (a separate compose project) is the way in: it loads
# deploy/Caddyfile and reaches these services over the shared "web" network.
# Every project on that network sees the others' service names, so the three
# services that join it carry the project's name: a plain "web" or "api" would
# answer for another project's lookups, and theirs for ours.
name: electro4ort name: electro4ort
x-api: &api x-api: &api
@@ -26,21 +32,21 @@ x-api: &api
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-} S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-}
# Browsers come in through Caddy; the API asks over the private network. # Browsers come in through Caddy; the API asks over the private network.
LIVEKIT_URL: wss://livekit.${DOMAIN} LIVEKIT_URL: wss://livekit.${DOMAIN}
LIVEKIT_INTERNAL_URL: http://livekit:7880 LIVEKIT_INTERNAL_URL: http://electro4ort-livekit:7880
LIVEKIT_API_KEY: ${LIVEKIT_API_KEY:?set LIVEKIT_API_KEY in .env} LIVEKIT_API_KEY: ${LIVEKIT_API_KEY:?set LIVEKIT_API_KEY in .env}
LIVEKIT_API_SECRET: ${LIVEKIT_API_SECRET:?set LIVEKIT_API_SECRET in .env} LIVEKIT_API_SECRET: ${LIVEKIT_API_SECRET:?set LIVEKIT_API_SECRET in .env}
services: services:
web: electro4ort-web:
build: build:
context: . context: .
target: web target: web
args: args:
VITE_API_URL: https://api.${DOMAIN} VITE_API_URL: https://api.${DOMAIN}
networks:
- web
image: electro4ort-web image: electro4ort-web
restart: unless-stopped restart: unless-stopped
networks:
- web # only the proxy talks to it
# Brings the database up to this version, then exits. The API waits for it. # Brings the database up to this version, then exits. The API waits for it.
migrate: migrate:
@@ -53,13 +59,14 @@ services:
postgres: postgres:
condition: service_healthy condition: service_healthy
api: electro4ort-api:
<<: *api <<: *api
volumes: volumes:
# Uploaded files, while STORAGE_DRIVER is "local". # Uploaded files, while STORAGE_DRIVER is "local".
- files:/data/files - files:/data/files
networks: networks:
- web - default # reaches postgres, redis and livekit
- web # shared with the proxy
depends_on: depends_on:
migrate: migrate:
condition: service_completed_successfully condition: service_completed_successfully
@@ -94,8 +101,9 @@ services:
retries: 10 retries: 10
# Voice and video. Signalling comes through Caddy; the media goes straight # Voice and video. Signalling comes through Caddy; the media goes straight
# between browsers and these two ports, which the firewall must let in. # between browsers and these two ports, which the router and the firewall
livekit: # must let in.
electro4ort-livekit:
image: livekit/livekit-server:v1.13 image: livekit/livekit-server:v1.13
restart: unless-stopped restart: unless-stopped
environment: environment:
@@ -110,10 +118,13 @@ services:
webhook: webhook:
api_key: ${LIVEKIT_API_KEY} api_key: ${LIVEKIT_API_KEY}
urls: urls:
- http://api:3000/livekit/webhook - http://electro4ort-api:3000/livekit/webhook
ports: ports:
- "7881:7881" - "7881:7881"
- "7882:7882/udp" - "7882:7882/udp"
networks:
- default # reaches the API, for the webhook
- web # shared with the proxy
volumes: volumes:
postgres-data: postgres-data: