From 154174a2c13832bfc09c6baf890c7541c9f5c32a Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Mon, 5 May 2025 15:23:00 +0330 Subject: [PATCH] create compose file for all services --- .env.example | 23 +++++++++ .gitignore | 3 ++ docker-compose.yml | 117 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..763d84b --- /dev/null +++ b/.env.example @@ -0,0 +1,23 @@ +PROJECT_NAME="" + +LARAVEL_PROJECT_PATH="./laravel" + +POSTGRES_USER="" +POSTGRES_DB="" +POSTGRES_PASSWORD="" + +NOTIFICATION_SERVER_PATH="" +NOTIFICATION_SERVER_DB="" +NOTIFICATION_SERVER_USER="" +NOTIFICATION_SERVER_PASSWORD="" +NOTIFICATION_SERVER_DB_SSL="" +NOTIFICATION_SERVER_DB_SYNC="" +NOTIFICATION_SERVER_PORT="" + +REDIS_HOST="" +REDIS_PORT="" + +NEXT_JS_PATH="" +NEXT_PUBLIC_VERSION="" +NEXT_PUBLIC_API_URL="" +NEXT_PUBLIC_SERVER_SOCKET_URL="" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3e701e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env +.idea +data \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5175841 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,117 @@ +services: + backend_db: + image: postgres:17-alpine3.21 + container_name: backend_db + tty: true + ports: + - "8050:5432" + environment: + POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + volumes: + - ./data:/var/lib/postgresql/data + profiles: + - server + networks: + - crm_network + + + notification_db: + image: postgres:17-alpine3.21 + container_name: notification_db + tty: true + ports: + - "8070:5432" + environment: + POSTGRES_DB: ${NOTIFICATION_SERVER_DB} + POSTGRES_USER: ${NOTIFICATION_SERVER_USER} + POSTGRES_PASSWORD: ${NOTIFICATION_SERVER_PASSWORD} + volumes: + - ./notification:/var/lib/postgresql/data + profiles: + - server + networks: + - crm_network + + redis: + image: redis:7-alpine3.21 + container_name: redis + restart: unless-stopped + tty: true + profiles: + - server + networks: + - crm_network + + laravel: + build: + context: ${LARAVEL_PROJECT_PATH} + dockerfile: Dockerfile + container_name: ${PROJECT_NAME} + tty: true + ports: + - "9000:9000" + volumes: + - ./laravel:/var/www/crm + profiles: + - server + networks: + - crm_network + depends_on: + - backend_db + + + notification_server: + build: + context: ${NOTIFICATION_SERVER_PATH} + dockerfile: Dockerfile + container_name: notification_server + environment: + - NODE_ENV=production + - DB_HOST=notification_db + - DB_PORT=5432 + - DB_USERNAME=${NOTIFICATION_SERVER_USER} + - DB_PASSWORD=${NOTIFICATION_SERVER_PASSWORD} + - DB_DATABASE=${NOTIFICATION_SERVER_DB} + - DB_SSL=${NOTIFICATION_SERVER_DB_SSL} + - DB_SYNC=${NOTIFICATION_SERVER_DB_SYNC} + - PORT=${NOTIFICATION_SERVER_PORT} + - REDIS_HOST=${REDIS_HOST} + - REDIS_PORT=${REDIS_PORT} + ports: + - "3023:${NOTIFICATION_SERVER_PORT}" + volumes: + - ${NOTIFICATION_SERVER_PATH}:/var/www/crm-notification-server + profiles: + - server + networks: + - crm_network + depends_on: + - backend_db + - laravel + - notification_db + - redis + + nextjs: + build: + context: ${NEXT_JS_PATH} + dockerfile: Dockerfile + container_name: nextjs + environment: + - NEXT_PUBLIC_VERSION=${NEXT_PUBLIC_VERSION} + - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} + - NEXT_PUBLIC_SERVER_SOCKET_URL=${NEXT_PUBLIC_SERVER_SOCKET_URL} + ports: + - "3000:3000" + env_file: + - .env.local + restart: unless-stopped + profiles: + - server + networks: + - crm_network + +networks: + crm_network: + driver: bridge \ No newline at end of file