Wire the artifact storage foundation to HTTP.
- PUT /tasks/{id}/artifacts/{filename}: a worker streams a partial result;
the coordinator verifies lease ownership (foreign worker → 409), streams
the bytes to blob storage while hashing, and records the metadata. An
orphaned blob from a failed metadata insert is cleaned up.
- GET /artifacts/{id}/download: streams an artifact back with its content
type, length, and checksum.
- Ownership is read with a new non-locking TaskRepository.Get, so no row lock
is held across a long upload. Identity travels in X-Worker-ID / X-Task-Attempt
headers per the contract; upload/download bypass the short request timeout.
- docker-compose mounts ./data for durable artifact storage; smoke and
requests.http exercise an upload → foreign-409 → download round-trip.
77 lines
2.5 KiB
YAML
77 lines
2.5 KiB
YAML
name: scimesh
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-scimesh}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-scimesh}
|
|
POSTGRES_DB: ${POSTGRES_DB:-scimesh}
|
|
ports:
|
|
- "${POSTGRES_PORT:-5432}:5432"
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
# Everything else waits on this, so the check must prove the server
|
|
# accepts queries — not merely that the port is open.
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-scimesh} -d ${POSTGRES_DB:-scimesh}"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 5s
|
|
|
|
# One-shot: applies migrations, then exits. Schema changes stay an explicit
|
|
# deployment step — the coordinator binary never migrates on startup.
|
|
migrate:
|
|
image: migrate/migrate:v4.17.1
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./migrations:/migrations:ro
|
|
command:
|
|
- -path=/migrations
|
|
- -database=postgres://${POSTGRES_USER:-scimesh}:${POSTGRES_PASSWORD:-scimesh}@postgres:5432/${POSTGRES_DB:-scimesh}?sslmode=disable
|
|
- up
|
|
restart: on-failure
|
|
|
|
coordinator:
|
|
build:
|
|
context: .
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
# Start only once the schema exists, otherwise the first query fails.
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
environment:
|
|
COORDINATOR_ADDR: ":8080"
|
|
# Host is the service name: compose resolves it on the project network.
|
|
DATABASE_URL: postgres://${POSTGRES_USER:-scimesh}:${POSTGRES_PASSWORD:-scimesh}@postgres:5432/${POSTGRES_DB:-scimesh}?sslmode=disable
|
|
WORKER_AUTH_TOKEN: ${WORKER_AUTH_TOKEN:-dev-token}
|
|
DB_MAX_CONNS: "10"
|
|
REQUEST_TIMEOUT: "15s"
|
|
LEASE_DURATION: "2m"
|
|
REAPER_INTERVAL: "30s"
|
|
LOG_LEVEL: ${LOG_LEVEL:-info}
|
|
# Logs are teed to stdout (docker logs) and this rotated file, which lives
|
|
# on the mounted ./logs directory so it survives a rebuild.
|
|
LOG_FILE: /var/log/scimesh/coordinator.log
|
|
# Artifact bytes land on the mounted ./data directory, durable across rebuilds.
|
|
COORDINATOR_STORAGE_DIR: /var/lib/scimesh/artifacts
|
|
ports:
|
|
- "${COORDINATOR_PORT:-8080}:8080"
|
|
volumes:
|
|
- ./logs:/var/log/scimesh
|
|
- ./data:/var/lib/scimesh/artifacts
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/health"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|