Repository navigation
Expand file tree
/
Copy pathcompose.quickstart.yml
More file actions
87 lines (83 loc) · 3.31 KB
/
Copy pathcompose.quickstart.yml
File metadata and controls
87 lines (83 loc) · 3.31 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
# Single-node Docker-only quickstart. OPENSTORAGE_IMAGE has no default: set it to
# a published ghcr.io/coder/openstorage version or to a local build. Compose pulls
# it only when it is not already present. See docs/how-to/quickstart-docker.md.
x-image: &image "${OPENSTORAGE_IMAGE:?Set OPENSTORAGE_IMAGE to a published image or a local build}"
services:
init:
image: *image
pull_policy: missing
user: root
restart: "no"
entrypoint: ["/bin/sh", "-ec"]
command:
- |
fail() { echo "quickstart init: $$*; restore a complete backup or destroy this disposable project" >&2; exit 1; }
# Only the mount roots are prepared. Never repair existing key files or
# recursively chown data; a different runtime UID needs an operator migration.
chown root:root /private /public
chmod 700 /private
chmod 755 /public
chown openstorage:openstorage /data
chmod 700 /data
umask 077
if [ -e /public/org.pub.pem ] || [ -L /public/org.pub.pem ]; then
[ -f /public/org.pub.pem ] && [ ! -L /public/org.pub.pem ] || fail "public key is not a regular file"
[ -f /private/org.pem ] && [ -f /private/org.pub.pem ] || fail "published key has no complete private pair"
fi
openstorage keygen --if-missing --out /private/org
if [ -e /public/org.pub.pem ] || [ -L /public/org.pub.pem ]; then
cmp -s /private/org.pub.pem /public/org.pub.pem || fail "published key differs from validated pair"
[ "$$(stat -c '%u:%g:%a' /public/org.pub.pem)" = 0:0:644 ] || fail "public key permissions changed"
else
# Noclobber exclusively creates the destination. An interrupted copy
# remains visible and fails validation next time; never silently replace it.
(umask 022; set -C; cat /private/org.pub.pem > /public/org.pub.pem)
fi
volumes:
- private:/private
- public:/public
- data:/data
server:
image: *image
pull_policy: missing
user: openstorage
restart: "no"
# docker stop sends SIGTERM to serve (PID 1) and SIGKILL after this
# period (Docker's default is 10 s). serve needs up to 8 s of drain,
# 1 s of git-child kill grace and 1 s for handlers to return, then
# teardown, which on S3-WAL includes up to 5 s of instance-lease
# release: 15 s. 30 s leaves headroom (issue #480).
stop_grace_period: 30s
depends_on:
init:
condition: service_completed_successfully
environment:
OPENSTORAGE_DATA_DIR: /data
OPENSTORAGE_ORG: selfhost
OPENSTORAGE_ORG_PUBKEYS: /public/org.pub.pem
OPENSTORAGE_LISTEN: 0.0.0.0:8080
OPENSTORAGE_BASE_URL: http://127.0.0.1:${OPENSTORAGE_PORT:-8080}
ports:
- "127.0.0.1:${OPENSTORAGE_PORT:-8080}:8080"
volumes:
- public:/public:ro
- data:/data
healthcheck:
# Startup initialization has completed before /healthz can answer. This
# remains a liveness probe, not continuous backing-store readiness.
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/healthz"]
interval: 2s
timeout: 3s
retries: 30
cli:
image: *image
pull_policy: missing
profiles: ["tools"]
user: root
restart: "no"
volumes:
- private:/private:ro
volumes:
private:
public:
data: