Commit
·
119352e
1
Parent(s):
ba75edf
Update configurations for HF
Browse files- Dockerfile +1 -0
- docker-compose.yml +15 -3
- gunicorn_config.py +8 -8
Dockerfile
CHANGED
@@ -5,6 +5,7 @@ WORKDIR /app
|
|
5 |
# Install system dependencies
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
|
|
8 |
&& rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
# Copy requirements first to leverage Docker cache
|
|
|
5 |
# Install system dependencies
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
8 |
+
curl \
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
# Copy requirements first to leverage Docker cache
|
docker-compose.yml
CHANGED
@@ -3,14 +3,15 @@ version: '3.8'
|
|
3 |
services:
|
4 |
web:
|
5 |
build: .
|
6 |
-
command: gunicorn --config gunicorn_config.py app:app
|
7 |
expose:
|
8 |
- "8008"
|
9 |
volumes:
|
10 |
- .:/app
|
11 |
- upload_data:/app/uploads
|
12 |
depends_on:
|
13 |
-
|
|
|
14 |
environment:
|
15 |
- FLASK_ENV=production
|
16 |
- REDIS_URL=redis://redis:6379/0
|
@@ -19,7 +20,13 @@ services:
|
|
19 |
resources:
|
20 |
limits:
|
21 |
cpus: '0.6'
|
22 |
-
memory:
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
restart: unless-stopped
|
24 |
|
25 |
redis:
|
@@ -29,6 +36,11 @@ services:
|
|
29 |
- redis_data:/data
|
30 |
ports:
|
31 |
- "6379:6379"
|
|
|
|
|
|
|
|
|
|
|
32 |
deploy:
|
33 |
resources:
|
34 |
limits:
|
|
|
3 |
services:
|
4 |
web:
|
5 |
build: .
|
6 |
+
command: gunicorn --config gunicorn_config.py app:app
|
7 |
expose:
|
8 |
- "8008"
|
9 |
volumes:
|
10 |
- .:/app
|
11 |
- upload_data:/app/uploads
|
12 |
depends_on:
|
13 |
+
redis:
|
14 |
+
condition: service_healthy
|
15 |
environment:
|
16 |
- FLASK_ENV=production
|
17 |
- REDIS_URL=redis://redis:6379/0
|
|
|
20 |
resources:
|
21 |
limits:
|
22 |
cpus: '0.6'
|
23 |
+
memory: 6G
|
24 |
+
healthcheck:
|
25 |
+
test: ["CMD", "curl", "-f", "http://localhost:8008/health"]
|
26 |
+
interval: 30s
|
27 |
+
timeout: 10s
|
28 |
+
retries: 3
|
29 |
+
start_period: 40s
|
30 |
restart: unless-stopped
|
31 |
|
32 |
redis:
|
|
|
36 |
- redis_data:/data
|
37 |
ports:
|
38 |
- "6379:6379"
|
39 |
+
healthcheck:
|
40 |
+
test: ["CMD", "redis-cli", "ping"]
|
41 |
+
interval: 10s
|
42 |
+
timeout: 5s
|
43 |
+
retries: 3
|
44 |
deploy:
|
45 |
resources:
|
46 |
limits:
|
gunicorn_config.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
import multiprocessing
|
2 |
import os
|
3 |
|
4 |
-
# Number of worker processes -
|
5 |
-
workers =
|
6 |
|
7 |
-
# Number of threads per worker
|
8 |
-
threads =
|
9 |
|
10 |
# Maximum number of pending connections
|
11 |
-
backlog =
|
12 |
|
13 |
# Maximum number of requests a worker will process before restarting
|
14 |
-
max_requests =
|
15 |
max_requests_jitter = 50
|
16 |
|
17 |
# Timeout for worker processes (5 minutes)
|
@@ -30,8 +30,8 @@ access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
|
|
30 |
port = os.getenv('PORT', '8008') # HF uses PORT env var
|
31 |
bind = f"0.0.0.0:{port}"
|
32 |
|
33 |
-
# Worker class
|
34 |
-
worker_class = "
|
35 |
|
36 |
# Process name
|
37 |
proc_name = "selector_server"
|
|
|
1 |
import multiprocessing
|
2 |
import os
|
3 |
|
4 |
+
# Number of worker processes - limited for 2vCPU environment
|
5 |
+
workers = 2 # Using 2 workers for 2vCPU
|
6 |
|
7 |
+
# Number of threads per worker - reduced for memory efficiency
|
8 |
+
threads = 2
|
9 |
|
10 |
# Maximum number of pending connections
|
11 |
+
backlog = 1024
|
12 |
|
13 |
# Maximum number of requests a worker will process before restarting
|
14 |
+
max_requests = 1000
|
15 |
max_requests_jitter = 50
|
16 |
|
17 |
# Timeout for worker processes (5 minutes)
|
|
|
30 |
port = os.getenv('PORT', '8008') # HF uses PORT env var
|
31 |
bind = f"0.0.0.0:{port}"
|
32 |
|
33 |
+
# Worker class - using sync for better stability
|
34 |
+
worker_class = "sync"
|
35 |
|
36 |
# Process name
|
37 |
proc_name = "selector_server"
|