Repository navigation
Expand file tree
/
Copy pathdocker-compose.clean.yml
More file actions
135 lines (119 loc) · 3.58 KB
/
Copy pathdocker-compose.clean.yml
File metadata and controls
135 lines (119 loc) · 3.58 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
version: '3.8'
networks:
fuzeinfra:
external: true
name: fuzeinfra_default
services:
# Database initialization service
fuzekeys-db-init:
build:
context: ./backend
dockerfile: Dockerfile
container_name: fuzekeys-db-init
environment:
- DATABASE_URL=postgresql://postgres:postgres@shared-postgres:5432/postgres
- PYTHONPATH=/app
networks:
- fuzeinfra
command: >
sh -c "
echo 'Waiting for PostgreSQL to be ready...'
while ! pg_isready -h shared-postgres -p 5432 -U postgres; do
sleep 2
done
echo 'PostgreSQL is ready!'
echo 'Setting up FuzeKeys database...'
python -c '
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
try:
conn = psycopg2.connect(
host=\"shared-postgres\",
port=5432,
user=\"postgres\",
password=\"postgres\",
database=\"postgres\"
)
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(\"SELECT 1 FROM pg_catalog.pg_database WHERE datname = %s\", (\"fuzekeys\",))
if not cursor.fetchone():
cursor.execute(\"CREATE DATABASE fuzekeys\")
print(\"Created fuzekeys database\")
cursor.execute(\"SELECT 1 FROM pg_roles WHERE rolname = %s\", (\"fuzekeys_user\",))
if not cursor.fetchone():
cursor.execute(\"CREATE USER fuzekeys_user WITH PASSWORD %s\", (\"fuzekeys_password\",))
print(\"Created fuzekeys_user\")
cursor.execute(\"GRANT ALL PRIVILEGES ON DATABASE fuzekeys TO fuzekeys_user\")
cursor.close()
conn.close()
conn = psycopg2.connect(
host=\"shared-postgres\",
port=5432,
user=\"postgres\",
password=\"postgres\",
database=\"fuzekeys\"
)
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(\"GRANT ALL ON SCHEMA public TO fuzekeys_user\")
cursor.execute(\"GRANT CREATE ON SCHEMA public TO fuzekeys_user\")
cursor.execute(\"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO fuzekeys_user\")
cursor.execute(\"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO fuzekeys_user\")
cursor.close()
conn.close()
print(\"Database setup completed successfully!\")
except Exception as e:
print(f\"Database setup error: {e}\")
exit(1)
'
echo 'Running database migrations...'
python -c '
from app.database import engine, Base
from app.models.site import Site
Base.metadata.create_all(engine)
print(\"Database tables created successfully!\")
'
echo 'Database initialization completed!'
"
restart: "no"
# FuzeKeys Backend API
fuzekeys-api:
build:
context: ./backend
dockerfile: Dockerfile
container_name: fuzekeys-api
env_file:
- docker.env
depends_on:
- fuzekeys-db-init
ports:
- "8002:8002"
networks:
- fuzeinfra
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8002/health"]
interval: 30s
timeout: 10s
retries: 3
# FuzeKeys Frontend (React)
fuzekeys-frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: fuzekeys-frontend
env_file:
- docker.env
depends_on:
- fuzekeys-api
ports:
- "3001:3000"
networks:
- fuzeinfra
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3