feat: Add environment configuration files and update Docker Compose setup for development and production

This commit is contained in:
MaddoScientisto 2026-04-20 19:58:42 +02:00
commit 539a848e95
8 changed files with 292 additions and 193 deletions

View file

@ -1,44 +1,39 @@
services:
faceai:
image: node:20-alpine
container_name: regalami-faceai
image: ${FACEAI_CLIENT_IMAGE:-forgejo.maddoscientisto.net/maddo/faceai-client:latest}
container_name: ${FACEAI_CLIENT_CONTAINER_NAME:-regalami-faceai}
restart: unless-stopped
working_dir: /app
command:
- node
- docker/run-with-log-file.mjs
- /data/logs/backend.log
- ${FACEAI_BACKEND_LOG_FILE:-/data/logs/backend.log}
- npm
- run
- start
- --workspace
- "@regalami/faceai-backend"
environment:
PORT: 3001
FACEAI_FRONTEND_URL: http://localhost:3001
FACEAI_PUBLIC_BASE_URL: http://localhost:3001
FACEAI_LEGACY_RETURN_URL: http://localhost:8080/faceai_return.php
FACEAI_LEGACY_HOME_URL: http://localhost:8080/index.jsp
FACEAI_PKL_ROOT: /data/pkl
FACEAI_ENABLE_LOCAL_LEGACY_STATIC: 1
FACEAI_LOCAL_LEGACY_STATIC_ROOT: /legacy-www
FACEAI_SHARED_SECRET: disagio-spaghetti-science-lol-boh
FACEAI_SESSION_COOKIE: rus_faceai_session
FACEAI_REDIS_URL: redis://redis:6379
FACEAI_RUNTIME_ROOT: /data/runtime
FACEAI_UPLOAD_ROOT: /data/runtime/uploads
FACEAI_LOG_ROOT: /data/logs
FACEAI_PROCESSOR_HEARTBEAT_GRACE_MS: 20000
NODE_ENV: ${NODE_ENV:-production}
PORT: ${FACEAI_PORT:-3001}
FACEAI_FRONTEND_URL: ${FACEAI_FRONTEND_URL:-https://ai.regalamiunsorriso.it}
FACEAI_PUBLIC_BASE_URL: ${FACEAI_PUBLIC_BASE_URL:-https://ai.regalamiunsorriso.it}
FACEAI_LEGACY_RETURN_URL: ${FACEAI_LEGACY_RETURN_URL:-https://www.regalamiunsorriso.it/faceai_return.php}
FACEAI_LEGACY_HOME_URL: ${FACEAI_LEGACY_HOME_URL:-https://www.regalamiunsorriso.it}
FACEAI_SHARED_SECRET: ${FACEAI_SHARED_SECRET:-change-me}
FACEAI_SESSION_COOKIE: ${FACEAI_SESSION_COOKIE:-rus_faceai_session}
FACEAI_REDIS_URL: ${FACEAI_REDIS_URL:-redis://redis:6379}
FACEAI_QUEUE_NAME: ${FACEAI_QUEUE_NAME:-faceai-searches}
FACEAI_RUNTIME_ROOT: ${FACEAI_RUNTIME_ROOT:-/data/runtime}
FACEAI_UPLOAD_ROOT: ${FACEAI_UPLOAD_ROOT:-/data/runtime/uploads}
FACEAI_LOG_ROOT: ${FACEAI_LOG_ROOT:-/data/logs}
FACEAI_PKL_ROOT: ${FACEAI_PKL_ROOT:-/data/pkl}
FACEAI_ENABLE_LOCAL_LEGACY_STATIC: ${FACEAI_ENABLE_LOCAL_LEGACY_STATIC:-0}
volumes:
- .:/app
- ./logs:/data/logs
- ../www:/legacy-www:ro
- ../test_pkl:/data/pkl:ro
- faceai-runtime:/data/runtime
- ${FACEAI_RUNTIME_BIND:-/mnt/storage/data/faceai/runtime}:${FACEAI_RUNTIME_ROOT:-/data/runtime}
- ${FACEAI_LOG_BIND:-/mnt/storage/data/faceai/logs}:${FACEAI_LOG_ROOT:-/data/logs}
- ${FACEAI_PKL_BIND:-/mnt/nas12/nas2/RUS}:${FACEAI_PKL_ROOT:-/data/pkl}:ro
ports:
- "3001:3001"
- "${FACEAI_PUBLISHED_PORT:-3001}:${FACEAI_PORT:-3001}"
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:3001/health').then(async (response) => { const payload = await response.json().catch(() => ({})); if (!response.ok || payload.ok !== true) { console.error(JSON.stringify(payload)); process.exit(1); } }).catch((error) => { console.error(error.stack || error.message); process.exit(1); })"]
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:' + (process.env.PORT || '3001') + '/health').then(async (response) => { const payload = await response.json().catch(() => ({})); if (!response.ok || payload.ok !== true) { console.error(JSON.stringify(payload)); process.exit(1); } }).catch((error) => { console.error(error.stack || error.message); process.exit(1); })"]
interval: 10s
timeout: 5s
retries: 6
@ -48,69 +43,41 @@ services:
condition: service_healthy
processor:
build:
context: ..
dockerfile: faceai/docker/processor.Dockerfile
image: regalami-faceai-processor-local
container_name: regalami-faceai-processor
image: ${FACEAI_PROCESSOR_IMAGE:-forgejo.maddoscientisto.net/maddo/faceai-processor:latest}
container_name: ${FACEAI_PROCESSOR_CONTAINER_NAME:-regalami-faceai-processor}
restart: unless-stopped
working_dir: /app
command:
- node
- docker/run-with-log-file.mjs
- /data/logs/processor.log
- ${FACEAI_PROCESSOR_LOG_FILE:-/data/logs/processor.log}
- npm
- run
- start
- --workspace
- "@regalami/faceai-processor"
- start:processor
environment:
FACEAI_REDIS_URL: redis://redis:6379
FACEAI_QUEUE_NAME: faceai-searches
FACEAI_RUNTIME_ROOT: /data/runtime
FACEAI_LOG_ROOT: /data/logs
FACEAI_PKL_ROOT: /data/pkl
FACEAI_WORKER_CONCURRENCY: 2
FACEAI_MATCHER_BINARY: /app/bin/face_matcher
FACEAI_PROCESSOR_HEARTBEAT_INTERVAL_MS: 5000
FACEAI_PROCESSOR_HEARTBEAT_TTL_SECONDS: 20
NODE_ENV: ${NODE_ENV:-production}
FACEAI_REDIS_URL: ${FACEAI_REDIS_URL:-redis://redis:6379}
FACEAI_QUEUE_NAME: ${FACEAI_QUEUE_NAME:-faceai-searches}
FACEAI_RUNTIME_ROOT: ${FACEAI_RUNTIME_ROOT:-/data/runtime}
FACEAI_LOG_ROOT: ${FACEAI_LOG_ROOT:-/data/logs}
FACEAI_PKL_ROOT: ${FACEAI_PKL_ROOT:-/data/pkl}
FACEAI_MATCHER_BINARY: ${FACEAI_MATCHER_BINARY:-/app/bin/face_matcher}
FACEAI_WORKER_CONCURRENCY: ${FACEAI_WORKER_CONCURRENCY:-8}
FACEAI_WORKER_TIMEOUT_MS: ${FACEAI_WORKER_TIMEOUT_MS:-300000}
volumes:
- ./logs:/data/logs
- ../test_pkl:/data/pkl:ro
- faceai-runtime:/data/runtime
- ${FACEAI_RUNTIME_BIND:-/mnt/storage/data/faceai/runtime}:${FACEAI_RUNTIME_ROOT:-/data/runtime}
- ${FACEAI_LOG_BIND:-/mnt/storage/data/faceai/logs}:${FACEAI_LOG_ROOT:-/data/logs}
- ${FACEAI_PKL_BIND:-/mnt/nas12/nas2/RUS}:${FACEAI_PKL_ROOT:-/data/pkl}:ro
depends_on:
redis:
condition: service_healthy
redis:
image: redis:7-alpine
container_name: regalami-faceai-redis
image: ${FACEAI_REDIS_IMAGE:-redis:7-alpine}
container_name: ${FACEAI_REDIS_CONTAINER_NAME:-regalami-faceai-redis}
restart: unless-stopped
command: redis-server --appendonly no
command: ${FACEAI_REDIS_COMMAND:-redis-server --appendonly no}
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 12
legacy-php:
image: php:8.3-apache
container_name: regalami-legacy-php
restart: unless-stopped
environment:
FACEAI_FEATURE_ENABLED: 1
FACEAI_BACKEND_INTERNAL_URL: http://faceai:3001
FACEAI_FRONTEND_URL: http://localhost:3001
FACEAI_SHARED_SECRET: disagio-spaghetti-science-lol-boh
FACEAI_ALLOW_DEV_HANDOFF: 1
FACEAI_IDENTITY_COOKIE: rus_faceai_identity
volumes:
- ../www:/var/www/html
ports:
- "8080:80"
depends_on:
faceai:
condition: service_healthy
volumes:
faceai-runtime: