feat(docker): add docker build script and enhance docker-compose with health checks and environment variable support
This commit is contained in:
parent
5827b44a21
commit
eb2b58c312
@ -5,15 +5,17 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
container_name: evo-ai-api
|
container_name: evo-ai-api
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
postgres:
|
||||||
- redis
|
condition: service_healthy
|
||||||
|
redis:
|
||||||
|
condition: service_healthy
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_CONNECTION_STRING: postgresql://postgres:postgres@postgres:5432/evo_ai
|
POSTGRES_CONNECTION_STRING: postgresql://postgres:${POSTGRES_PASSWORD:-postgres}@postgres:5432/evo_ai
|
||||||
REDIS_HOST: redis
|
REDIS_HOST: redis
|
||||||
REDIS_PORT: 6379
|
REDIS_PORT: 6379
|
||||||
REDIS_PASSWORD: ""
|
REDIS_PASSWORD: ${REDIS_PASSWORD:-""}
|
||||||
REDIS_SSL: "false"
|
REDIS_SSL: "false"
|
||||||
REDIS_KEY_PREFIX: "a2a:"
|
REDIS_KEY_PREFIX: "a2a:"
|
||||||
REDIS_TTL: 3600
|
REDIS_TTL: 3600
|
||||||
@ -25,38 +27,81 @@ services:
|
|||||||
SENDGRID_API_KEY: ${SENDGRID_API_KEY}
|
SENDGRID_API_KEY: ${SENDGRID_API_KEY}
|
||||||
EMAIL_FROM: ${EMAIL_FROM}
|
EMAIL_FROM: ${EMAIL_FROM}
|
||||||
APP_URL: ${APP_URL}
|
APP_URL: ${APP_URL}
|
||||||
|
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||||
|
DEBUG: ${DEBUG:-false}
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/app/logs
|
- ./logs:/app/logs
|
||||||
|
- ./static:/app/static
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
start_period: 15s
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
||||||
|
memory: 1G
|
||||||
|
networks:
|
||||||
|
- evo-network
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:14-alpine
|
image: postgres:14-alpine
|
||||||
container_name: evo-ai-postgres
|
container_name: evo-ai-postgres
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: postgres
|
POSTGRES_USER: postgres
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
||||||
POSTGRES_DB: evo_ai
|
POSTGRES_DB: evo_ai
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "${POSTGRES_PORT:-5432}:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_period: 10s
|
||||||
|
networks:
|
||||||
|
- evo-network
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
||||||
|
memory: 1G
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:alpine
|
image: redis:alpine
|
||||||
container_name: evo-ai-redis
|
container_name: evo-ai-redis
|
||||||
|
command: redis-server --appendonly yes ${REDIS_PASSWORD:+--requirepass ${REDIS_PASSWORD}}
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "${REDIS_PORT:-6379}:6379"
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
command: redis-server --appendonly yes
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 30s
|
timeout: 30s
|
||||||
retries: 50
|
retries: 50
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- evo-network
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "0.5"
|
||||||
|
memory: 500M
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
name: ${POSTGRES_VOLUME_NAME:-evo-ai-postgres-data}
|
||||||
redis_data:
|
redis_data:
|
||||||
|
name: ${REDIS_VOLUME_NAME:-evo-ai-redis-data}
|
||||||
|
|
||||||
|
networks:
|
||||||
|
evo-network:
|
||||||
|
name: ${NETWORK_NAME:-evo-network}
|
||||||
|
driver: bridge
|
||||||
|
2
docker_build.sh
Executable file
2
docker_build.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
docker build -t atendai/evoai-api:latest .
|
||||||
|
docker push atendai/evoai-api:latest
|
Loading…
Reference in New Issue
Block a user