-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
95 lines (88 loc) · 4.14 KB
/
Copy pathdocker-compose.yml
File metadata and controls
95 lines (88 loc) · 4.14 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
version: "3.9"
# ─────────────────────────────────────────────────────────────────────────────
# ChainForge — Full Stack
#
# docker compose up --build
#
# Services:
# go-builder — compiles the Go binary into a shared volume (init pattern)
# backend — Express API on :5000, calls chainforge.exe binary via execSync
# frontend — Vite/React app on :5173
# landing — Next.js landing page on :3001
#
# Ports exposed to your host:
# http://localhost:3001 → Landing page (Next.js)
# http://localhost:5173 → Frontend app (Vite/React)
# http://localhost:5000 → Backend API (Express)
#
# Volume layout:
# go-bin → Go binary shared between go-builder and backend
# mounted at /go-bin in both containers
# chain-data → Persistent BoltDB chain + wallet .dat files
# mounted at /go-root in the backend (= GO_ROOT env var, set in
# Dockerfile.backend). Backend code lives at /app/backend —
# deliberately NOT under /go-root, since mounting a non-empty
# named volume replaces everything at that path rather than
# merging with the image, which would otherwise hide backend
# code changes behind whatever was first put in the volume.
# ─────────────────────────────────────────────────────────────────────────────
services:
# ── Compile Go binary into shared volume ───────────────────────────────────
go-builder:
build:
context: .
dockerfile: Dockerfile.go
volumes:
- go-bin:/go-bin
# Copy the compiled binary into the shared volume and exit
entrypoint: ["sh", "-c", "cp /app/chainforge /go-bin/chainforge && chmod +x /go-bin/chainforge && echo '✅ Go binary ready'"]
# ── Express REST API ────────────────────────────────────────────────────────
backend:
build:
context: .
dockerfile: Dockerfile.backend
ports:
- "5000:5000"
environment:
PORT: 5000
NODE_ID: 3000
MONGO_URI: ${MONGO_URI:-}
volumes:
# Shared Go binary — mounted at /go-bin so the CMD can copy
# it to /usr/local/bin/chainforge.exe for server.js to call
- go-bin:/go-bin
# Persist blockchain .db and wallet .dat files at GO_ROOT (env var,
# see Dockerfile.backend). Backend code lives at /app/backend instead,
# specifically so this mount never overlaps with — and therefore never
# shadows — the application code.
- chain-data:/go-root
depends_on:
go-builder:
condition: service_completed_successfully
restart: unless-stopped
# ── React Frontend (production build, served by nginx) ────────────────────────
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
ports:
- "5173:80"
depends_on:
- backend
restart: unless-stopped
# ── Next.js Landing Page ────────────────────────────────────────────────────
landing:
build:
context: .
dockerfile: Dockerfile.landing
ports:
# Map host 3001 → container 3000 to avoid clash with Go's NODE_ID=3000 port
- "3001:3000"
depends_on:
- frontend
- backend
restart: unless-stopped
# ── Named Volumes ───────────────────────────────────────────────────────────
volumes:
go-bin: # Shared Go binary between go-builder and backend
chain-data: # Persistent BoltDB chain + wallet files (mounted at /go-root)