Repository navigation
Expand file tree
/
Copy pathdocker-compose.example.yml
More file actions
98 lines (95 loc) · 4.15 KB
/
Copy pathdocker-compose.example.yml
File metadata and controls
98 lines (95 loc) · 4.15 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
# Snippets to adapt, not to paste wholesale. See the README for the reasoning.
#
# `gcb compose` prints the sidecar below, already filled in for your paths:
#
# gcb compose --socket-dir <a host directory the DSH container mounts> \
# > docker-compose.yml
#
# Then, from that directory: docker compose up -d
#
# Generate it rather than retyping it. The mount targets inside the container must match the
# paths `init --mode sidecar` recorded, and both commands read them from one definition, so a
# hand-edited copy is the one thing that can silently drift.
services:
git-cred-broker:
# The usual NAS case. The released image contains gcb-host, so there is no checkout to copy
# and nothing to build. Only this container mounts the private key; the socket directory is
# the only thing shared with the DSH container.
image: ghcr.io/code-vaults/gcb-host:0.8.0
container_name: git-cred-broker
restart: unless-stopped
# Must match the uid/gid of the container that will use the socket, or it is unusable.
# `compose --user "<pusher uid>:<pusher gid>"` renders this from the deployment.
user: '1000:1000'
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
environment:
# Egress: the socket needs no proxy, the broker's own calls to github.com do.
- http_proxy=${http_proxy:-${HTTP_PROXY:-}}
- https_proxy=${https_proxy:-${HTTPS_PROXY:-}}
- no_proxy=${no_proxy:-${NO_PROXY:-}}
- NODE_USE_ENV_PROXY=1
command:
- sh
- -c
- exec gcb daemon --config /etc/git-cred-broker/config/broker.config.yml
volumes:
# The configuration directory, not one file: an atomic replacement on the host must stay
# visible to the container's watcher. Put broker.config.yml in ./config; the key and refresh
# token stay outside it.
- ./config:/etc/git-cred-broker/config:ro
- ./app.pem:/etc/git-cred-broker/app.pem:ro
# Writable, and the only secret that is: GitHub rotates the refresh token on every exchange,
# so the broker has to write the new one back. It sits beside the key on the host and is
# created by `gcb authorize` — see the README.
- ./user.refresh:/etc/git-cred-broker/user.refresh:rw
# Writable: the audit log is appended to, and it must stay outside the DSH container.
- ./log:/var/log/git-cred-broker
# The socket directory, shared with the DSH container below. This is the only interface
# between the two: no ports are published, and none should be added.
- /srv/git-broker-socket:/run/git-broker
dsh:
# Add the socket mount and the two environment variables. Setting them in environment: is
# better than sourcing a file, because it reaches every process including non-login shells.
# Keep the rest of the existing DSH configuration.
environment:
# ... existing PUID/PGID/proxy entries ...
- GIT_BROKER_SOCKET=/run/git-broker/broker.sock
# Fail closed: never silently fall back to another credential source.
- GIT_BROKER_REQUIRE=1
volumes:
# ... existing mounts ...
# The same host directory the broker binds, or the two are not sharing a socket at all.
- /srv/git-broker-socket:/run/git-broker
# Pin the released image tag or digest; `compose` pins the version it was generated from.
#
# The host-process alternative, for a host that has Node and a service manager:
#
# [Unit]
# Description=git credential broker
# After=network-online.target
#
# [Service]
# Type=simple
# RuntimeDirectory=git-cred-broker
# RuntimeDirectoryMode=0750
# ExecStartPre=/usr/bin/gcb daemon --config /volume1/docker/git-cred-broker/broker.config.yml --check
# ExecStart=/usr/bin/gcb daemon --config /volume1/docker/git-cred-broker/broker.config.yml
# Restart=on-failure
# User=root
#
# [Install]
# WantedBy=multi-user.target
#
# Then, inside the DSH container:
#
# gcb setup
#
# Do not put the private key or any credential anywhere the agent container mounts: every such
# directory is shared with it. The broker's configuration, key and token belong outside all of
# them, and `init`, `stage` and `authorize` refuse a target they detect as shared.