Repository navigation
Expand file tree
/
Copy pathcompose.logto.https.yaml
More file actions
221 lines (199 loc) · 9.05 KB
/
Copy pathcompose.logto.https.yaml
File metadata and controls
221 lines (199 loc) · 9.05 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
services:
postgres:
ports: !reset []
environment:
POSTGRES_PASSWORD: '${AGENTCONNECT_POSTGRES_PASSWORD:?set AGENTCONNECT_POSTGRES_PASSWORD before enabling HTTPS}'
# Keep deployment administration opt-in and loopback-only. Public traffic is
# authenticated by the bundled Logto deployment below.
setup-server:
profiles: [setup]
ports: !reset []
environment:
SETUP_SERVER_URL: 'http://localhost:${AGENTCONNECT_SETUP_PORT:-8091}'
LOGTO_ADMIN_ENDPOINT: 'http://localhost:${AGENTCONNECT_LOGTO_ADMIN_PORT:-3002}'
LOGTO_MGMT_ENDPOINT: 'http://logto:3001'
OIDC_ISSUER: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_LOGTO_HTTPS_PORT}/oidc'
AGENTCONNECT_PUBLIC_WEB_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}'
AGENTCONNECT_PUBLIC_CP_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}/cp'
AGENTCONNECT_PUBLIC_RELAY_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}/relay'
control-plane:
ports: !reset []
environment:
API_KEY_PEPPER: '${AGENTCONNECT_API_KEY_PEPPER:?set AGENTCONNECT_API_KEY_PEPPER before enabling HTTPS}'
RELAY_TOKEN: '${AGENTCONNECT_RELAY_TOKEN:?set AGENTCONNECT_RELAY_TOKEN before enabling HTTPS}'
OIDC_ISSUER: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_LOGTO_HTTPS_PORT}/oidc'
LOGTO_ENDPOINT: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_LOGTO_HTTPS_PORT}'
LOGTO_MGMT_ENDPOINT: 'http://logto:3001'
PUBLIC_CP_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}/cp'
PUBLIC_WEB_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}'
PUBLIC_RELAY_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}/relay'
CORS_ORIGIN: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}'
# Console file transfer through the bundled object store (docs/designs/source-cache-file-transfer.md §7): URLs are signed for the public origin, while the Control Plane reaches the store at Caddy's in-network name.
AC_FILE_TRANSFER: '{"version":1,"endpoint":"https://object-store.internal:9443","publicEndpoint":"https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_OBJECT_STORE_HTTPS_PORT:?set AGENTCONNECT_OBJECT_STORE_HTTPS_PORT before enabling HTTPS}","region":"us-east-1","bucket":"agentconnect","forcePathStyle":true,"credentials":{"source":"static","dir":"/run/secrets","accessKeyIdKey":"object_store_access_key_id","secretAccessKeyKey":"object_store_secret_access_key"}}'
# The Control Plane reads the bucket through Caddy, so it trusts Caddy's internal root.
NODE_EXTRA_CA_CERTS: /caddy-root/root.crt
depends_on:
object-store-setup:
condition: service_completed_successfully
caddy-ca:
condition: service_completed_successfully
secrets:
- object_store_access_key_id
- object_store_secret_access_key
volumes:
- caddy_root_ca:/caddy-root:ro
relay:
ports: !reset []
environment:
RELAY_TOKEN: '${AGENTCONNECT_RELAY_TOKEN:?set AGENTCONNECT_RELAY_TOKEN before enabling HTTPS}'
DAEMON_DIAL_URL: 'wss://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}/relay'
web:
ports: !reset []
environment:
PUBLIC_WEB_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}'
CP_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}/cp/api/v1'
RELAY_URL: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}/relay'
LOGTO_ENDPOINT: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_LOGTO_HTTPS_PORT}'
logto-db-init:
environment:
PGPASSWORD: '${AGENTCONNECT_POSTGRES_PASSWORD:?set AGENTCONNECT_POSTGRES_PASSWORD before enabling HTTPS}'
LOGTO_POSTGRES_PASSWORD: '${LOGTO_POSTGRES_PASSWORD:?set LOGTO_POSTGRES_PASSWORD before enabling HTTPS}'
logto:
ports: !reset []
environment:
DB_URL: 'postgresql://logto:${LOGTO_POSTGRES_PASSWORD:?set LOGTO_POSTGRES_PASSWORD before enabling HTTPS}@postgres:5432/logto'
ENDPOINT: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_LOGTO_HTTPS_PORT}'
ADMIN_ENDPOINT: 'http://localhost:${AGENTCONNECT_LOGTO_ADMIN_PORT:-3002}'
TRUST_PROXY_HEADER: 'true'
# RustFS, an S3-compatible store for console file transfers. Reachable only through Caddy's HTTPS origin, because signed URLs must be https://.
object-store:
image: rustfs/rustfs:${AGENTCONNECT_RUSTFS_VERSION:-1.0.1}
environment:
RUSTFS_ACCESS_KEY: '${AGENTCONNECT_OBJECT_STORE_ACCESS_KEY:?set AGENTCONNECT_OBJECT_STORE_ACCESS_KEY before enabling HTTPS}'
RUSTFS_SECRET_KEY: '${AGENTCONNECT_OBJECT_STORE_SECRET_KEY:?set AGENTCONNECT_OBJECT_STORE_SECRET_KEY before enabling HTTPS}'
healthcheck:
test: ['CMD', 'curl', '-fsS', '-o', '/dev/null', 'http://127.0.0.1:9000/health']
interval: 5s
timeout: 3s
retries: 20
volumes:
- object-store-data:/data
restart: unless-stopped
# Creates the bucket, its lifecycle rules and browser CORS; safe to rerun on every start.
object-store-setup:
image: rustfs/rustfs:${AGENTCONNECT_RUSTFS_VERSION:-1.0.1}
entrypoint: ['sh', '/object-store-setup.sh']
depends_on:
object-store:
condition: service_healthy
environment:
AC_STORE_URL: http://object-store:9000
AC_STORE_BUCKET: agentconnect
AC_STORE_CORS_ORIGIN: 'https://${AGENTCONNECT_HTTPS_HOST}:${AGENTCONNECT_HTTPS_PORT}'
RUSTFS_ACCESS_KEY: '${AGENTCONNECT_OBJECT_STORE_ACCESS_KEY:?set AGENTCONNECT_OBJECT_STORE_ACCESS_KEY before enabling HTTPS}'
RUSTFS_SECRET_KEY: '${AGENTCONNECT_OBJECT_STORE_SECRET_KEY:?set AGENTCONNECT_OBJECT_STORE_SECRET_KEY before enabling HTTPS}'
configs:
- source: object-store-setup
target: /object-store-setup.sh
restart: 'no'
# Publishes Caddy's internal root certificate, and never its key, for the Control Plane to trust at process start.
caddy-ca:
image: caddy:2-alpine
command:
- /bin/sh
- -c
- |
set -eu
root=/data/caddy/pki/authorities/local/root.crt
for _ in $$(seq 60); do
if [ -s "$$root" ]; then
install -m 0644 "$$root" /caddy-root/root.crt
exit 0
fi
sleep 1
done
echo 'Caddy did not create its internal root CA' >&2
exit 1
depends_on:
caddy:
condition: service_started
volumes:
- caddy_data:/data:ro
- caddy_root_ca:/caddy-root
restart: 'no'
# Caddy starts first so the Control Plane can trust its root; its upstreams answer 502 until they are healthy.
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- '${AGENTCONNECT_HTTPS_BIND_ADDRESS:-0.0.0.0}:${AGENTCONNECT_HTTPS_PORT}:443'
- '${AGENTCONNECT_HTTPS_BIND_ADDRESS:-0.0.0.0}:${AGENTCONNECT_LOGTO_HTTPS_PORT}:8443'
- '${AGENTCONNECT_HTTPS_BIND_ADDRESS:-0.0.0.0}:${AGENTCONNECT_OBJECT_STORE_HTTPS_PORT:?set AGENTCONNECT_OBJECT_STORE_HTTPS_PORT before enabling HTTPS}:9443'
- '127.0.0.1:${AGENTCONNECT_LOGTO_ADMIN_PORT:-3002}:3002'
- '127.0.0.1:${AGENTCONNECT_SETUP_PORT:-8091}:8091'
configs:
- source: caddyfile
target: /etc/caddy/Caddyfile
volumes:
- caddy_data:/data
- caddy_runtime_config:/config
networks:
default:
# The Control Plane's own route to the store, independent of how clients name the host.
aliases: [object-store.internal]
admin:
configs:
# One setup script for Compose and the chart.
object-store-setup:
file: ./charts/agentconnect/files/object-store-setup.sh
caddyfile:
content: |
{
# IP-address clients do not consistently send SNI. Select the
# certificate for this IP when the ClientHello omits it.
default_sni ${AGENTCONNECT_HTTPS_HOST}
}
https://${AGENTCONNECT_HTTPS_HOST} {
tls internal
handle_path /cp/* {
reverse_proxy control-plane:8080
}
handle_path /relay/* {
reverse_proxy relay:8080
}
handle {
reverse_proxy web:8080
}
}
https://${AGENTCONNECT_HTTPS_HOST}:8443 {
tls internal
reverse_proxy logto:3001 {
header_up X-Forwarded-Proto https
}
}
# The S3 API keeps the client's Host header, which every SigV4 signature covers.
https://${AGENTCONNECT_HTTPS_HOST}:9443 {
tls internal
reverse_proxy object-store:9000
}
# The Control Plane's in-network route to the same store; the host may be localhost, which inside a container is the container itself.
https://object-store.internal:9443 {
tls internal
reverse_proxy object-store:9000
}
http://:3002 {
reverse_proxy logto:3002
}
http://:8091 {
reverse_proxy setup-server:8091
}
secrets:
object_store_access_key_id:
environment: AGENTCONNECT_OBJECT_STORE_ACCESS_KEY
object_store_secret_access_key:
environment: AGENTCONNECT_OBJECT_STORE_SECRET_KEY
volumes:
caddy_data:
caddy_runtime_config:
caddy_root_ca:
object-store-data: