From ccb48a387bcd6efd859374ce32ffb671eabf20b0 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Thu, 23 Jan 2025 10:44:37 +0800 Subject: [PATCH] feat: add network configuration to Docker compose - Define a custom network 'net1' for services - Attach services to 'net1' network - Ensure connectivity between application components This commit enhances the Docker Compose setup by introducing a custom network. This isolation can help manage service dependencies better and improve communication between services, establishing clearer boundaries. It simplifies networking configuration and lays the groundwork for further scaling if needed. --- compose.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 9f13845..a0030af 100644 --- a/compose.yaml +++ b/compose.yaml @@ -8,6 +8,8 @@ services: - DATABASE_URL=postgresql://postgres:${PG_PASSWORD}@db:5432/db - RAILS_MASTER_KEY=${RAILS_MASTER_KEY} - REDIS_URL=redis://redis:6379/0 + networks: + - net1 depends_on: - db - redis @@ -20,6 +22,8 @@ services: - DATABASE_URL=postgresql://postgres:${PG_PASSWORD}@db:5432/db - RAILS_MASTER_KEY=${RAILS_MASTER_KEY} - REDIS_URL=redis://redis:6379/0 + networks: + - net1 depends_on: - db - redis @@ -28,6 +32,8 @@ services: image: postgres:16 volumes: - ../taw_data/pg:/var/lib/postgresql/data + networks: + - net1 environment: - POSTGRES_PASSWORD=${PG_PASSWORD} - POSTGRES_DB=db @@ -36,4 +42,10 @@ services: image: redis:7-alpine volumes: - ../taw_data/redis:/data - command: redis-server --appendonly yes \ No newline at end of file + networks: + - net1 + command: redis-server --appendonly yes + +networks: + net1: + driver: bridge \ No newline at end of file