
# Install the application on your server

In about an hour, you put Planning Équipes online on your own server: the application and its PostgreSQL database, behind your reverse proxy, with a check that confirms everything answers. You need a Linux server with Docker Compose, a domain name and an SMTP relay. Still undecided? [Host it yourself or have it hosted](/heberger/) sums up what it takes, and what can be taken care of for you.

## Before you start

| You need | Why |
| --- | --- |
| A domain name and a TLS certificate | `PUBLIC_URL` builds the espace links printed on PDFs: they must stay reachable after the event as well as during it |
| An authenticated SMTP relay | Access codes, espace links, individual schedules, swap notifications: everything goes by e-mail ([getting them delivered](courriels.md)) |
| A reverse proxy | It terminates TLS and must be the only path to the application: [hardening the deployment](securite.md) |
| The organiser's legal information | Publisher, host, contact, legal basis, retention period ([fill them in](mentions-legales.md)) |
| 2.5 GB of memory for the stack | 2 GB for the application, 512 MB for PostgreSQL ([why so much](calcul-du-planning.md#la-mémoire-de-lapplication)) |
| A single copy of the application | The lock that keeps two publications from running at once, the rate limits and the solve queue live in memory: do not run it as several copies behind a load balancer |

## What you receive

| Item | Content |
| --- | --- |
| The image | `ghcr.io/sylvainmetayer/planning-equipes`, published with no authentication, one tag per version (`1.2.0`, `1.2`), plus `main` (acceptance, rebuilt on every merge) and `latest`. It bundles the application, the interface and the `pg_dump` client, listens on port 8080 and runs as user 1000. SBOM and signature: [version numbers](versioning.md) |
| `docker-compose.prod.yml` | The production stack: the application and PostgreSQL 19, nothing else |
| `.env.prod.example` | The environment file to copy to `.env.prod`, every variable commented |
| `docker-compose.yml` | A **development** stack, not to be deployed: it publishes PostgreSQL on the host and adds pgAdmin and an SMTP sink |
| `scripts/verifier-deploiement.sh` | The end-of-deployment check |
| `scripts/restaurer.sh` | The guided restore ([the procedure](sauvegarde-et-restauration.md)) |

Take these files from the [project repository](repo:docker-compose.prod.yml), at the tag of the version you are going to deploy.

## Start the stack

1. Write the environment. Copy the template (`cp .env.prod.example .env.prod`), then fill in at least the seven mandatory variables and the legal notices. Never commit this file: it carries secrets.

   The seven mandatory variables are `APP_VERSION`, `DB_PASSWORD`, `ADMIN_PASSWORD`, `SESSION_ENCRYPTION_KEY`, `PUBLIC_URL`, `MAIL_HOST` and `MAIL_FROM`. The compose file refuses to start if one is missing, and the application refuses the two example passwords and, on a public instance (`PUBLIC_INSTANCE=true`), five empty legal notices; the full list of its refusals opens [the variable inventory](variables-environnement.md#obligatoires-en-production).

2. Choose a named version: `APP_VERSION=1.2.0`, never `main` or `latest`. An incident report must be able to name the deployment: "1.2.0" does, "Tuesday's image" does not ([what a number promises](versioning.md)).

3. Prepare the backup directory, which must belong to user 1000, otherwise Docker creates it as `root` and the first backup fails:

   ```bash
   mkdir -p backup && sudo chown 1000:1000 backup
   ```

4. Start. On first start, the application applies its migrations by itself before answering.

   ```bash
   docker compose -f docker-compose.prod.yml --env-file .env.prod up -d
   ```

5. Check, from the directory of `.env.prod` (bash, `curl` and `jq`; no host access or credentials, a deployment CI can call it as is):

   ```bash
   scripts/verifier-deploiement.sh https://<domain>          # version read from APP_VERSION
   scripts/verifier-deploiement.sh https://<domain> 1.2.0    # or given explicitly
   ```

   The script chains the checks below and stops at the first failure with a non-zero exit code:

   | Check | What is verified |
   | --- | --- |
   | Availability | `/q/health/ready` answers `UP`: database reachable, no pending or failed migration. The wait is bounded (120 s, `--attente`) to let a first start's migrations through |
   | Version | the version exposed by `/api/config` is the expected one (`--version-libre` while `APP_VERSION=main`) |
   | Brand and notices | `/api/branding` and `/api/mentions-legales` answer |
   | Mandatory notices | none of the five keys required from `LEGAL_MENTIONS` is empty; skipped if the instance declares itself a demo (`LEGAL_DEMO_INSTANCE=true`), or with `--instance-demo` |

   The application footer and the *Debug* page (*Administer*, Ctrl+K or `/debug`, *Solve* tab) show the deployed version: the `vX.Y.Z` tag for a release image, the commit for an acceptance image. This is what a vulnerability report must cite ([report a vulnerability](repo:.github/SECURITY.md)).

6. Open the administration with the `admin` account and the `ADMIN_PASSWORD` password. If you connect an identity provider, first create your named account ([OIDC](oidc.md), [local accounts](comptes-locaux.md)). Then set the instance settings and load or enter the first edition: [Prepare your first edition](../regles/preparer-edition.md) takes over.

## What the production stack does

- The application is published only on the loopback (`127.0.0.1:8080`): your reverse proxy terminates TLS and is the only way in. Its supervision port (9000, metrics) is never published.
- PostgreSQL has no published port; its data lives in a named volume.
- The nightly backup writes to `./backup` ([back up and restore](sauvegarde-et-restauration.md)).
- Container logs rotate (5 files of 20 MB per service, `LOG_MAX_SIZE` and `LOG_MAX_FILE`) so a full disk does not make the backup fail ([the logs](surveillance.md#lire-et-limiter-les-journaux)).
- The `app` health check queries `/q/health/ready`: `docker compose ps` shows it `healthy` once the migrations have run (up to 180 s of grace).
