feat(tests): add PostgreSQL readiness check in test setup
Integration Tests / integration-test (push) Failing after 1m10s
Integration Tests / integration-test (push) Failing after 1m10s
This commit is contained in:
@@ -80,6 +80,16 @@ test-setup: build ## Start test environment (docker-compose/podman-compose)
|
|||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
@$(COMPOSE_CMD) -f tests/docker-compose.yml up -d
|
@$(COMPOSE_CMD) -f tests/docker-compose.yml up -d
|
||||||
|
@echo "Waiting for PostgreSQL to be ready..."
|
||||||
|
@for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do \
|
||||||
|
if $(COMPOSE_CMD) -f tests/docker-compose.yml exec -T postgres pg_isready -U user > /dev/null 2>&1; then \
|
||||||
|
echo "PostgreSQL is ready"; exit 0; \
|
||||||
|
fi; \
|
||||||
|
sleep 2; \
|
||||||
|
done; \
|
||||||
|
echo "ERROR: PostgreSQL did not become ready in time"; \
|
||||||
|
$(COMPOSE_CMD) -f tests/docker-compose.yml logs postgres; \
|
||||||
|
exit 1
|
||||||
|
|
||||||
test-teardown: ## Stop test environment (docker-compose/podman-compose)
|
test-teardown: ## Stop test environment (docker-compose/podman-compose)
|
||||||
@echo "Stopping test environment (using $(COMPOSE_CMD))..."
|
@echo "Stopping test environment (using $(COMPOSE_CMD))..."
|
||||||
|
|||||||
@@ -264,6 +264,23 @@ See the [examples](./examples/) directory for complete examples.
|
|||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
|
### Prebuilt image
|
||||||
|
|
||||||
|
Published to `git.warky.dev/wdevs/pgsql-broker` on every `v*.*.*` tag (`.github/workflows/docker-release.yml`), tagged with the version and `latest`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull git.warky.dev/wdevs/pgsql-broker:latest
|
||||||
|
docker run --rm -v $(pwd)/broker.yaml:/etc/pgsql-broker/broker.yaml:ro git.warky.dev/wdevs/pgsql-broker:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Config must be mounted at `/etc/pgsql-broker/broker.yaml` — no config is baked into the image.
|
||||||
|
|
||||||
|
### Building the image locally
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make docker-build # builds pgsql-broker:<VERSION> and pgsql-broker:latest via Dockerfile
|
||||||
|
```
|
||||||
|
|
||||||
### Production: `Dockerfile` + `docker-compose.yml`
|
### Production: `Dockerfile` + `docker-compose.yml`
|
||||||
|
|
||||||
Multi-stage build (`golang:1.26-alpine` → `alpine:3.22`, static binary, non-root user). The compose stack runs Postgres, a one-shot `migrate` service (`install --with-roles`), then the `broker` service connecting as `broker_runtime`.
|
Multi-stage build (`golang:1.26-alpine` → `alpine:3.22`, static binary, non-root user). The compose stack runs Postgres, a one-shot `migrate` service (`install --with-roles`), then the `broker` service connecting as `broker_runtime`.
|
||||||
|
|||||||
Reference in New Issue
Block a user