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:
context: ../../
dockerfile: compose/dev/django/Dockerfile
env_file:
- ../../.env
env_file: ../../.env
volumes:
- ../../:/app
ports:
- '0.0.0.0:8000:8000'
- "8000:8000"
depends_on:
fyp-postgres-dev:
condition: service_healthy
@ -23,27 +22,26 @@ services:
dockerfile: compose/dev/node/Dockerfile
environment:
NODE_ENV: development
CHOKIDAR_USEPOLLING: 'true'
CHOKIDAR_USEPOLLING: "true"
stdin_open: true
volumes:
- ../../site:/app:delegated
- /app/node_modules
ports:
- '0.0.0.0:5173:5173'
- "5173:5173"
fyp-postgres-dev:
container_name: fyp-postgres-dev
image: pgvector/pgvector:pg15
env_file:
- ../../.env
env_file: ../../.env
environment:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- fyp_postgres_data:/var/lib/postgresql/data
ports:
- '0.0.0.0:5432:5432'
- "5432:5432"
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
timeout: 3s
retries: 5
@ -52,7 +50,7 @@ services:
container_name: fyp-redis-dev
image: redis:7-alpine
ports:
- '0.0.0.0:6379:6379'
- "6379:6379"
volumes:
- fyp_redis_data:/data
healthcheck:
@ -66,8 +64,7 @@ services:
build:
context: ../../
dockerfile: compose/dev/celery/Dockerfile
env_file:
- ../../.env
env_file: ../../.env
volumes:
- ../../:/app
depends_on:
@ -75,22 +72,18 @@ services:
condition: service_healthy
fyp-postgres-dev:
condition: service_healthy
fyp-inference-dev:
container_name: fyp-inference-dev
build:
context: ../../
dockerfile: compose/dev/inference/Dockerfile
env_file:
- ../../.env
env_file: ../../.env
volumes:
- ../../:/app
- ../../models:/app/models
- hf_cache:/root/.cache/huggingface
deploy:
mode: replicated
replicas: 1
resources:
reservations:
devices:
@ -104,15 +97,14 @@ services:
- HF_HOME=/root/.cache/huggingface
- HF_HUB_OFFLINE=1
ports:
- "0.0.0.0:8001:8001"
- "8001:8001"
depends_on:
fyp-redis-dev:
condition: service_healthy
fyp-postgres-dev:
condition: service_healthy
volumes:
fyp_postgres_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
restart: unless-stopped
deploy:
mode: replicated
replicas: 1
resources:
reservations:
devices:
@ -20,6 +18,10 @@ services:
- INFERENCE_HTTP_HOST=0.0.0.0
- INFERENCE_HTTP_PORT=8001
- NVIDIA_VISIBLE_DEVICES=all
- WATCHFILES_FORCE_POLLING=true
- PYTHONPATH=/app
- HF_HOME=/root/.cache/huggingface
- HF_HUB_OFFLINE=1
ports:
- '0.0.0.0:58001:8001'
volumes: