Repository navigation
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
223 lines (218 loc) · 10.5 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
223 lines (218 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
services:
gateway:
# Pinned to the nginx:alpine multi-arch index digest to prevent floating-tag
# supply-chain risk (mirrors the watchtower pin below). Refresh deliberately:
# TOKEN=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/nginx:pull" | jq -r .token)
# curl -sI -H "Authorization: Bearer $TOKEN" \
# -H "Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.v2+json" \
# https://registry-1.docker.io/v2/library/nginx/manifests/alpine | grep -i docker-content-digest
# and update both the tag and the @sha256 digest together.
image: nginx:alpine@sha256:4a73073bd557c65b759505da037898b61f1be6cbcc3c2c3aeac22d2a470c1752
container_name: hive-gateway
restart: unless-stopped
ports:
# SECURITY: only the authenticating proxy port is published. :7681 (the raw
# writable ttyd terminal) is intentionally NOT published — the terminal is
# reached through :3001/terminal, which authenticates first. Publishing 7681
# exposed an unauthenticated shell into the credential-holding container.
- "3001:3001"
volumes:
- ./deploy/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
hive:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-sf", "http://127.0.0.1:3001/api/health"]
interval: 10s
timeout: 5s
retries: 3
hive:
# Image references for the standalone stack come from ONE source of truth,
# src/deploy/standalone-images.sh, so the Docker and Podman assets cannot
# drift apart. src/deploy/test_standalone_image_refs.sh fails the build if
# this line stops agreeing with it.
#
# Bumped off the retired `v2-latest` (#4206). That tag belonged to the v2
# branch and resolves to a different, older digest than the v4 channels;
# src/docs/operator-reference.md already told operators not to use it for
# new deployments and flagged this default as pending a bump, and
# src/deploy/k8s/backup-cronjob.yaml made the same move for the same reason
# (#3709). `stable` is the operator-blessed release channel; pin a digest
# here instead (`ghcr.io/hivecommons/hive@sha256:...`) for full
# reproducibility.
image: ghcr.io/hivecommons/hive:stable
build:
context: ..
dockerfile: src/Dockerfile
args:
GIT_HASH: ${GIT_HASH:-unknown}
GIT_SHORT: ${GIT_SHORT:-unknown}
container_name: hive
restart: unless-stopped
cap_add:
- NET_ADMIN
expose:
- "3001"
- "3002"
- "7681"
volumes:
- ./hive.yaml:/etc/hive/hive.yaml
- hive-data:/data
- ./secrets:/secrets:ro
# PARITY (#4404): this list and the variable names in
# deploy/quadlet/hive.env.example are asserted to be the SAME SET by
# deploy/test_standalone_runtime_parity.sh. The Quadlet unit reads its
# environment through an opaque `EnvironmentFile=`, so a variable added here
# and nowhere else used to reach Docker and silently never reach Podman.
# Add to both, or to neither.
environment:
- HIVE_GITHUB_TOKEN=${HIVE_GITHUB_TOKEN}
- HIVE_DASHBOARD_TOKEN=${HIVE_DASHBOARD_TOKEN}
# `:-` on the two OPTIONAL variables and deliberately not on the two
# tokens above (#4477). Compose warns once per command for every `${VAR}`
# it cannot resolve, and ntfy is off by default, so an ordinary quick
# start printed two permanent warnings that mean nothing — training the
# operator to skim past the line that says a variable is unset. That line
# is the ONLY signal Compose gives when the env file is not being read at
# all, which is how the quick start's `.env` sat unread at the repo root.
# Give a default to what is genuinely optional; leave the tokens bare so
# their warning still means something.
- NTFY_SERVER=${NTFY_SERVER:-}
- NTFY_TOPIC=${NTFY_TOPIC:-}
- HIVE_LEVEL=${HIVE_LEVEL:-}
- HIVE_REPO=${HIVE_REPO:-}
- LINEAR_API_KEY=${LINEAR_API_KEY:-}
- LINEAR_CLIENT_ID=${LINEAR_CLIENT_ID:-}
- LINEAR_CLIENT_SECRET=${LINEAR_CLIENT_SECRET:-}
- LINEAR_WEBHOOK_SECRET=${LINEAR_WEBHOOK_SECRET:-}
- HIVE_DEPLOYMENT_RUNTIME=docker-compose
- HIVE_DEPLOYMENT_PODMAN_MODE=
- HIVE_DASHBOARD_UPGRADE_HELPER=${HIVE_DASHBOARD_UPGRADE_HELPER:-}
# Deliberately empty here: the upgrade request bridge (#10344) is the
# Podman/Quadlet answer to a container that cannot reach its host
# lifecycle. Compose upgrades go through the helper above instead. The
# name is still spelled out because
# src/deploy/test_standalone_runtime_parity.sh requires both runtimes to
# name the same set of variables.
- HIVE_DEPLOYMENT_UPGRADE_REQUEST_DIR=
labels:
- "com.centurylinklabs.watchtower.enable=true"
# BOTH LISTENERS, not just the Go API (#4476). 3002 is the Go API; 3001 is
# the Node auth proxy that deploy/nginx.conf points `upstream hive_api` at,
# so 3001 is what the gateway and every operator reach. Probing 3002 alone
# reported this container `healthy` for the whole two minutes a missing
# HIVE_DASHBOARD_TOKEN kept the proxy from binding 3001. CMD-SHELL because
# `&&` is the shell's; the Quadlet unit runs the identical string, which
# deploy/test_standalone_runtime_parity.sh asserts.
healthcheck:
test: ["CMD-SHELL", "curl -sf http://127.0.0.1:3002/api/health && curl -sf http://127.0.0.1:3001/api/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 120s
# Filtered Docker API in front of watchtower (#3865).
#
# Watchtower used to bind /var/run/docker.sock straight into its own
# container. That is the full daemon API — including /exec, which reads the
# GitHub App private key out of the hive container without needing an
# escalation at all. This service is the ONLY thing holding the socket now,
# and it exposes a deny-by-default subset of the API over TCP.
#
# READ src/docs/auto-update-profile.md BEFORE ENABLING THIS PROFILE. The proxy
# narrows the surface; it does NOT make auto-update safe. Watchtower must be
# able to create and start containers to do its job, and that permission is
# itself host-root-equivalent. The doc states exactly what survives.
docker-socket-proxy:
# Pinned by digest for the same reason watchtower is, and more so: this is
# now the container holding the socket. The digest is the multi-arch OCI
# index (linux/amd64 + linux/arm64 both resolve). Bump deliberately by
# verifying the release at
# https://github.com/Tecnativa/docker-socket-proxy/releases and updating
# BOTH the tag and the @sha256 digest together.
image: tecnativa/docker-socket-proxy:0.3.0@sha256:9e4b9e7517a6b660f2cc903a19b257b1852d5b3344794e3ea334ff00ae677ac2
container_name: hive-docker-socket-proxy
restart: unless-stopped
volumes:
# :ro is deliberate but is NOT the control here — a unix socket mounted
# read-only still accepts writes, because the restriction applies to the
# inode, not to the API spoken over it. The control is the allowlist
# below. Do not "harden" this by adding :ro to watchtower and calling it
# done; see src/docs/auto-update-profile.md.
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
# ── ALLOWED: the minimum Watchtower needs ──────────────────────────────
- CONTAINERS=1 # list/inspect the containers it manages
- IMAGES=1 # inspect and pull replacement images
- POST=1 # create/start/stop — without this it can only look
- DELETE=1 # required by WATCHTOWER_CLEANUP=true (old images)
- PING=1 # daemon liveness
- VERSION=1 # API version negotiation on connect
# ── DENIED: set to 0 explicitly, not left to the image's defaults ──────
# These are already the upstream defaults. They are written out so that a
# future image whose defaults change cannot silently widen this, and so a
# reviewer sees the boundary rather than having to infer it.
# EXEC is the important one: it is the direct path to the App private key
# and every agent credential inside the hive container.
- EXEC=0
- AUTH=0
- BUILD=0
- COMMIT=0
- CONFIGS=0
- DISTRIBUTION=0
- INFO=0
- NETWORKS=0
- NODES=0
- PLUGINS=0
- SECRETS=0
- SERVICES=0
- SESSION=0
- SWARM=0
- SYSTEM=0
- TASKS=0
- VOLUMES=0
security_opt:
- no-new-privileges:true
networks:
# ONLY the internal network. The proxy speaks an unauthenticated Docker
# API on :2375 — anything that can route to it inherits that API. It must
# never be published to the host, and it must never be reachable from the
# default network, where the hive container runs semi-trusted agent code.
- docker-proxy
profiles:
- auto-update
watchtower:
# Pinned to v1.7.1 to prevent floating-tag supply-chain risk.
# Bump deliberately by verifying the release at
# https://github.com/containrrr/watchtower/releases and updating BOTH the
# tag and the @sha256 digest below. The digest is the multi-arch
# manifest-list digest, so amd64/arm64 pulls both still resolve.
# src/deploy/test_supply_chain_pins.sh fails the build if the digest is dropped.
image: containrrr/watchtower:1.7.1@sha256:6dd50763bbd632a83cb154d5451700530d1e44200b268a4e9488fefdfcf2b038
container_name: hive-watchtower
restart: unless-stopped
# NO docker.sock bind (#3865). Watchtower reaches the daemon only through
# the filtered proxy above. src/deploy/test_watchtower_socket_contract.sh
# fails the build if the raw socket comes back.
environment:
- DOCKER_HOST=tcp://docker-socket-proxy:2375
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_POLL_INTERVAL=60
- WATCHTOWER_LABEL_ENABLE=true
depends_on:
- docker-socket-proxy
security_opt:
- no-new-privileges:true
networks:
# default: reach registries. docker-proxy: reach the filtered daemon.
- default
- docker-proxy
profiles:
- auto-update
networks:
# internal: true keeps this network off the host and unroutable to the
# outside — it exists only so watchtower can reach the socket proxy. Every
# other service stays on `default` and cannot see the Docker API at all.
docker-proxy:
internal: true
volumes:
hive-data: