-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
116 lines (112 loc) · 3.48 KB
/
Copy pathdocker-compose.yml
File metadata and controls
116 lines (112 loc) · 3.48 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
services:
mariadb:
image: mariadb:11.2
container_name: rt_mart_mariadb
command: --lower-case-table-names=1
ports:
- "3306:3306"
environment:
# Root password for database administration
- MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-c}
# Application database name
- MARIADB_DATABASE=${DB_NAME:-rt_mart_db}
# Application database user
- MARIADB_USER=${DB_USER:-rt_mart_user}
# Application database password
- MARIADB_PASSWORD=${DB_PASSWORD:-rt_mart_and_the_user_password_yeah_very_cool123*}
volumes:
# Persist database data between container restarts
- mariadb_data:/var/lib/mysql
# Add initialization scripts
- ./database/init:/docker-entrypoint-initdb.d
healthcheck:
# Check if MariaDB is ready to accept connections
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
networks:
- app-network
# NestJS Backend Service
backend:
build:
context: ./backend
dockerfile: ./Dockerfile.dev
container_name: rt_mart_backend
command: sh -c "npm run migration:run && npm run start:dev" #if migrations are needed on startup
ports:
- '3000:3000'
volumes:
# Mount source code for hot-reloading during development
- ./backend:/app
# Prevent node_modules from being overwritten
- /app/node_modules
environment:
- NODE_ENV=development
# Database connection string
- DATABASE_URL=mysql://${DB_USER:-rt_mart_user}:${DB_PASSWORD:-rt_mart_and_the_user_password_yeah_very_cool123*}@mariadb:3306/${DB_NAME:-rt_mart_db}
- DB_HOST=mariadb
- DB_PORT=3306
- DB_USER=${DB_USER:-rt_mart_user}
- DB_PASSWORD=${DB_PASSWORD:-rt_mart_and_the_user_password_yeah_very_cool123*}
- DB_NAME=${DB_NAME:-rt_mart_db}
# TypeORM settings
- TYPEORM_SYNCHRONIZE=false
- TYPEORM_LOGGING=true
env_file:
# Load additional environment variables from .env file
- ./backend/.env
depends_on:
mariadb:
# Wait for MariaDB to be healthy before starting backend
condition: service_healthy
healthcheck:
# Check if backend API is responding
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
networks:
- app-network
# React Frontend Service
frontend:
build:
context: ./frontend
dockerfile: ./Dockerfile.dev
args:
REGISTRY_PREFIX: ${REGISTRY_PREFIX:-}
container_name: rt_mart_frontend
ports:
- "5173:5173"
volumes:
# Mount source code for hot-reloading during development
- ./frontend:/app
# Prevent node_modules from being overwritten
- /app/node_modules
environment:
# Enable file watching for hot-reload on all platforms
- CHOKIDAR_USEPOLLING=true
# Backend API URL for development
- VITE_API_URL=http://localhost:3000
# Docker environment flag
- DOCKER_ENV=true
env_file:
# Load additional environment variables from .env file
- ./frontend/.env
depends_on:
- backend
restart: unless-stopped
networks:
- app-network
# Named volumes for data persistence
volumes:
mariadb_data:
driver: local
# Custom network for service communication
networks:
app-network:
driver: bridge