-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: hosted deployment stack — production compose, /healthz, image publish, ops runbook #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Build and publish the coven-github container image to GHCR. | ||
| # Pushes to main publish `latest` + the commit SHA; version tags publish the | ||
| # semver tag. deploy/hosted/compose.yaml pins deployments to these images. | ||
| name: publish | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| tags: ["v*"] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| jobs: | ||
| image: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ghcr.io/opencoven/coven-github | ||
| tags: | | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
| type=sha,format=long | ||
| type=semver,pattern={{version}} | ||
|
|
||
| - uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file added
BIN
+4.85 KB
deploy/coven-github/__pycache__/test_coven_github_adapter.cpython-314.pyc
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets for deploy/hosted/compose.yaml. Copy to .env (mode 0600) and fill | ||
| # in. NEVER commit the filled-in file. | ||
|
|
||
| # Public hostname the GitHub App webhook points at. | ||
| WEBHOOK_DOMAIN=gh.opencoven.ai | ||
|
|
||
| # Image tag to run (a released ghcr.io/opencoven/coven-github tag). | ||
| COVEN_GITHUB_TAG=latest | ||
|
|
||
| # Cloudflare R2 (S3-compatible) for Litestream SQLite replication. | ||
| # Create an R2 API token scoped to one bucket with object read+write. | ||
| R2_ACCOUNT_ID= | ||
| R2_BUCKET=coven-github-store | ||
| R2_ACCESS_KEY_ID= | ||
| R2_SECRET_ACCESS_KEY= | ||
|
|
||
| # Host docker group id, so the unprivileged adapter user can drive the | ||
| # daemon for the container worker backend. provision.sh fills this in | ||
| # (getent group docker | cut -d: -f3). | ||
| DOCKER_GID= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # TLS ingress for hosted coven-github. Caddy provisions and renews | ||
| # Let's Encrypt certificates automatically for $WEBHOOK_DOMAIN. | ||
| {$WEBHOOK_DOMAIN} { | ||
| encode gzip | ||
|
|
||
| # GitHub webhook deliveries and the tenant-scoped API. | ||
| reverse_proxy coven-github:3000 | ||
|
|
||
| log { | ||
| output stdout | ||
| format console | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Production Docker Compose for hosted coven-github: adapter + TLS ingress | ||
| # (Caddy) + continuous SQLite replication (Litestream → Cloudflare R2). | ||
| # | ||
| # Runbook: docs/hosted-deploy.md. Secrets come from ./.env (never committed); | ||
| # copy .env.example and fill it in. | ||
| # | ||
| # Layout on the host (created by provision.sh): | ||
| # /opt/coven-github/ | ||
| # compose.yaml this file | ||
| # .env secrets (mode 0600) | ||
| # Caddyfile TLS ingress | ||
| # litestream.yml replication config | ||
| # config/production.toml adapter config | ||
| # keys/app.pem GitHub App private key (mode 0600) | ||
| # data/ SQLite store (replicated) | ||
|
|
||
| services: | ||
| coven-github: | ||
| image: ghcr.io/opencoven/coven-github:${COVEN_GITHUB_TAG:-latest} | ||
| command: ["serve", "--config", "/config/production.toml"] | ||
| restart: unless-stopped | ||
| expose: | ||
| - "3000" | ||
| volumes: | ||
| - ./config:/config:ro | ||
| - ./keys:/keys:ro | ||
| - ./data:/data | ||
| - ./workspaces:/tmp/coven-github-tasks | ||
| # Container worker backend: the adapter launches per-task hardened | ||
| # containers through the host Docker daemon (docs/container-isolation.md). | ||
| - /var/run/docker.sock:/var/run/docker.sock | ||
| # The image runs unprivileged (uid 10001); grant the host docker group so | ||
| # the worker can drive the daemon. provision.sh fills DOCKER_GID in .env. | ||
| group_add: | ||
| - "${DOCKER_GID:?set in .env (getent group docker | cut -d: -f3)}" | ||
| environment: | ||
| RUST_LOG: "coven_github=info" | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-fsS", "http://localhost:3000/healthz"] | ||
| interval: 30s | ||
| timeout: 5s | ||
| retries: 3 | ||
| start_period: 10s | ||
|
|
||
| caddy: | ||
| image: caddy:2 | ||
| restart: unless-stopped | ||
| ports: | ||
| - "80:80" | ||
| - "443:443" | ||
| volumes: | ||
| - ./Caddyfile:/etc/caddy/Caddyfile:ro | ||
| - caddy-data:/data | ||
| - caddy-config:/config | ||
| environment: | ||
| WEBHOOK_DOMAIN: ${WEBHOOK_DOMAIN:?set in .env, e.g. gh.opencoven.ai} | ||
| depends_on: | ||
| - coven-github | ||
|
|
||
| litestream: | ||
| image: litestream/litestream:0.3 | ||
| restart: unless-stopped | ||
| command: ["replicate", "-config", "/etc/litestream.yml"] | ||
| volumes: | ||
| - ./litestream.yml:/etc/litestream.yml:ro | ||
| - ./data:/data | ||
| environment: | ||
| LITESTREAM_ACCESS_KEY_ID: ${R2_ACCESS_KEY_ID:?set in .env} | ||
| LITESTREAM_SECRET_ACCESS_KEY: ${R2_SECRET_ACCESS_KEY:?set in .env} | ||
| R2_BUCKET: ${R2_BUCKET:?set in .env} | ||
| R2_ACCOUNT_ID: ${R2_ACCOUNT_ID:?set in .env} | ||
| depends_on: | ||
| - coven-github | ||
|
|
||
| volumes: | ||
| caddy-data: | ||
| caddy-config: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Litestream: continuous SQLite replication to Cloudflare R2 (S3-compatible). | ||
| # Credentials come from the environment (compose.yaml). Restore drill: | ||
| # litestream restore -config /etc/litestream.yml /data/coven-github.db | ||
| dbs: | ||
| - path: /data/coven-github.db | ||
| replicas: | ||
| - type: s3 | ||
| bucket: ${R2_BUCKET} | ||
| path: coven-github | ||
| endpoint: https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com | ||
| # R2 ignores regions but the S3 client requires one. | ||
| region: auto | ||
| retention: 720h # 30 days of point-in-time history | ||
| sync-interval: 10s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/usr/bin/env bash | ||
| # Provision a fresh Ubuntu 24.04 host (e.g. Hetzner CPX41) to run hosted | ||
| # coven-github. Idempotent; run as root ON THE SERVER: | ||
| # | ||
| # curl -fsSL https://raw.githubusercontent.com/OpenCoven/coven-github/main/deploy/hosted/provision.sh | bash | ||
| # | ||
| # Then follow docs/hosted-deploy.md to place config, keys, and .env. | ||
| set -euo pipefail | ||
|
|
||
| DEPLOY_DIR=/opt/coven-github | ||
| RAW=https://raw.githubusercontent.com/OpenCoven/coven-github/main/deploy/hosted | ||
|
|
||
| echo "==> Installing Docker Engine + compose plugin" | ||
| if ! command -v docker >/dev/null 2>&1; then | ||
| curl -fsSL https://get.docker.com | sh | ||
| fi | ||
|
|
||
| echo "==> Hardening: unattended upgrades + firewall (22/80/443 only)" | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| apt-get update -qq | ||
| apt-get install -y -qq unattended-upgrades ufw curl | ||
| ufw default deny incoming | ||
| ufw default allow outgoing | ||
| ufw allow 22/tcp | ||
| ufw allow 80/tcp | ||
| ufw allow 443/tcp | ||
| ufw --force enable | ||
|
|
||
| echo "==> Laying out ${DEPLOY_DIR}" | ||
| mkdir -p "${DEPLOY_DIR}"/{config,keys,data,workspaces} | ||
| chmod 700 "${DEPLOY_DIR}/keys" | ||
| # The image runs as uid 10001 (user `coven`); it owns its state dirs. | ||
| chown 10001 "${DEPLOY_DIR}/data" "${DEPLOY_DIR}/workspaces" | ||
| cd "${DEPLOY_DIR}" | ||
| for f in compose.yaml Caddyfile litestream.yml .env.example; do | ||
| curl -fsSL "${RAW}/${f}" -o "${f}" | ||
| done | ||
| [ -f .env ] || { cp .env.example .env && chmod 600 .env; } | ||
|
|
||
| echo "==> Recording the docker group id for the compose worker" | ||
| DOCKER_GID="$(getent group docker | cut -d: -f3)" | ||
| grep -q '^DOCKER_GID=' .env \ | ||
| && sed -i "s/^DOCKER_GID=.*/DOCKER_GID=${DOCKER_GID}/" .env \ | ||
| || echo "DOCKER_GID=${DOCKER_GID}" >> .env | ||
|
|
||
| cat <<'NEXT' | ||
|
|
||
| Provisioned. Next (docs/hosted-deploy.md): | ||
| 1. Fill /opt/coven-github/.env (domain, image tag, R2 credentials) | ||
| 2. Place /opt/coven-github/config/production.toml and keys/app.pem (0600) | ||
| 3. Point DNS A/AAAA for your webhook domain at this host | ||
| 4. docker compose run --rm coven-github doctor --config /config/production.toml | ||
| 5. docker compose up -d | ||
| 6. curl -fsS https://<domain>/healthz | ||
| NEXT |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.