api/docker-compose.prod.yml

181 lines
4.5 KiB
YAML

name: bemeal
x-app-image: &app-image gitea.leonmorival.com/daily_meal/bemeal-api:${IMAGE_TAG:-latest}
x-app-environment: &app-environment
APP_LOCALE: "fr"
APP_ENV: "production"
APP_KEY: "${APP_KEY:?APP_KEY is required}"
APP_URL: "${APP_URL:?APP_URL is required}"
SERVER_NAME: ":80"
APP_RUNTIME: "Laravel\\FrankenPHP\\Runtime"
APP_DEBUG: "${APP_DEBUG:-false}"
FILESYSTEM_DISK: "public"
DB_CONNECTION: "pgsql"
DB_HOST: "pgsql"
DB_PORT: "5432"
DB_DATABASE: "${DB_DATABASE:?DB_DATABASE is required}"
DB_USERNAME: "${DB_USERNAME:?DB_USERNAME is required}"
DB_PASSWORD: "${DB_PASSWORD:?DB_PASSWORD is required}"
GEMINI_API_KEY: "${GEMINI_API_KEY:?GEMINI_API_KEY is required}"
AI_MEAL_USER_NAME: "${AI_MEAL_USER_NAME:-Lolo AI}"
AI_MEAL_USER_EMAIL: "${AI_MEAL_USER_EMAIL:-loloai@maily.com}"
AI_MEAL_IMAGE_PATH: "${AI_MEAL_IMAGE_PATH:-meal-posts/ai-generated}"
AI_MEAL_IMAGE_QUALITY: "${AI_MEAL_IMAGE_QUALITY:-medium}"
AI_MEAL_TEXT_TIMEOUT: "${AI_MEAL_TEXT_TIMEOUT:-90}"
AI_MEAL_IMAGE_TIMEOUT: "${AI_MEAL_IMAGE_TIMEOUT:-120}"
REDIS_HOST: "redis"
REDIS_CLIENT: "predis"
QUEUE_CONNECTION: "redis"
SCOUT_DRIVER: "meilisearch"
MEILISEARCH_HOST: "http://meilisearch:7700"
MEILISEARCH_KEY: "${MEILISEARCH_KEY:?MEILISEARCH_KEY is required}"
x-app-volumes: &app-volumes
- storage-data:/var/www/html/storage/app
- storage-public-data:/var/www/html/storage/app/public
x-app-depends-on: &app-depends-on
pgsql:
condition: service_healthy
redis:
condition: service_started
meilisearch:
condition: service_started
x-app-healthcheck: &app-healthcheck
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/api/health >/dev/null 2>&1"]
start_period: 30s
interval: 5s
timeout: 5s
retries: 12
x-app-service: &app-service
image: *app-image
restart: unless-stopped
depends_on: *app-depends-on
environment: *app-environment
volumes: *app-volumes
networks:
- internal
stop_grace_period: 30s
services:
bemeal-api-blue:
<<: *app-service
container_name: bemeal-api-blue
ports:
- "127.0.0.1:8081:80"
healthcheck: *app-healthcheck
bemeal-api-green:
<<: *app-service
container_name: bemeal-api-green
ports:
- "127.0.0.1:8082:80"
healthcheck: *app-healthcheck
pgsql:
image: postgres:15-alpine
container_name: bemeal-pgsql
restart: unless-stopped
environment:
POSTGRES_DB: "${DB_DATABASE:?DB_DATABASE is required}"
POSTGRES_USER: "${DB_USERNAME:?DB_USERNAME is required}"
POSTGRES_PASSWORD: "${DB_PASSWORD:?DB_PASSWORD is required}"
volumes:
- pgsql-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -p 5432"]
start_period: 30s
interval: 5s
timeout: 5s
retries: 10
networks:
- internal
redis:
image: redis:alpine
container_name: bemeal-redis
restart: unless-stopped
volumes:
- redis-data:/data
networks:
- internal
horizon:
image: *app-image
container_name: bemeal-horizon
restart: unless-stopped
depends_on:
pgsql:
condition: service_healthy
redis:
condition: service_started
environment: *app-environment
volumes: *app-volumes
command: "php artisan horizon"
stop_grace_period: 60s
networks:
- internal
scheduler:
image: *app-image
container_name: bemeal-scheduler
restart: unless-stopped
depends_on:
pgsql:
condition: service_healthy
redis:
condition: service_started
environment: *app-environment
volumes: *app-volumes
command: "php artisan schedule:work"
stop_grace_period: 30s
networks:
- internal
adminer:
image: adminer:latest
container_name: bemeal-adminer
restart: unless-stopped
environment:
ADMINER_DEFAULT_SERVER: pgsql
networks:
- internal
meilisearch:
image: getmeili/meilisearch:latest
container_name: bemeal-meilisearch
restart: unless-stopped
environment:
MEILI_NO_ANALYTICS: "true"
MEILI_MASTER_KEY: "${MEILISEARCH_KEY:?MEILISEARCH_KEY is required}"
volumes:
- meilisearch-data:/meili_data
networks:
- internal
volumes:
pgsql-data:
external: true
name: bemeal_pgsql_data
redis-data:
name: bemeal_redis_data
storage-data:
name: bemeal_storage_data
storage-public-data:
name: bemeal_storage_public_data
meilisearch-data:
name: bemeal_meilisearch_data
networks:
internal:
driver: bridge