# Deployment
The server runs the images published by CI; nothing is built on the server.
```mermaid
flowchart LR
PR[Pull request] -->|lint, types, tests| Main[merge to main]
Main -->|CI| Images[ghcr.io/rewake-fr/api
ghcr.io/rewake-fr/api-ocr
ghcr.io/rewake-fr/api-docs
tags latest and sha-…]
Images -->|scripts/deploy/deploy.sh| Server[Server: docker compose]
```
Every push to `main` builds the images (`api`, `api-ocr`, `api-docs`), tagged `latest` and
`sha-`, and publishes a GitHub release with its notes. **Merging does not deploy.**
## Deploy
On the server, in the API directory:
```bash
scripts/deploy/deploy.sh # the latest image
scripts/deploy/deploy.sh sha-abc1234 # a precise build: to pin a version or roll back
```
The script pulls the images, restarts the services and waits for `/health/` to answer.
Once per server, log in to the registry (the images are private): `docker login ghcr.io` with a
GitHub token that has `read:packages`.
## Before deploying
- New settings: add them to the server's `.env` (see the release notes and
[Configuration](configuration.md)).
- A change in the job names or the schedule: jobs already queued under an old name fail once;
deploy when nothing important is running.
## Documentation site
The `docs` service serves this documentation (nginx, image `api-docs`) on
`172.17.0.1:${DOCS_PORT}` (3003 by default); Traefik publishes it on
. `scripts/deploy/deploy.sh` deploys it with the API; to deploy only
the documentation:
```bash
scripts/deploy/docs.sh # or: make docs-deploy
scripts/deploy/docs.sh sha-abc1234
```
Set up once:
1. DNS: an `A` record `docs.api.rewake.fr` pointing to the server.
2. Traefik: a router to the service. With Traefik's file provider (dynamic configuration):
```yaml
http:
routers:
api-docs:
rule: Host(`docs.api.rewake.fr`)
entryPoints: [websecure]
service: api-docs
tls:
certResolver: mytlschallenge
services:
api-docs:
loadBalancer:
servers:
- url: http://172.17.0.1:3003
```
If Traefik reads Docker labels instead, declare the same router as `traefik.http.routers.*`
labels on the `docs` service and attach it to Traefik's network. Use the entry point and
certificate resolver names of the existing routers.
While writing documentation, `make docs` builds it and opens it, and `make docs-live` rebuilds
it on every change.