Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions deploy/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
# The service publishes no port. Whatever carries webhook deliveries to it
# joins the `edge` network and reaches it at receiver:8080.
#
# OTEL_EXPORTER_OTLP_ENDPOINT defaults to empty. Setting it drains the stored
# queue, so the host owner must export the stored backlog first.
# METRICS_NETWORK is required and names an existing network on the host.
# Compose reads both from the environment or a .env file beside compose.yaml.
#
# Both secrets are files, never environment variables: `secrets/webhook_secret`
# for the receiver and `secrets/tunnel_token` for the tunnel connector. Compose
# bind-mounts each file as it is, so the host file itself must be readable by
Expand Down Expand Up @@ -45,6 +50,7 @@ services:
restart: unless-stopped
environment:
LISTEN_ADDR: ":8080"
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-}
STORE_FILE: /var/lib/github-metrics/store.db
WEBHOOK_SECRET_FILE: /run/secrets/webhook_secret
volumes:
Expand All @@ -53,6 +59,7 @@ services:
- webhook_secret
networks:
- edge
- metrics
healthcheck:
test: ["CMD", "/github-metrics", "-healthcheck"]
interval: 30s
Expand Down Expand Up @@ -116,6 +123,9 @@ secrets:

networks:
edge: {}
metrics:
name: "${METRICS_NETWORK:?set METRICS_NETWORK to the existing collector network}"
external: true

volumes:
store: {}
11 changes: 11 additions & 0 deletions deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@ func TestReceiverServiceSettings(t *testing.T) {
for _, want := range []string{
"\n user: \"65532:65532\"\n",
"\n read_only: true\n",
"\n OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-}\n",
"\n STORE_FILE: /var/lib/github-metrics/store.db\n",
"\n volumes:\n - store:/var/lib/github-metrics\n",
"\n networks:\n - edge\n - metrics\n",
} {
if !strings.Contains(block, want) {
t.Errorf("the receiver service lacks %q", strings.TrimSpace(want))
Expand All @@ -374,6 +376,14 @@ func TestReceiverServiceSettings(t *testing.T) {
if !strings.Contains(composeText(t), "\nvolumes:\n store: {}\n") {
t.Error("compose.yaml does not define the named store volume")
}

const network = "\n metrics:\n" +
" name: \"${METRICS_NETWORK:?set METRICS_NETWORK to the existing collector network}\"\n" +
" external: true\n"

if !strings.Contains(composeText(t), network) {
t.Error("compose.yaml does not define the external metrics network with its required METRICS_NETWORK name")
}
}

// TestTunnelServiceSettings reads the block for the pinned image, the token
Expand All @@ -397,6 +407,7 @@ func TestTunnelServiceSettings(t *testing.T) {
"\n secrets:\n - tunnel_token\n",
"\n - --token-file\n - /run/secrets/tunnel_token\n",
"\n depends_on:\n receiver:\n condition: service_healthy\n",
"\n networks:\n - edge\n healthcheck:\n",
} {
if !strings.Contains(block, want) {
t.Errorf("the tunnel service lacks %q", strings.TrimSpace(want))
Expand Down