-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
197 lines (189 loc) · 5.5 KB
/
docker-compose.yml
File metadata and controls
197 lines (189 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
185
186
187
188
189
190
191
192
193
194
195
196
197
# Docker Compose configuration for Star Wars Engineer Assessment
# Run: docker compose up --build
# Access: Frontend at http://localhost:5173 | Backend API at http://localhost:8080
services:
# ===========================================
# Backend Services
# ===========================================
backend:
build:
context: ./backend
dockerfile: Dockerfile
target: development
ports:
- "${BACKEND_PORT:-8000}:8000"
environment:
APP_NAME: "${APP_NAME:-Star Wars API}"
APP_ENV: "${APP_ENV:-local}"
APP_KEY: "${APP_KEY:-base64:YOUR_APP_KEY_HERE}"
APP_DEBUG: "${APP_DEBUG:-true}"
APP_URL: "${APP_URL:-http://localhost:8000}"
LOG_CHANNEL: "${LOG_CHANNEL:-stack}"
LOG_LEVEL: "${LOG_LEVEL:-debug}"
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: 3306
DB_DATABASE: "${DB_DATABASE:-starwars}"
DB_USERNAME: "${DB_USERNAME:-starwars}"
DB_PASSWORD: "${DB_PASSWORD:-secret}"
CACHE_STORE: "${CACHE_STORE:-redis}"
QUEUE_CONNECTION: "${QUEUE_CONNECTION:-redis}"
SESSION_DRIVER: "${SESSION_DRIVER:-redis}"
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: "${REDIS_PASSWORD:-null}"
volumes:
- ./backend:/var/www/html
- backend_vendor:/var/www/html/vendor
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- app-network
restart: unless-stopped
# Queue worker for background jobs
queue:
build:
context: ./backend
dockerfile: Dockerfile
target: development
command: php artisan queue:work --tries=3 --timeout=90
environment:
APP_NAME: "${APP_NAME:-Star Wars API}"
APP_ENV: "${APP_ENV:-local}"
APP_KEY: "${APP_KEY:-base64:YOUR_APP_KEY_HERE}"
APP_DEBUG: "${APP_DEBUG:-true}"
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: 3306
DB_DATABASE: "${DB_DATABASE:-starwars}"
DB_USERNAME: "${DB_USERNAME:-starwars}"
DB_PASSWORD: "${DB_PASSWORD:-secret}"
CACHE_STORE: "${CACHE_STORE:-redis}"
QUEUE_CONNECTION: "${QUEUE_CONNECTION:-redis}"
REDIS_HOST: redis
REDIS_PORT: 6379
volumes:
- ./backend:/var/www/html
- backend_vendor:/var/www/html/vendor
depends_on:
- backend
- mysql
- redis
networks:
- app-network
restart: unless-stopped
# Scheduler for cron jobs (runs every minute to check schedule)
scheduler:
build:
context: ./backend
dockerfile: Dockerfile
target: development
command: >
sh -c "while true; do php artisan schedule:run --verbose --no-interaction; sleep 60; done"
environment:
APP_NAME: "${APP_NAME:-Star Wars API}"
APP_ENV: "${APP_ENV:-local}"
APP_KEY: "${APP_KEY:-base64:YOUR_APP_KEY_HERE}"
APP_DEBUG: "${APP_DEBUG:-true}"
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: 3306
DB_DATABASE: "${DB_DATABASE:-starwars}"
DB_USERNAME: "${DB_USERNAME:-starwars}"
DB_PASSWORD: "${DB_PASSWORD:-secret}"
CACHE_STORE: "${CACHE_STORE:-redis}"
QUEUE_CONNECTION: "${QUEUE_CONNECTION:-redis}"
REDIS_HOST: redis
REDIS_PORT: 6379
volumes:
- ./backend:/var/www/html
- backend_vendor:/var/www/html/vendor
depends_on:
- backend
- mysql
- redis
networks:
- app-network
restart: unless-stopped
# ===========================================
# Frontend Services
# ===========================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
target: development
ports:
- "${FRONTEND_PORT:-5173}:5173"
environment:
VITE_API_URL: "${VITE_API_URL:-http://localhost:8000/api}"
volumes:
- ./frontend:/app
- frontend_node_modules:/app/node_modules
depends_on:
- backend
networks:
- app-network
restart: unless-stopped
# ===========================================
# Database Services
# ===========================================
mysql:
image: mysql:8.4
ports:
- "${DB_EXTERNAL_PORT:-3307}:3306"
environment:
MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-root}"
MYSQL_DATABASE: "${DB_DATABASE:-starwars}"
MYSQL_USER: "${DB_USERNAME:-starwars}"
MYSQL_PASSWORD: "${DB_PASSWORD:-secret}"
command: --mysql-native-password=ON --authentication-policy=mysql_native_password
volumes:
- mysql_data:/var/lib/mysql
networks:
- app-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD:-root}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
# ===========================================
# Cache & Queue Services
# ===========================================
redis:
image: redis:7-alpine
ports:
- "${REDIS_EXTERNAL_PORT:-6379}:6379"
volumes:
- redis_data:/data
networks:
- app-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
# ===========================================
# Networks
# ===========================================
networks:
app-network:
driver: bridge
# ===========================================
# Volumes
# ===========================================
volumes:
mysql_data:
driver: local
redis_data:
driver: local
backend_vendor:
driver: local
frontend_node_modules:
driver: local