-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
124 lines (119 loc) · 4.49 KB
/
docker-compose.yml
File metadata and controls
124 lines (119 loc) · 4.49 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
version: '3.8'
services:
# Frontend service configuration
kenyare-frontend:
build:
context: .
dockerfile: Dockerfile.frontend.txt # Dockerfile for building the frontend service
ports:
- "5173:5173" # Expose port 5173 for frontend service
- "24678:24678" # For HMR websockets
depends_on:
- kenyare-backend # Ensure backend starts before frontend
environment:
- NODE_ENV=development # Set environment to development
- VITE_API_BASE_URL=http://kenyare-backend:8000 # API base URL for frontend to communicate with backend
- VITE_PUBLIC_IP=${VITE_PUBLIC_IP} # Public IP for frontend
- VITE_WS_HOST=${VITE_WS_HOST}
- HOST=0.0.0.0 # Host for the frontend service
- UPLOAD_DIR=/app/static/uploads
volumes:
- /kenyare/node_modules # Persistent storage for node_modules between container restarts
- type: bind
source: ./uploads
target: /app/static/uploads
user: "0:0"
deploy:
resources:
limits:
cpus: '1.0' # Limit CPU usage to 1 core
memory: 2G # Limit memory usage to 2GB
restart: unless-stopped # Restart policy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:5173"] # Health check command
interval: 30s # Interval between health checks
timeout: 10s # Timeout for health check
retries: 3 # Number of retries before marking as unhealthy
start_period: 40s # Start period before health checks begin
logging:
driver: "json-file"
options:
max-size: "200k" # Max size of log file
max-file: "10" # Max number of log files
# Backend service configuration
kenyare-backend:
build:
context: .
dockerfile: Dockerfile.backend.txt # Dockerfile for building the backend service
ports:
- 8000:8000 # Expose port 8000 for backend service
environment:
- ALLOWED_HOSTS=${ALLOWED_HOSTS} # Allowed hosts for backend
- OPENAI_API_KEY=${OPENAI_API_KEY} # API key for OpenAI
volumes:
- kenyare-backend-data:/var/lib/kenyare # Persistent storage for backend data
- type: bind
source: ./uploads
target: /app/static/uploads
user: "0:0"
deploy:
resources:
limits:
cpus: '1.0' # Limit CPU usage to 1 core
memory: 1G # Limit memory usage to 1GB
restart: unless-stopped # Restart policy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"] # Health check command
interval: 30s # Interval between health checks
timeout: 10s # Timeout for health check
retries: 3 # Number of retries before marking as unhealthy
start_period: 40s # Start period before health checks begin
logging:
driver: "json-file"
options:
max-size: "200k" # Max size of log file
max-file: "10" # Max number of log files
# NGINX service configuration
nginx:
build:
context: .
dockerfile: Dockerfile.nginx # Dockerfile for building the NGINX service
ports:
- "${NGINX_PORT:-80}:80" # Expose port 80 (HTTP traffic) for NGINX
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro # Mount NGINX configuration file
- ./static:/usr/share/nginx/html/static:ro # Mount static files directory
depends_on:
- kenyare-frontend # Ensure frontend starts before NGINX
- kenyare-backend # Ensure backend starts before NGINX
deploy:
resources:
limits:
cpus: '0.30' # Limit CPU usage to 0.3 cores
memory: 256M # Limit memory usage to 256MB
restart: unless-stopped # Restart policy
healthcheck:
test: ["CMD", "nginx", "-t"] # Health check command to test NGINX configuration
interval: 30s # Interval between health checks
timeout: 10s # Timeout for health check
retries: 3 # Number of retries before marking as unhealthy
logging:
driver: "json-file"
options:
max-size: "200k" # Max size of log file
max-file: "10" # Max number of log files
volumes:
kenyare-backend-data:
driver: local # Use local driver for persistent storage
uploads:
driver: local
driver_opts:
type: none
device: ${PWD}/uploads # Adjust this path to your needs
o: bind
networks:
default:
driver: bridge # Use bridge network driver
ipam:
config:
- subnet: 172.28.0.0/16 # Custom subnet for the network