|
| 1 | +### ### Compose |
| 2 | +### |
| 3 | +### Validates the local dev compose stack — config-lint in every operational |
| 4 | +### mode, plus a smoke-test that the default-mode bundled traefik actually |
| 5 | +### serves nginx over HTTPS with the self-signed dev cert. |
| 6 | +### |
| 7 | +### Scoped to changes that can break the dev stack: compose files, |
| 8 | +### bundled traefik config, the dev-cert script, and `.env` (whose |
| 9 | +### COMPOSE_PROFILES default decides which services run). |
| 10 | + |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + paths: |
| 14 | + - "docker-compose.yml" |
| 15 | + - "docker-compose.shared-frontend.yml" |
| 16 | + - "docker-compose.postgres.yml" |
| 17 | + - "traefik/**" |
| 18 | + - "scripts/dev-cert.sh" |
| 19 | + - ".env" |
| 20 | + - ".github/workflows/docker-compose.yaml" |
| 21 | + |
| 22 | +name: Docker Compose |
| 23 | + |
| 24 | +jobs: |
| 25 | + lint: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + name: Lint compose (all modes) |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v6 |
| 31 | + |
| 32 | + - name: Default mode (traefik profile) |
| 33 | + env: |
| 34 | + COMPOSE_PROFILES: traefik |
| 35 | + run: docker compose config --quiet |
| 36 | + |
| 37 | + - name: Default + dev tooling profile |
| 38 | + env: |
| 39 | + COMPOSE_PROFILES: traefik,dev |
| 40 | + run: docker compose config --quiet |
| 41 | + |
| 42 | + - name: Postgres portability overlay |
| 43 | + env: |
| 44 | + COMPOSE_PROFILES: traefik |
| 45 | + COMPOSE_FILE: docker-compose.yml:docker-compose.postgres.yml |
| 46 | + run: docker compose config --quiet |
| 47 | + |
| 48 | + - name: Itkdev opt-in (shared-frontend overlay, bundled traefik off) |
| 49 | + env: |
| 50 | + COMPOSE_PROFILES: "" |
| 51 | + COMPOSE_FILE: docker-compose.yml:docker-compose.shared-frontend.yml |
| 52 | + COMPOSE_FRONTEND_NETWORK: frontend |
| 53 | + run: | |
| 54 | + docker network create frontend |
| 55 | + docker compose config --quiet |
| 56 | +
|
| 57 | + smoke-default: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + name: Smoke test (bundled traefik) |
| 60 | + env: |
| 61 | + COMPOSE_PROFILES: traefik |
| 62 | + steps: |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v6 |
| 65 | + |
| 66 | + - name: Generate dev cert |
| 67 | + run: bash scripts/dev-cert.sh |
| 68 | + |
| 69 | + # Limited service set — mariadb + phpfpm + nginx + traefik + redis. |
| 70 | + # node + playwright are intentionally excluded; they're heavy pulls |
| 71 | + # and not needed to validate the routing path. |
| 72 | + - name: Bring up core services |
| 73 | + run: docker compose up --detach --wait mariadb redis nginx traefik |
| 74 | + |
| 75 | + - name: Probe nginx health via bundled traefik (HTTPS) |
| 76 | + # `--resolve` aligns URL host, TLS SNI, and HTTP Host header — all |
| 77 | + # `display.local.itkdev.dk` (matches the router rule labelled on |
| 78 | + # nginx). Mismatched SNI vs Host makes traefik v3 return 421 |
| 79 | + # (misdirected request) even when `sniStrict` is off. |
| 80 | + # `-k` skips cert verification — the dev cert is self-signed. |
| 81 | + run: | |
| 82 | + status=$(curl -kfsS -o /dev/null -w '%{http_code}' \ |
| 83 | + --resolve display.local.itkdev.dk:443:127.0.0.1 \ |
| 84 | + https://display.local.itkdev.dk/health) |
| 85 | + echo "HTTP status: $status" |
| 86 | + test "$status" = "200" |
| 87 | +
|
| 88 | + - name: Dump logs on failure |
| 89 | + if: failure() |
| 90 | + run: docker compose logs --no-color |
| 91 | + |
| 92 | + - name: Tear down |
| 93 | + if: always() |
| 94 | + run: docker compose down --volumes --remove-orphans |
| 95 | + |
| 96 | + smoke-itkdev: |
| 97 | + runs-on: ubuntu-latest |
| 98 | + name: Smoke test (itkdev opt-in) |
| 99 | + steps: |
| 100 | + - name: Checkout |
| 101 | + uses: actions/checkout@v6 |
| 102 | + |
| 103 | + - name: Pre-create external frontend network |
| 104 | + run: docker network create frontend |
| 105 | + |
| 106 | + # Mirror how an itkdev dev actually opts out of the bundled traefik: |
| 107 | + # an `.env.local` that overrides the committed `.env` defaults. The |
| 108 | + # dev-cert.sh script re-sources `.env` (with `.env.local` last so it |
| 109 | + # wins), so this is the only way to make the override stick. |
| 110 | + - name: Write itkdev .env.local override |
| 111 | + run: | |
| 112 | + cat > .env.local <<'EOF' |
| 113 | + COMPOSE_PROFILES= |
| 114 | + COMPOSE_FILE=docker-compose.yml:docker-compose.shared-frontend.yml |
| 115 | + COMPOSE_FRONTEND_NETWORK=frontend |
| 116 | + EOF |
| 117 | +
|
| 118 | + - name: Dev cert script no-ops when bundled traefik is off |
| 119 | + run: | |
| 120 | + out=$(bash scripts/dev-cert.sh) |
| 121 | + echo "$out" |
| 122 | + echo "$out" | grep -q "skipping dev cert" |
| 123 | + test ! -f traefik/ssl/dev.crt |
| 124 | +
|
| 125 | + - name: Bring up core services (no bundled traefik) |
| 126 | + run: docker compose up --detach --wait mariadb redis nginx |
| 127 | + |
| 128 | + - name: Dump logs on failure |
| 129 | + if: failure() |
| 130 | + run: docker compose logs --no-color |
| 131 | + |
| 132 | + - name: Tear down |
| 133 | + if: always() |
| 134 | + run: docker compose down --volumes --remove-orphans |
0 commit comments