Refactor Docker Compose configuration to enhance network management

- Removed network_mode settings for services and replaced them with a dedicated portal-network.
- Ensured all services are connected to the new bridge network for improved communication and organization.
This commit is contained in:
T. Narantuya 2025-08-29 18:33:30 +09:00
parent 8b855ca371
commit 638638ea89

View File

@ -6,9 +6,10 @@ services:
frontend: frontend:
image: portal-frontend:latest image: portal-frontend:latest
container_name: portal-frontend container_name: portal-frontend
network_mode: bridge
ports: ports:
- "127.0.0.1:3000:3000" # Only accessible from localhost for security - "127.0.0.1:3000:3000"
networks:
- portal-network
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- PORT=3000 - PORT=3000
@ -27,9 +28,10 @@ services:
backend: backend:
image: portal-backend:latest image: portal-backend:latest
container_name: portal-backend container_name: portal-backend
network_mode: bridge
ports: ports:
- "127.0.0.1:4000:4000" - "127.0.0.1:4000:4000"
networks:
- portal-network
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- PORT=4000 - PORT=4000
@ -76,9 +78,8 @@ services:
database: database:
image: postgres:17-alpine image: postgres:17-alpine
container_name: portal-database container_name: portal-database
network_mode: bridge networks:
ports: - portal-network
- "127.0.0.1:5432:5432" # Only accessible from localhost for security
environment: environment:
- POSTGRES_DB=${POSTGRES_DB} - POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER} - POSTGRES_USER=${POSTGRES_USER}
@ -96,9 +97,8 @@ services:
cache: cache:
image: redis:7-alpine image: redis:7-alpine
container_name: portal-cache container_name: portal-cache
network_mode: bridge networks:
ports: - portal-network
- "127.0.0.1:6379:6379" # Only accessible from localhost for security
volumes: volumes:
- redis_data:/data - redis_data:/data
restart: unless-stopped restart: unless-stopped
@ -113,3 +113,8 @@ volumes:
driver: local driver: local
redis_data: redis_data:
driver: local driver: local
networks:
portal-network:
driver: bridge
name: portal-network