-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
184 lines (175 loc) · 5.5 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
184 lines (175 loc) · 5.5 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
services:
# MySQL Database (Development)
mysql:
image: mysql:8.0
container_name: securewallet_mysql_dev
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-CHANGE_THIS_DEV_ROOT_PASSWORD}
MYSQL_DATABASE: securewallet_dev
MYSQL_USER: securewallet_dev
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-CHANGE_THIS_DEV_DB_PASSWORD}
# SECURE: Comment out ports for production-like security in dev
ports:
- "3307:3306"
volumes:
- mysql_dev_data:/var/lib/mysql
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p$$MYSQL_ROOT_PASSWORD"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- securewallet_network_dev
# MongoDB Database (Development)
mongodb:
image: mongo:7.0
container_name: securewallet_mongodb_dev
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USERNAME:-admin}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD:-CHANGE_THIS_DEV_MONGO_PASSWORD}
MONGO_INITDB_DATABASE: securewallet_dev
# SECURE: Comment out ports for production-like security in dev
ports:
- "27018:27017"
volumes:
- mongodb_dev_data:/data/db
networks:
- securewallet_network_dev
# Redis Cache (Development)
redis:
image: redis:7.2-alpine
container_name: securewallet_redis_dev
# SECURE: Comment out ports for production-like security in dev
ports:
- "6380:6379"
command: redis-server --requirepass ${REDIS_PASSWORD:-CHANGE_THIS_DEV_REDIS_PASSWORD}
volumes:
- redis_dev_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-CHANGE_THIS_DEV_REDIS_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
networks:
- securewallet_network_dev
# Backend Application (Go - Development)
backend:
build:
context: .
dockerfile: build/docker/Dockerfile.go.dev
container_name: securewallet_backend_dev
ports:
- "8081:8080"
env_file:
- .env
volumes:
- .:/app
environment:
- DB_HOST=mysql
- DB_PORT=3306
- DB_USER=securewallet_dev
- DB_PASSWORD=${MYSQL_PASSWORD:-securewalletpass_dev}
- DB_NAME=securewallet_dev
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-CHANGE_THIS_DEV_REDIS_PASSWORD}
- PORT=8080
- ENVIRONMENT=development
- GIN_MODE=debug
- RESET_DATABASE_ON_STARTUP=${RESET_DATABASE_ON_STARTUP:-false}
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-CHANGE_THIS_DEV_JWT_SECRET_KEY}
- JWT_ALGORITHM=HS256
- ACCESS_TOKEN_EXPIRE_MINUTES=30
- USER_PASSWORD=User#2025
- ADMIN_PASSWORD=Admin#2025
- AUTO_SETUP_CRON=${AUTO_SETUP_CRON:-true}
- APP_VERSION=dev
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health/live"]
interval: 15s
timeout: 5s
retries: 3
start_period: 40s
networks:
- securewallet_network_dev
# Cron Service for Scheduled Tasks
cron:
build:
context: .
dockerfile: build/docker/Dockerfile.go.dev
container_name: securewallet_cron_dev
env_file:
- .env
volumes:
- .:/app
- ./logs/cron:/app/logs/cron
environment:
- DB_HOST=mysql
- DB_PORT=3306
- DB_USER=securewallet_dev
- DB_PASSWORD=${MYSQL_PASSWORD:-securewalletpass_dev}
- DB_NAME=securewallet_dev
- REDIS_HOST=redis
- REDIS_PORT=6379
- ENVIRONMENT=development
- AUTO_SETUP_CRON=true
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
backend:
condition: service_healthy
networks:
- securewallet_network_dev
command: >
sh -c "
echo '🚀 Starting SecureWallet Cron Service...' &&
apk add --no-cache dcron &&
mkdir -p /app/logs/cron &&
echo '⏳ Waiting for backend to be ready...' &&
sleep 30 &&
echo '⚙️ Setting up cron jobs...' &&
echo '*/5 * * * * cd /app && go run main.go --cron=comment-approval >> /app/logs/cron/comment-approval.log 2>&1' > /tmp/crontab &&
echo '0 * * * * cd /app && go run main.go --cron=backup >> /app/logs/cron/backup.log 2>&1' >> /tmp/crontab &&
echo '0 2 * * * cd /app && go run main.go --cron=log-cleanup >> /app/logs/cron/log-cleanup.log 2>&1' >> /tmp/crontab &&
echo '*/10 * * * * cd /app && go run main.go --cron=security-monitor >> /app/logs/cron/security-monitor.log 2>&1' >> /tmp/crontab &&
crontab /tmp/crontab &&
echo '✅ Cron jobs setup completed!' &&
echo '📋 Current crontab:' &&
crontab -l &&
echo '🔄 Starting cron daemon...' &&
crond -f -d 8
"
# Frontend Application (Development)
frontend:
build: ./frontend
container_name: securewallet_frontend_dev
ports:
- "3001:3000"
environment:
- NODE_ENV=development
- VITE_API_BASE_URL=http://localhost:8081/api
volumes:
- ./frontend/src:/app/src
- ./frontend/public:/app/public
command: npm run dev
depends_on:
- backend
networks:
- securewallet_network_dev
volumes:
mysql_dev_data:
mongodb_dev_data:
redis_dev_data:
networks:
securewallet_network_dev:
driver: bridge