Repository navigation
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
126 lines (115 loc) · 5.48 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
126 lines (115 loc) · 5.48 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
# Development overrides, layered on docker-compose.yml:
# docker compose up -d --build --remove-orphans (.env sets COMPOSE_FILE/COMPOSE_PROFILES)
#
# What changes compared with the runtime stack:
# - backend and provision use the Dockerfile `development` stage (toolchain + uv) instead of `runtime`.
# - The repo is bind-mounted at /app, so code edits are live without rebuilding the image.
# - start-python-service.sh runs `uv sync` at startup so the dev venv matches uv.lock.
# - The backend auto-reloads when files under src/backend change.
# - The embedding services run their runtime images with source mounted over them (see below).
# - Nginx proxies the React UI to Vite, which hot-reloads the bind-mounted frontend source.
# Profiles, limits, ports, and networks are inherited from docker-compose.yml.
#
# Splitting services across machines in development works the same way: add tailnet to each
# machine's COMPOSE_PROFILES (see the tailscale service in docker-compose.yml), e.g. an embedding-only laptop:
# COMPOSE_PROFILES=embedding-gpu,log-shipper,tailnet
# backend and provision share one image and one volume holding both the uv cache and the venv
# (paths set in the Dockerfile `development` stage). Same volume = same filesystem, so uv hardlinks
# packages from its cache instead of copying them: each package is stored once. provision finishes before backend starts, so they never sync at once.
x-development: &development
build:
target: development
image: goldenguide-python:development
environment:
# Throttle uv's parallelism so the startup sync doesn't hit the container's CPU/RAM caps.
UV_CONCURRENT_DOWNLOADS: ${UV_CONCURRENT_DOWNLOADS:-2}
UV_CONCURRENT_INSTALLS: ${UV_CONCURRENT_INSTALLS:-1}
UV_CONCURRENT_BUILDS: ${UV_CONCURRENT_BUILDS:-1}
volumes:
- .:/app
- python_dev_env:/home/app/.cache
# Embedding dependencies (torch, CUDA) are large and rarely change, so dev reuses the runtime image
# instead of a multi-GB dev venv; running dev and prod side by side stores them once. Mounted source
# on PYTHONPATH takes precedence over the copy installed in the image. After changing an embedding
# dependency group, rebuild the image (`up --build`).
x-embedding-dev: &embedding-dev
volumes:
- ./src:/app/src:ro
- ./configs:/app/configs:ro
environment:
PYTHONPATH: /app/src
services:
backend:
<<: *development
# dev-backend = the backend dependency group plus dev tools. --reload-dir limits file watching to backend code.
command: [start-python-service.sh, dev-backend, uvicorn, backend.main:app, --host, 0.0.0.0, --port, "8080", --ws, none, --reload, --reload-dir, /app/src/backend]
provision:
<<: *development
# Same group as backend so both share one venv.
command: [start-python-service.sh, dev-backend, python, -m, backend.core.startup.provision]
# IDE tool environment (type hints, tests, Ruff): point the IDE's Docker Compose interpreter at this
# service. It sleeps and shares backend's venv, so it starts and stops with the rest of all-dev.
workspace:
<<: *development
build:
context: .
dockerfile: Dockerfile
target: development
profiles: [all-dev]
cpus: ${WORKSPACE_CPUS:-2.0}
mem_limit: ${WORKSPACE_MEMORY_LIMIT:-2g}
memswap_limit: ${WORKSPACE_MEMORY_LIMIT:-2g}
command: [sleep, infinity]
networks: [public, private]
# Model weights stay in the base file's /models volume.
local-embedding-gpu: *embedding-dev
local-embedding-cpu: *embedding-dev
# The public origin stays on Nginx; API/auth requests still go straight to the backend.
frontend:
build:
target: development-proxy
image: goldenguide-frontend:development-proxy
depends_on:
frontend-vite:
condition: service_healthy
# Internal only: both HTTP and the HMR WebSocket are reached through frontend:8080.
frontend-vite:
build:
context: .
dockerfile: docker/frontend/Dockerfile
target: development
image: goldenguide-frontend:development
profiles: [frontend, all, all-dev]
restart: unless-stopped
cpus: ${FRONTEND_DEV_CPUS:-1.0}
mem_limit: ${FRONTEND_DEV_MEMORY_LIMIT:-1g}
memswap_limit: ${FRONTEND_DEV_MEMORY_LIMIT:-1g}
logging:
driver: json-file
options:
max-size: ${CONTAINER_LOG_MAX_SIZE:-10m}
max-file: "3"
# Reconcile the persistent Linux dependencies on restart when the lockfile changes.
# Scope CI to install: pnpm can replace stale modules without a TTY; Vite keeps its dev environment.
command: [sh, -ec, "CI=true pnpm install --frozen-lockfile && exec pnpm dev --host 0.0.0.0"]
environment:
GG_BACKEND_ORIGIN: ${BACKEND_ORIGIN:-http://backend:8080}
GG_SITE_ORIGIN: ${SITE_ORIGIN:-http://localhost:8080}
# Docker Desktop bind mounts do not reliably deliver file-change events from Windows.
GG_WATCH_POLLING: ${FRONTEND_DEV_POLLING:-true}
volumes:
- ./frontend:/app
- frontend_node_modules:/app/node_modules
healthcheck:
test: [CMD, wget, -qO-, http://127.0.0.1:5173/@vite/client]
interval: 10s
timeout: 3s
retries: 6
start_period: 60s
networks: [public]
db-bootstrap:
# The test database is created only for development, never in the runtime configuration.
command: [psql, --host=postgres, "--username=${DB__POSTGRES__USER:-}", --dbname=postgres, --set=ON_ERROR_STOP=1, "--set=databases=${DB__POSTGRES__DATABASE:-goldenguide},goldenguide_test", --file=/bootstrap.sql]
volumes:
python_dev_env:
frontend_node_modules: