From 37a890413c3595e89b3357ce013613d6c48712af Mon Sep 17 00:00:00 2001 From: djeck1432 Date: Sun, 1 Dec 2024 17:10:06 +0100 Subject: [PATCH 1/2] rework docker-compose.dev --- docker-compose.dev.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 377478e8..73507ba7 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -10,13 +10,11 @@ services: container_name: backend_dev volumes: - ./entrypoint.sh:/app/entrypoint.sh - - .:/app # Mount the entire project for easy code updates + - .:/app env_file: - - .env.dev # Use a different environment file for local development - expose: - - "8000" + - .env.dev ports: - - "8000:8000" # Expose backend to localhost + - "8000:8000" networks: - app_network depends_on: @@ -41,9 +39,9 @@ services: networks: - app_network ports: - - "${DB_PORT:-5432}:5432" # Use environment variable for port mapping + - "5432:5432" healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] + test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 @@ -63,4 +61,4 @@ services: - backend volumes: - postgres_data_dev: \ No newline at end of file + postgres_data_dev: From 31a68edd149e1e70d9b8cb91b7be7496aa191df5 Mon Sep 17 00:00:00 2001 From: djeck1432 Date: Sun, 1 Dec 2024 17:10:15 +0100 Subject: [PATCH 2/2] add docker-compose.back --- docker-compose.back.yaml | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docker-compose.back.yaml diff --git a/docker-compose.back.yaml b/docker-compose.back.yaml new file mode 100644 index 00000000..422187e4 --- /dev/null +++ b/docker-compose.back.yaml @@ -0,0 +1,52 @@ +version: '3.8' + +networks: + app_network: + driver: bridge + +services: + backend: + build: . + container_name: backend_dev + volumes: + - ./entrypoint.sh:/app/entrypoint.sh + - .:/app + env_file: + - .env.dev + expose: + - "8000" + ports: + - "8000:8000" + networks: + - app_network + depends_on: + - db + environment: + - DB_HOST=db + - DB_PORT=5432 + - DB_NAME=spotnet + - DB_USER=postgres + - DB_PASSWORD=password + + db: + image: postgres:14 + container_name: postgres_dev + environment: + POSTGRES_DB: spotnet + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + volumes: + - postgres_data_dev:/var/lib/postgresql/data + - ./init-db:/docker-entrypoint-initdb.d + networks: + - app_network + ports: + - "${DB_PORT:-5432}:5432" + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + postgres_data_dev: