Added prod start script, tweaked swarm values for inference containers

This commit is contained in:
Viswamedha Nalabotu 2026-02-26 12:08:16 +00:00
parent 29f97b383d
commit b604c243c8
3 changed files with 43 additions and 22 deletions

View file

@ -4,12 +4,11 @@ services:
build: build:
context: ../../ context: ../../
dockerfile: compose/dev/django/Dockerfile dockerfile: compose/dev/django/Dockerfile
env_file: env_file: ../../.env
- ../../.env
volumes: volumes:
- ../../:/app - ../../:/app
ports: ports:
- '0.0.0.0:8000:8000' - "8000:8000"
depends_on: depends_on:
fyp-postgres-dev: fyp-postgres-dev:
condition: service_healthy condition: service_healthy
@ -23,27 +22,26 @@ services:
dockerfile: compose/dev/node/Dockerfile dockerfile: compose/dev/node/Dockerfile
environment: environment:
NODE_ENV: development NODE_ENV: development
CHOKIDAR_USEPOLLING: 'true' CHOKIDAR_USEPOLLING: "true"
stdin_open: true stdin_open: true
volumes: volumes:
- ../../site:/app:delegated - ../../site:/app:delegated
- /app/node_modules - /app/node_modules
ports: ports:
- '0.0.0.0:5173:5173' - "5173:5173"
fyp-postgres-dev: fyp-postgres-dev:
container_name: fyp-postgres-dev container_name: fyp-postgres-dev
image: pgvector/pgvector:pg15 image: pgvector/pgvector:pg15
env_file: env_file: ../../.env
- ../../.env
environment: environment:
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust
volumes: volumes:
- fyp_postgres_data:/var/lib/postgresql/data - fyp_postgres_data:/var/lib/postgresql/data
ports: ports:
- '0.0.0.0:5432:5432' - "5432:5432"
healthcheck: healthcheck:
test: ['CMD-SHELL', 'pg_isready -h 127.0.0.1 -p 5432 -U ${POSTGRES_USER} -d ${POSTGRES_DB}'] test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -p 5432 -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s interval: 5s
timeout: 3s timeout: 3s
retries: 5 retries: 5
@ -52,7 +50,7 @@ services:
container_name: fyp-redis-dev container_name: fyp-redis-dev
image: redis:7-alpine image: redis:7-alpine
ports: ports:
- '0.0.0.0:6379:6379' - "6379:6379"
volumes: volumes:
- fyp_redis_data:/data - fyp_redis_data:/data
healthcheck: healthcheck:
@ -66,8 +64,7 @@ services:
build: build:
context: ../../ context: ../../
dockerfile: compose/dev/celery/Dockerfile dockerfile: compose/dev/celery/Dockerfile
env_file: env_file: ../../.env
- ../../.env
volumes: volumes:
- ../../:/app - ../../:/app
depends_on: depends_on:
@ -75,22 +72,18 @@ services:
condition: service_healthy condition: service_healthy
fyp-postgres-dev: fyp-postgres-dev:
condition: service_healthy condition: service_healthy
fyp-inference-dev: fyp-inference-dev:
container_name: fyp-inference-dev container_name: fyp-inference-dev
build: build:
context: ../../ context: ../../
dockerfile: compose/dev/inference/Dockerfile dockerfile: compose/dev/inference/Dockerfile
env_file: env_file: ../../.env
- ../../.env
volumes: volumes:
- ../../:/app - ../../:/app
- ../../models:/app/models - ../../models:/app/models
- hf_cache:/root/.cache/huggingface - hf_cache:/root/.cache/huggingface
deploy: deploy:
mode: replicated
replicas: 1
resources: resources:
reservations: reservations:
devices: devices:
@ -104,15 +97,14 @@ services:
- HF_HOME=/root/.cache/huggingface - HF_HOME=/root/.cache/huggingface
- HF_HUB_OFFLINE=1 - HF_HUB_OFFLINE=1
ports: ports:
- "0.0.0.0:8001:8001" - "8001:8001"
depends_on: depends_on:
fyp-redis-dev: fyp-redis-dev:
condition: service_healthy condition: service_healthy
fyp-postgres-dev: fyp-postgres-dev:
condition: service_healthy condition: service_healthy
volumes: volumes:
fyp_postgres_data: fyp_postgres_data:
fyp_redis_data: fyp_redis_data:
hf_cache: hf_cache:

27
compose/prod/django/start Normal file
View file

@ -0,0 +1,27 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
DB_HOST="${POSTGRES_HOST}"
DB_PORT="${POSTGRES_PORT}"
echo "Waiting for database at ${DB_HOST}:${DB_PORT}..."
wait-for-it ${DB_HOST}:${DB_PORT} --timeout=30 --strict || {
echo "Timed out waiting for database" >&2
exit 1
}
echo "Database is available, continuing startup..."
python manage.py makemigrations
python manage.py migrate --noinput
for fixture in /app/data/*.json; do
echo "Loading fixture: $fixture"
python manage.py loaddata "$fixture"
done
python manage.py collectstatic --noinput
exec daphne -b 0.0.0.0 -p 8000 config.asgi:application

View file

@ -6,8 +6,6 @@ services:
dockerfile: compose/dev/inference/Dockerfile dockerfile: compose/dev/inference/Dockerfile
restart: unless-stopped restart: unless-stopped
deploy: deploy:
mode: replicated
replicas: 1
resources: resources:
reservations: reservations:
devices: devices:
@ -20,6 +18,10 @@ services:
- INFERENCE_HTTP_HOST=0.0.0.0 - INFERENCE_HTTP_HOST=0.0.0.0
- INFERENCE_HTTP_PORT=8001 - INFERENCE_HTTP_PORT=8001
- NVIDIA_VISIBLE_DEVICES=all - NVIDIA_VISIBLE_DEVICES=all
- WATCHFILES_FORCE_POLLING=true
- PYTHONPATH=/app
- HF_HOME=/root/.cache/huggingface
- HF_HUB_OFFLINE=1
ports: ports:
- '0.0.0.0:58001:8001' - '0.0.0.0:58001:8001'
volumes: volumes: