diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81bc18b..e2f6480 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,15 +182,29 @@ jobs: - name: Test de fumée par le port web run: bash tools/docker-smoke.sh http://localhost:8080 + # Un second front qui joint l'API par le nom de son conteneur (API_UPSTREAM), comme sur Umbrel. + - name: Front avec une autre adresse d'API + run: | + WEB_IMAGE="$(docker compose config --images | grep parenthese-web)" + API_CONTAINER="$(docker compose ps -q api | xargs docker inspect -f '{{.Name}}' | tr -d /)" + docker run -d --name web-upstream --network parenthese_default -p 8081:80 \ + -e API_UPSTREAM="$API_CONTAINER:4000" "$WEB_IMAGE" + sleep 3 + docker exec web-upstream grep -q "http://$API_CONTAINER:4000" /etc/nginx/conf.d/default.conf + bash tools/docker-smoke.sh http://localhost:8081 + - name: État et journaux en cas d'échec if: failure() run: | docker compose ps -a docker compose logs --no-color --timestamps + docker logs web-upstream || true - name: Arrêt et suppression des volumes if: always() - run: docker compose down -v --remove-orphans + run: | + docker rm -f web-upstream || true + docker compose down -v --remove-orphans docker-aio: name: Docker tout-en-un (Unraid, NAS) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0fd1ba..8ab5f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Notable changes to Parenthèse. Dates are in YYYY-MM-DD format. ### Self-hosting - Single-container image `ghcr.io/iliesallali/parenthese-aio` (PostgreSQL, API and front end), for Unraid and NAS systems that install one container per app. It needs no configuration: the database, its password and the session key are created in `/data` on first start. Tested in CI by a fresh start, a restart and the smoke test. +- The `parenthese-web` image reads the API address from `API_UPSTREAM` (`api:4000` by default, unchanged for existing installs). Set it when the name `api` is already taken on the Docker network, for example on Umbrel where apps share one network. ## 1.0.2 (2026-10-09) diff --git a/Dockerfile.web b/Dockerfile.web index 64c0dde..146c5fc 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -19,7 +19,14 @@ RUN npm run build FROM nginx:1.30-alpine -COPY deploy/nginx.docker.conf /etc/nginx/conf.d/default.conf +# Adresse de l'API lue au démarrage du conteneur, `api:4000` par défaut (le service de docker-compose.yml). +# À changer quand le nom `api` est déjà pris sur le réseau, comme sur Umbrel où les apps partagent un réseau. +# L'image nginx passe les fichiers de /etc/nginx/templates par envsubst et n'y remplace que les variables +# d'environnement définies : $host, $uri et les autres variables de nginx restent telles quelles. +ENV API_UPSTREAM=api:4000 +COPY deploy/nginx.docker.conf /etc/nginx/templates/default.conf.template +RUN sed -i 's|http://api:4000|http://${API_UPSTREAM}|g' /etc/nginx/templates/default.conf.template \ + && ! grep -q 'api:4000' /etc/nginx/templates/default.conf.template COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 diff --git a/README.fr.md b/README.fr.md index 9b9d9b8..910b661 100644 --- a/README.fr.md +++ b/README.fr.md @@ -53,7 +53,7 @@ docker compose up -d Le premier démarrage télécharge les images (ou les construit depuis les sources si elles sont introuvables), applique les migrations de la base, puis sert l'application sur [http://localhost](http://localhost). Créez votre compte depuis l'écran d'accueil : le premier compte est un compte comme les autres, il n'y a pas d'administrateur global. -Trois conteneurs tournent : `db` (PostgreSQL 16), `api` (l'API Node) et `web` (nginx qui sert le front et relaie l'API). Seul `web` est exposé, sur le port choisi par `WEB_PORT` (80 par défaut). Si ce port est déjà pris, changez `WEB_PORT` dans `.env` et adaptez `CORS_ORIGIN` en conséquence. +Trois conteneurs tournent : `db` (PostgreSQL 16), `api` (l'API Node) et `web` (nginx qui sert le front et relaie l'API). Seul `web` est exposé, sur le port choisi par `WEB_PORT` (80 par défaut). Si ce port est déjà pris, changez `WEB_PORT` dans `.env` et adaptez `CORS_ORIGIN` en conséquence. Le conteneur `web` trouve l'API à `api:4000` ; si vous lancez les images sous d'autres noms de service, donnez `API_UPSTREAM` à `web` (par exemple `API_UPSTREAM=monapi:4000`). Pour ouvrir l'instance à la famille depuis Internet, placez un reverse proxy HTTPS devant le port `web` (Caddy, Traefik, nginx) et mettez l'adresse publique dans `CORS_ORIGIN`, par exemple `https://arbre.votre-domaine.fr`. diff --git a/README.md b/README.md index 73aedee..d9b947d 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ docker compose up -d The first start downloads the images (or builds them from the source when they can't be pulled), applies the database migrations, then serves the app on [http://localhost](http://localhost). Create your account from the home screen. The first account is an account like any other, there is no global administrator. -Three containers run: `db` (PostgreSQL 16), `api` (the Node API) and `web` (nginx, which serves the front end and proxies the API). Only `web` is exposed, on the port set by `WEB_PORT` (80 by default). If that port is taken, change `WEB_PORT` in `.env` and update `CORS_ORIGIN` to match. +Three containers run: `db` (PostgreSQL 16), `api` (the Node API) and `web` (nginx, which serves the front end and proxies the API). Only `web` is exposed, on the port set by `WEB_PORT` (80 by default). If that port is taken, change `WEB_PORT` in `.env` and update `CORS_ORIGIN` to match. The `web` container finds the API at `api:4000`; if you run the images under other service names, set `API_UPSTREAM` on `web` (for example `API_UPSTREAM=myapi:4000`). To open the instance to your family over the Internet, put an HTTPS reverse proxy in front of the `web` port (Caddy, Traefik, nginx) and set the public address in `CORS_ORIGIN`, for example `https://tree.your-domain.com`.