Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
153 lines (147 loc) · 6.22 KB
/
Copy pathdocker-compose.yml
File metadata and controls
153 lines (147 loc) · 6.22 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
150
151
152
153
version: "2.4"
###############################################################################
# docker-compose.yml — OpenEscrow MVP
# docker-compose.OpenEscrow.yml — OpenEscrow (openescrow.smarthinking.tech)
#
# Handles: local development + production-equivalent single-server deployment.
# Services: postgres, api (Fastify), web (Next.js), bot (Telegraf).
# Does NOT: include Redis, reverse proxy, or TLS termination (post-MVP scope).
#
# Served by the main stack's nginx at https://openescrow.smarthinking.tech
# (see main docker-compose.yml + nginx-conf/default.conf).
#
#
# Usage:
# docker compose up -d # start all services
# docker compose ps # check health
# docker compose logs api # tail api logs
# docker compose down -v # stop + remove volumes (DESTRUCTIVE)
#
# Production (on server):
# 1. Start main stack first so app-network exists:
# cd /path/to/smarthinking-website && docker compose up -d
# 2. Obtain SSL for openescrow (main stack certbot): already in main compose
# 3. Start OpenEscrow (from this project directory):
# docker compose -f docker-compose.OpenEscrow.yml up -d
#
# Usage:
# docker compose -f docker-compose.OpenEscrow.yml up -d
# docker compose -f docker-compose.OpenEscrow.yml ps
# docker compose -f docker-compose.OpenEscrow.yml down -v # DESTRUCTIVE
###############################################################################
services:
# ─── PostgreSQL ─────────────────────────────────────────────────────────────
postgres:
image: postgres:16-alpine
container_name: open-escrow-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-escrow}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
POSTGRES_DB: ${POSTGRES_DB:-open_escrow}
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- '${POSTGRES_PORT:-5432}:5432'
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-escrow} -d ${POSTGRES_DB:-open_escrow}']
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
# ─── Backend API ─────────────────────────────────────────────────────────────
api:
build:
context: .
dockerfile: apps/api/Dockerfile
container_name: open-escrow-api
restart: unless-stopped
depends_on:
- postgres
environment:
NODE_ENV: ${NODE_ENV:-production}
DATABASE_URL: postgresql://${POSTGRES_USER:-escrow}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-open_escrow}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET is required}
JWT_EXPIRY: ${JWT_EXPIRY:-24h}
ALLOWED_ORIGIN: ${ALLOWED_ORIGIN:-http://localhost:3000}
CONTRACT_ADDRESS: ${CONTRACT_ADDRESS:?CONTRACT_ADDRESS is required}
RPC_URL: ${RPC_URL:?RPC_URL is required}
CHAIN_ID: ${CHAIN_ID:-11155111}
USDC_ADDRESS: ${USDC_ADDRESS:?USDC_ADDRESS is required}
USDT_ADDRESS: ${USDT_ADDRESS:?USDT_ADDRESS is required}
INDEXER_POLL_INTERVAL_MS: ${INDEXER_POLL_INTERVAL_MS:-12000}
BOT_API_SECRET: ${BOT_API_SECRET:?BOT_API_SECRET is required}
API_PORT: ${API_PORT:-3001}
LOG_LEVEL: ${LOG_LEVEL:-info}
expose:
- "3001"
networks:
- default
- app-network
healthcheck:
test: ['CMD-SHELL', 'wget -qO- http://localhost:3001/api/v1/health || exit 1']
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
# ─── Web Dashboard ────────────────────────────────────────────────────────────
web:
build:
context: .
dockerfile: apps/web/Dockerfile
args:
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://openescrow.smarthinking.tech}
NEXT_PUBLIC_CHAIN_ID: ${CHAIN_ID:-11155111}
NEXT_PUBLIC_CONTRACT_ADDRESS: ${CONTRACT_ADDRESS}
NEXT_PUBLIC_USDC_ADDRESS: ${USDC_ADDRESS}
NEXT_PUBLIC_USDT_ADDRESS: ${USDT_ADDRESS}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${WALLETCONNECT_PROJECT_ID}
# Nginx routes /api/* to this Fastify service, so /api/rpc hits the Fastify
# RPC proxy (index.ts). RPC_URL is set in the API service's environment.
NEXT_PUBLIC_RPC_URL: ${NEXT_PUBLIC_RPC_URL:-https://openescrow.smarthinking.tech/api/rpc}
container_name: open-escrow-web
restart: unless-stopped
depends_on:
- api
environment:
NODE_ENV: ${NODE_ENV:-production}
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://openescrow.smarthinking.tech}
NEXT_PUBLIC_CHAIN_ID: ${CHAIN_ID:-11155111}
NEXT_PUBLIC_CONTRACT_ADDRESS: ${CONTRACT_ADDRESS}
NEXT_PUBLIC_USDC_ADDRESS: ${USDC_ADDRESS}
NEXT_PUBLIC_USDT_ADDRESS: ${USDT_ADDRESS}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${WALLETCONNECT_PROJECT_ID:?WALLETCONNECT_PROJECT_ID is required}
expose:
- "3000"
networks:
- default
- app-network
healthcheck:
test: ['CMD-SHELL', 'wget -qO- http://localhost:3000 || exit 1']
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
# ─── Telegram Bot ─────────────────────────────────────────────────────────────
bot:
build:
context: .
dockerfile: apps/bot/Dockerfile
container_name: open-escrow-bot
restart: unless-stopped
depends_on:
- api
environment:
NODE_ENV: ${NODE_ENV:-production}
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN:?TELEGRAM_BOT_TOKEN is required}
API_BASE_URL: ${BOT_API_BASE_URL:-http://api:3001}
BOT_API_SECRET: ${BOT_API_SECRET:?BOT_API_SECRET is required}
POLL_INTERVAL_MS: ${BOT_POLL_INTERVAL_MS:-30000}
LOG_LEVEL: ${LOG_LEVEL:-info}
volumes:
postgres_data:
driver: local
# Join the main stack's network so nginx can proxy to open-escrow-web (openescrow.smarthinking.tech)
networks:
app-network:
external: true