-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
110 lines (105 loc) · 3.24 KB
/
docker-compose.dev.yml
File metadata and controls
110 lines (105 loc) · 3.24 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
services:
postgres:
image: postgres:14-alpine
container_name: multisig-postgres-dev
ports:
- "5434:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: multisig
volumes:
- postgres-dev-data:/var/lib/postgresql/data
- ./docker/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
- multisig-network
app:
build:
context: .
dockerfile: Dockerfile.dev
container_name: multisig-app-dev
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/multisig
- DIRECT_URL=postgresql://postgres:postgres@postgres:5432/multisig
env_file:
- .env
volumes:
- .:/app
- /app/node_modules
- /app/.next
depends_on:
postgres:
condition: service_healthy
networks:
- multisig-network
command: >
sh -c "
echo 'Waiting for PostgreSQL to be ready...' &&
until pg_isready -h postgres -p 5432 -U postgres; do
sleep 1
done &&
echo 'PostgreSQL is ready!' &&
echo 'Running database migrations...' &&
npx prisma migrate deploy || npx prisma db push &&
echo 'Starting development server...' &&
npm run dev
"
# Optional: Database initialization service
# Note: For better migration management, use Ansible instead:
# cd ansible && make setup
# or: cd ansible && ansible-playbook playbooks/dev-db-setup.yml
db-init:
image: node:20-alpine
container_name: multisig-db-init-dev
working_dir: /app
environment:
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/multisig
DIRECT_URL: postgresql://postgres:postgres@postgres:5432/multisig
volumes:
- .:/app
- /app/node_modules
- ./docker/ensure-roles.sh:/docker/ensure-roles.sh:ro
- ./docker/fix-crowdfund-rls.sh:/docker/fix-crowdfund-rls.sh:ro
command: >
sh -c "
apk add --no-cache postgresql-client &&
echo 'Waiting for PostgreSQL to be ready...' &&
until pg_isready -h postgres -p 5432 -U postgres; do
sleep 1
done &&
echo 'PostgreSQL is ready!' &&
echo 'Ensuring required roles exist...' &&
sh /docker/ensure-roles.sh &&
echo 'Installing dependencies...' &&
npm ci --silent &&
echo 'Running database migrations...' &&
if ! npx prisma migrate deploy; then
echo 'Migration failed, attempting to fix Crowdfund table issue...' &&
sh /docker/fix-crowdfund-rls.sh || true &&
echo 'Retrying migrations...' &&
npx prisma migrate deploy
fi &&
echo 'Applying post-migration fixes...' &&
sh /docker/fix-crowdfund-rls.sh || true &&
echo 'Database migrations completed successfully!'
"
depends_on:
postgres:
condition: service_healthy
networks:
- multisig-network
profiles:
- db-init # Only start with: docker compose --profile db-init up
volumes:
postgres-dev-data:
networks:
multisig-network:
driver: bridge