From 19588dd914b303b9adc5eab3ccb756e04529ea33 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Wed, 25 Feb 2026 18:30:05 +0000 Subject: [PATCH] Use host Redis and PostgreSQL instead of containerized Server already has Redis and PostgreSQL running. Worker uses network_mode: host to connect directly, no port conflicts. Co-Authored-By: Claude Opus 4.6 --- docker-compose.prod.yml | 55 ++++++----------------------------------- 1 file changed, 8 insertions(+), 47 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index f845f48..ca57888 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,26 +1,22 @@ -# Production Docker Compose — worker + Redis + PostgreSQL only -# Apache on host serves PHP + frontend files natively -# Redis/PostgreSQL ports exposed to localhost for api.php access +# Production Docker Compose — worker only +# Uses host Redis + PostgreSQL (already running on server) +# Apache/Nginx on host serves PHP + frontend files natively services: worker: build: context: . dockerfile: Dockerfile.worker + network_mode: host volumes: - ${WEB_DIR:-/var/www/html/pdf-accessibility}/uploads:/app/uploads - ${WEB_DIR:-/var/www/html/pdf-accessibility}/results:/app/results - ./logs:/app/logs - depends_on: - redis: - condition: service_healthy - postgres: - condition: service_healthy environment: - - REDIS_HOST=redis - - REDIS_PORT=6379 - - DB_HOST=postgres - - DB_PORT=5432 + - REDIS_HOST=${REDIS_HOST:-127.0.0.1} + - REDIS_PORT=${REDIS_PORT:-6379} + - DB_HOST=${DB_HOST:-127.0.0.1} + - DB_PORT=${DB_PORT:-5432} - DB_NAME=${DB_NAME:-pdf_checker} - DB_USER=${DB_USER:-pdf_checker} - DB_PASSWORD=${DB_PASSWORD:-dev_password} @@ -29,38 +25,3 @@ services: deploy: replicas: ${WORKER_COUNT:-2} restart: unless-stopped - - redis: - image: redis:7-alpine - ports: - - "127.0.0.1:${REDIS_PORT:-6380}:6379" - volumes: - - redis-data:/data - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 10s - timeout: 3s - retries: 3 - restart: unless-stopped - - postgres: - image: postgres:16-alpine - ports: - - "127.0.0.1:${DB_PORT:-5433}:5432" - volumes: - - pg-data:/var/lib/postgresql/data - - ./db/init.sql:/docker-entrypoint-initdb.d/init.sql - environment: - POSTGRES_DB: ${DB_NAME:-pdf_checker} - POSTGRES_USER: ${DB_USER:-pdf_checker} - POSTGRES_PASSWORD: ${DB_PASSWORD:-dev_password} - healthcheck: - test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-pdf_checker}"] - interval: 10s - timeout: 3s - retries: 3 - restart: unless-stopped - -volumes: - redis-data: - pg-data: