Repository navigation
Expand file tree
/
Copy pathcompose.yaml
More file actions
149 lines (141 loc) · 5.27 KB
/
Copy pathcompose.yaml
File metadata and controls
149 lines (141 loc) · 5.27 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
# Local development environment (not a way to run koroku in production; see
# docs/OPERATIONS.md for that).
#
# docker compose up
#
# then open http://localhost:4200. Run it from the repository root.
#
# web Vite dev server in development mode, with hot reload of the Ember
# app. /api and /auth are proxied to koroku.
# koroku The control plane, built from this checkout, with login disabled.
# It deploys apps into the local Docker daemon.
# caddy The reverse proxy, on 127.0.0.1:80 and :443 only. koroku loads its
# configuration as in production, so a deployed app answers on
# https://<slug>.dev.localhost and the console on
# https://console.dev.localhost. Certificates come from Caddy's own
# local CA; import its root certificate into the browser's trust
# store (see docs/DEVELOPMENT.md).
#
# storage S3-compatible object storage (Versity S3 Gateway) on
# 127.0.0.1:9000, standing in for production object storage: log archives and
# restic backups go there, as plain files in a volume. Its WebUI is
# on http://127.0.0.1:9001 (access key koroku-dev, secret
# koroku-dev-secret). storage-setup creates the bucket.
#
# After changing Go code: docker compose restart koroku
#
# Both services run in the image of dev/Dockerfile (the same one bin/dev
# uses) and share its caches. Like bin/dev they use the host network and the
# host's Docker socket, and mount the checkout at its host path: the apps
# koroku deploys are started by the host's daemon, which resolves paths on the
# host. State lives in data/dev/ (ignored by git); delete it to start over.
name: koroku-dev
x-dev: &dev
image: koroku-dev:compose
build: ./dev
init: true
network_mode: host
working_dir: ${PWD}
# Drops from root to the owner of the checkout before running the command.
entrypoint: ["dev/compose-entrypoint.sh"]
volumes:
- ${PWD}:${PWD}
- /var/run/docker.sock:/var/run/docker.sock
- go:/cache/go
- go-build:/cache/go-build
- pnpm:/cache/pnpm-store
services:
koroku:
<<: *dev
command: ["dev/serve.sh"]
# Backups read the named volumes of apps where Docker keeps them, at
# the same path as on the host, like koroku does as root in production.
# Set KOROKU_DOCKER_ROOT (for example in .env) when `docker info -f
# '{{.DockerRootDir}}'` is not /var/lib/docker. Docker Desktop keeps
# volumes inside its VM, out of reach; volume backups fail there.
volumes:
- ${PWD}:${PWD}
- /var/run/docker.sock:/var/run/docker.sock
- go:/cache/go
- go-build:/cache/go-build
- pnpm:/cache/pnpm-store
- ${KOROKU_DOCKER_ROOT:-/var/lib/docker}/volumes:${KOROKU_DOCKER_ROOT:-/var/lib/docker}/volumes
environment:
DEV_FILE_CAPS: "1"
depends_on:
caddy:
condition: service_healthy
storage-setup:
condition: service_completed_successfully
caddy:
image: caddy:2.11.9
network_mode: host
# The admin API stays on loopback; --resume brings back the routes koroku
# loaded last, so restarting Caddy alone does not drop them.
command: ["caddy", "run", "--resume", "--config", "/etc/caddy/koroku-initial.json"]
volumes:
- ./deploy/caddy-initial.json:/etc/caddy/koroku-initial.json:ro
- caddy-data:/data
- caddy-config:/config
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:2019/config/"]
interval: 2s
timeout: 2s
retries: 15
storage:
image: versity/versitygw:v1.11.0
network_mode: host
# Fixed credentials: the gateway listens on loopback only and holds
# nothing but local test data. They match dev/serve.sh. The posix backend
# keeps every bucket as a directory under /data.
command:
- --port=127.0.0.1:9000
- --webui=127.0.0.1:9001
- --cors-allow-origin=http://127.0.0.1:9001
- --quiet
- posix
- /data
environment:
ROOT_ACCESS_KEY: koroku-dev
ROOT_SECRET_KEY: koroku-dev-secret
volumes:
- storage-data:/data
# Creates the bucket (koroku expects it to exist, like the bucket made by
# hand in production), then exits.
storage-setup:
<<: *dev
restart: "no"
depends_on:
- storage
command: ["dev/storage-setup.sh"]
web:
<<: *dev
command:
- sh
- -c
- >-
cd web &&
pnpm install --frozen-lockfile &&
exec pnpm exec vite --mode development --host 127.0.0.1 --port 4200 --strictPort
environment:
# Point this at another backend to develop against it, for example the
# mock API of web/mock/server.mjs.
KOROKU_URL: ${KOROKU_URL:-http://127.0.0.1:8080}
# The caches bin/dev uses. When bin/dev created them first, Compose warns that
# they were "not created by Docker Compose"; sharing them is intended.
volumes:
go:
name: koroku-dev-go
go-build:
name: koroku-dev-go-build
pnpm:
name: koroku-dev-pnpm
# Caddy's local CA (its root key and certificate) and the issued
# certificates. Deleting it makes a new CA, which has to be trusted again.
caddy-data:
name: koroku-dev-caddy-data
caddy-config:
name: koroku-dev-caddy-config
# Objects of the local storage: log archives and the restic repository.
storage-data:
name: koroku-dev-s3-data