-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.https.yml
More file actions
67 lines (65 loc) · 2.49 KB
/
Copy pathdocker-compose.https.yml
File metadata and controls
67 lines (65 loc) · 2.49 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
# Optional HTTPS overlay. The base compose file remains LAN/local friendly.
# Set PUBLIC_IP (or PIXCODE_DOMAIN) before starting this overlay. The Caddy
# container derives `pixcode.<PUBLIC_IP>.<PUBLIC_PROXY_DOMAIN>` at runtime so
# Compose never has to interpolate a nested variable default.
services:
pixcode:
# The base compose file publishes 3001 for LAN/local use. In the HTTPS
# overlay keep that port reachable only from the host itself; Caddy talks
# to Pixcode over the private compose network and is the only public edge.
# Compose normally merges list values from the base file. `!override`
# prevents the public `3001:3001` base mapping from surviving alongside
# this loopback-only mapping when the HTTPS overlay is applied.
ports: !override
- "127.0.0.1:3001:3001"
environment:
PUBLIC_IP: "${PUBLIC_IP:-}"
PUBLIC_PROXY_DOMAIN: "${PUBLIC_PROXY_DOMAIN:-sslip.io}"
PUBLIC_PROXY_PREFIX: "${PUBLIC_PROXY_PREFIX:-pixcode}"
PUBLIC_SCHEME: "https"
TRUST_PROXY_HOPS: "1"
CORS_ORIGINS: "${CORS_ORIGINS:-}"
caddy:
image: caddy:2.10-alpine
container_name: pixcode-caddy
restart: unless-stopped
depends_on:
pixcode:
condition: service_healthy
ports:
- "80:80"
- "443:443"
environment:
# The command below derives PIXCODE_DOMAIN inside the container. Keeping
# this as a plain variable avoids Compose's ambiguous nested-default
# interpolation and still permits an explicit real domain.
PIXCODE_DOMAIN: "${PIXCODE_DOMAIN:-}"
PUBLIC_IP: "${PUBLIC_IP:-}"
PUBLIC_PROXY_DOMAIN: "${PUBLIC_PROXY_DOMAIN:-sslip.io}"
PUBLIC_PROXY_PREFIX: "${PUBLIC_PROXY_PREFIX:-pixcode}"
command:
- /bin/sh
- -c
- >-
if [ -z "$${PIXCODE_DOMAIN}" ]; then
if [ -n "$${PUBLIC_IP}" ]; then
export PIXCODE_DOMAIN="$${PUBLIC_PROXY_PREFIX}.$${PUBLIC_IP}.$${PUBLIC_PROXY_DOMAIN}";
else
echo 'PUBLIC_IP or PIXCODE_DOMAIN is required for the HTTPS overlay.' >&2;
exit 64;
fi;
fi;
case "$${PIXCODE_DOMAIN}" in
''|*[!A-Za-z0-9.-]*)
echo 'PIXCODE_DOMAIN must contain only DNS hostname characters.' >&2;
exit 64;
;;
esac;
exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
volumes:
- ./deploy/Caddyfile:/etc/caddy/Caddyfile:ro
- caddy-data:/data
- caddy-config:/config
volumes:
caddy-data:
caddy-config: