yavsc/docker-compose.yaml
Paul Schneider 4fc0ddb6d4 docker: use Dockerfile multi-stage targets in compose
After the multi-stage refactor of Dockerfile, the three separate
Dockerfile.runtime* files are obsolete: every runtime image is
now a stage of the main Dockerfile.

Delete Dockerfile.runtime, Dockerfile.runtime.blogs,
Dockerfile.runtime.api, and rewrite docker-compose.yaml so that
each service points at the corresponding target via build.target:

  web    -> web-runtime    (port 5000)
  api    -> api-runtime    (port 5002)
  blogs  -> blogs-runtime  (port 5004)

The build tag is passed through build.args.BUILD_ENV_TAG, which
the Dockerfile declares as an ARG with the same default as
before.

The shared multi-stage Dockerfile is now the single source of
truth for both the build-env image (used by the APK workflow)
and the three runtime images.
2026-06-27 16:32:48 +01:00

109 lines
3 KiB
YAML

services:
# ---------- PostgreSQL ----------
db:
image: postgres:16
env_file: .env
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- yavsc-internal
healthcheck:
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
# ---------- Yavsc.Org (front web) ----------
# Construit depuis le stage `web-runtime` du Dockerfile multi-stage.
# ASPNETCORE_URLS=http://+:5000 (HTTP seul en dev). Pour activer
# HTTPS en prod, décommenter le port 5001, monter /etc/letsencrypt
# en volume, et configurer Kestrel:Certificates dans
# appsettings-org.json (cf. CONTRIBUTING.md).
web:
build:
context: .
dockerfile: Dockerfile
target: web-runtime
args:
BUILD_ENV_TAG: debian12-dotnet10-android36-v1
secrets:
- yavsc_appsettings
env_file: .env
ports:
- "5000:5000"
# - "5001:5001" # HTTPS : décommenter avec le volume letsencrypt
depends_on:
db:
condition: service_healthy
networks:
- yavsc-internal
- yavsc-public
# volumes:
# - /etc/letsencrypt:/etc/letsencrypt:ro
# ---------- Yavsc.Api (API REST principale) ----------
api:
build:
context: .
dockerfile: Dockerfile
target: api-runtime
args:
BUILD_ENV_TAG: debian12-dotnet10-android36-v1
secrets:
- yavsc_appsettings
env_file: .env
ports:
- "5002:5002"
# - "5003:5003" # HTTPS : décommenter avec le volume letsencrypt
depends_on:
db:
condition: service_healthy
networks:
- yavsc-internal
- yavsc-public
# volumes:
# - /etc/letsencrypt:/etc/letsencrypt:ro
# ---------- Yavsc.Blogs (backend API headless des blogs) ----------
# Déployé sur un sous-domaine dédié en production (ex: blogs.yavsc.example).
# cf. doc/architecture/decoupage-organisation.md.
blogs:
build:
context: .
dockerfile: Dockerfile
target: blogs-runtime
args:
BUILD_ENV_TAG: debian12-dotnet10-android36-v1
secrets:
- yavsc_appsettings
env_file: .env
ports:
- "5004:5004"
# - "5005:5005" # HTTPS : décommenter avec le volume letsencrypt
depends_on:
db:
condition: service_healthy
networks:
- yavsc-internal
- yavsc-public
# volumes:
# - /etc/letsencrypt:/etc/letsencrypt:ro
volumes:
pgdata:
networks:
# Réseau interne : seuls les services Yavsc et la base s'y voient.
yavsc-internal:
internal: false
# Réseau public : exposé à l'hôte via les ports mappés.
yavsc-public:
secrets:
# appsettings-org.json vit à src/Yavsc.Org/appsettings-org.json
# (non commité). BuildKit le monte dans
# /run/secrets/yavsc_appsettings pendant le build de chaque image
# runtime via le Dockerfile multi-stage.
yavsc_appsettings:
file: ./src/Yavsc.Org/appsettings-org.json