Files
openwaf/docker-compose.yml
T
Pavlo Ratushnyi ea68b550e2 Two CI jobs sharing one compose project: one job's teardown was the other's connection refused
The full local runner pass (act 0.2.89, catthehacker/ubuntu:act-latest) on this
tree went 4 jobs succeeded, 1 failed: the console job died 33 s in, at the
seeding curl of scripts/console-smoke.sh, with curl exit 7 — nothing listening on
127.0.0.1:8080 any more.

Not a product failure and not flakiness. The image job and the console job each
run `docker compose up -d` and each tear the stack down on exit, and both take the
project name from the repository directory and the host port from a literal 8080
in docker-compose.yml. On any machine where two jobs share one docker daemon — a
self-hosted runner, or act — they are the same stack, so the image job's
`compose down` removes the containers the console job is seeding into. Run alone,
the same console job passes (act -j console: 1 job succeeded, 53 assertions). On
GitHub's hosted runners each job gets its own machine, which is exactly why this
has never been seen there and why "the workflow has never run on GitHub" is still
a gap this repository carries rather than a solved problem.

Fix: the published port is ${EDGE_PORT:-8080}, and each job names its own compose
project (openwafci-image on 8080, openwafci-console on 8090). Separate projects
means separate containers, separate volumes and separate ports, so neither job can
see the other's stack. scripts/ci-linux-rehearsal.sh passes COMPOSE_PROJECT_NAME
and EDGE_PORT through to the seeding container so an operator can isolate a
rehearsal the same way.

Measured after: the same full act pass is 5 jobs succeeded, 0 failed — lint,
source (128/128, 117/117, smoke 25/0), image (261 MB, compose smoke 53/0),
console (53 assertions / 0 failed, screenshot artifact), freshness. Locally:
compose gate 53/0 with the default project and port unchanged, and the console
gate 53/0 driven through the CI configuration (COMPOSE_PROJECT_NAME=openwafci-console,
EDGE_PORT=8090).
2026-10-02 07:21:13 +02:00

55 lines
2.4 KiB
YAML

# The edge in front of an application it knows nothing about. That is the
# point: openwaf decides on what the upstream answered, so the upstream can be
# anything. `upstream` here is nginx purely so the compose file demonstrates a
# ban with nothing but curl.
#
# Before starting: set OPENWAF_ADMIN_TOKEN. Without it the admin API is closed
# (404), which is the safe default, not a misconfiguration.
services:
edge:
build:
context: .
dockerfile: Dockerfile
ports:
# The host port is a variable, not a literal. Two CI jobs that each bring
# up this file against one docker daemon otherwise fight over the same
# published port and the same project's containers — one job's teardown is
# another job's connection refused. Measured with a local Actions runner
# (act 0.2.89), where the image job and the console job share a daemon: the
# console gate died at its seeding curl with exit 7 while the image job's
# compose smoke was tearing the same project down. On GitHub's hosted
# runners each job gets its own machine, which is exactly why this never
# showed up there.
- "${EDGE_PORT:-8080}:8080"
environment:
OPENWAF_ADMIN_TOKEN: ${OPENWAF_ADMIN_TOKEN:?set OPENWAF_ADMIN_TOKEN before starting}
OpenWaf__Policy__Mode: Enforce
OpenWaf__Policy__StreakThreshold: "10"
OpenWaf__Policy__StreakWindow: "00:05:00"
OpenWaf__Policy__BanDuration: "01:00:00"
# Only turn this on when the edge sits behind a proxy you control and
# whose address you have allowlisted. If X-Forwarded-For is
# attacker-controlled, every request gets a fresh source key and no
# streak ever matures.
OpenWaf__Policy__TrustProxyHeaders: "false"
ReverseProxy__Clusters__upstream__Destinations__upstream1__Address: "http://upstream:80/"
volumes:
- openwaf-data:/app/data
- openwaf-geoip:/app/geoip
depends_on:
- upstream
upstream:
image: nginx:alpine
restart: unless-stopped
# deploy/upstream.conf is nginx's own default plus one path that answers 502,
# so scripts/compose-smoke.sh can prove "server errors alert and never ban"
# against the deployed image instead of only against a fake upstream in a
# test. Remove this mount and the demo still works; that assertion fails.
volumes:
- ./deploy/upstream.conf:/etc/nginx/conf.d/default.conf:ro
volumes:
openwaf-data:
openwaf-geoip: