From a2b37d99c4b413823b0abb0f7731b2641c5c8382 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Fri, 23 Oct 2026 20:32:18 +0500 Subject: [PATCH] Refactored Docker Compose: updated service names, adjusted build contexts and targets, added missing environment variables, and updated volumes for consistency across development and production. --- docker-compose-prod.yml | 47 ++++++++++++++++++++++++----------------- docker-compose.yml | 37 ++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index 500d65e..da3cab8 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -1,60 +1,68 @@ -version: '3.7' +#version: '3.7' services: - nginx: + web: build: - context: ./nginx - dockerfile: Dockerfile - # restart: always + context: app + dockerfile: docker/Dockerfile + target: WEB_PRODUCTION + # restart: always depends_on: - app - - swagger ports: - - ${DOCKER_NGINX_PORT}:80 + - ${DOCKER_WEB_PORT}:80 + environment: + IS_GZIP: 1 + # FRONTEND_PORT: ${DOCKER_WEB_PORT} + BACKEND_HOST: app + BACKEND_PORT: 9000 + TRUSTED_PROXY_CIDR: 172.16.0.0/12 + # Enable swagger + ENABLE_API_DOCS: 1 + volumes: + - ./app/application/public:/usr/share/nginx/html + - ./app/application/storage/app/public:/usr/share/nginx/html/storage app: build: context: app dockerfile: docker/Dockerfile - target: PRODUCTION + target: APP_PRODUCTION # restart: always -# cap_drop: -# - ALL -# cap_add: -# - SETGID -# - SETUID -# - CHOWN -# - FOWNER depends_on: - db - redis - reverb env_file: app/application/.env + volumes: + - ./app/application:/var/www/html environment: CONTAINER_ROLE: app - UNIT_SOURCE: '"172.16.0.0/12"' + APP_ENV: production queue: build: context: app dockerfile: docker/Dockerfile - target: PRODUCTION + target: APP_PRODUCTION # restart: always depends_on: - db - redis environment: CONTAINER_ROLE: queue + APP_ENV: production volumes: - ./app/application:/var/www/html reverb: build: context: app dockerfile: docker/Dockerfile - target: PRODUCTION + target: APP_PRODUCTION # restart: always depends_on: - db - redis environment: CONTAINER_ROLE: websockets + APP_ENV: production ports: - ${DOCKER_WEBSOCKET_PORT}:9000 volumes: @@ -63,13 +71,14 @@ services: build: context: app dockerfile: docker/Dockerfile - target: PRODUCTION + target: APP_PRODUCTION # restart: always depends_on: - db - redis environment: CONTAINER_ROLE: scheduler + APP_ENV: production volumes: - ./app/application:/var/www/html swagger: diff --git a/docker-compose.yml b/docker-compose.yml index ffbad99..bd4718d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,32 +1,47 @@ -version: '3.7' +#version: '3.7' services: web: - image: nginx:alpine3.18-slim - volumes: - - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf - ports: - - ${DOCKER_NGINX_PORT}:80 + build: + context: app + dockerfile: docker/Dockerfile + target: WEB_DEVELOP depends_on: - db - redis - app - reverb + ports: + - ${DOCKER_WEB_PORT}:80 + environment: + IS_GZIP: 0 + FRONTEND_PORT: ${DOCKER_WEB_PORT} + BACKEND_HOST: app + BACKEND_PORT: 9000 + # Enable swagger + ENABLE_API_DOCS: 1 + # TRUSTED_PROXY_CIDR: 172.16.0.0/12 + volumes: + - ./app/application/public:/usr/share/nginx/html + - ./app/application/storage/app/public:/usr/share/nginx/html/storage app: build: context: app dockerfile: docker/Dockerfile - target: DEVELOP + target: APP_DEVELOP depends_on: - db - redis - reverb volumes: - ./app/application:/var/www/html + environment: + CONTAINER_ROLE: app + APP_ENV: local queue: build: context: app dockerfile: docker/Dockerfile - target: DEVELOP + target: APP_DEVELOP depends_on: - db - redis @@ -38,7 +53,7 @@ services: build: context: app dockerfile: docker/Dockerfile - target: DEVELOP + target: APP_DEVELOP depends_on: - db - redis @@ -52,7 +67,7 @@ services: build: context: app dockerfile: docker/Dockerfile - target: DEVELOP + target: APP_DEVELOP depends_on: - db - redis @@ -107,4 +122,4 @@ services: target: NPM user: "${UID}:${GID}" volumes: - - ./app/application:/var/www/html + - ./app/application:/var/www/html \ No newline at end of file