From 892d6090c7e67a4b4e71ba6c67e741cdf9eb763d Mon Sep 17 00:00:00 2001 From: Tyler Wright Date: Tue, 2 Apr 2024 13:15:18 -0600 Subject: [PATCH] remake docker files --- docker-compose.yml | 53 ++++++++++++++++------------- prod.docker-compose.yml | 52 ++++++++++++++++++++++++++++ staging.docker-compose.yml | 69 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 23 deletions(-) create mode 100644 prod.docker-compose.yml create mode 100644 staging.docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml index c3048063..0e56c084 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,12 +11,14 @@ services: timeout: 5s retries: 10 start_period: 10s + ports: + - 5432:5432 volumes: - - orecart-db-volume:/var/lib/postgresql/data + - orecart-db-dev-volume:/var/lib/postgresql/data env_file: - database.env networks: - - prod + - dev migration: container_name: orecart-migration build: ./backend @@ -27,11 +29,13 @@ services: database: condition: service_healthy networks: - - prod + - dev backend: container_name: orecart-backend build: ./backend restart: always + ports: + - 8000:8000 env_file: - backend.env healthcheck: @@ -44,26 +48,29 @@ services: migration: condition: service_completed_successfully networks: - - prod - # frontend-admin: - # container_name: orecart-frontend-admin - # build: ./frontend-admin - # restart: always - # ports: - # - 5173:5173 - # env_file: - # - frontend-admin.env - # healthcheck: - # test: ["CMD", "curl", "-f", "http://localhost:5173/"] - # interval: 30s - # timeout: 5s - # retries: 10 - # start_period: 10s - # depends_on: - # backend: - # condition: service_healthy + - dev + frontend-admin: + container_name: orecart-frontend-admin + build: ./frontend-admin + restart: always + ports: + - 5173:5173 + env_file: + - frontend-admin.env + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:5173/"] + interval: 30s + timeout: 5s + retries: 10 + start_period: 10s + depends_on: + backend: + condition: service_healthy + networks: + - dev + networks: - prod: + dev: volumes: - orecart-db-volume: {} + orecart-db-dev-volume: {} diff --git a/prod.docker-compose.yml b/prod.docker-compose.yml new file mode 100644 index 00000000..fadbd44d --- /dev/null +++ b/prod.docker-compose.yml @@ -0,0 +1,52 @@ +version: "3.9" + +services: + database: + container_name: orecart-database + image: postgres + restart: always + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 30s + timeout: 5s + retries: 10 + start_period: 10s + volumes: + - orecart-db-volume:/var/lib/postgresql/data + env_file: + - database.env + networks: + - prod + migration: + container_name: orecart-migration + build: ./backend + command: alembic upgrade head + env_file: + - backend.env + depends_on: + database: + condition: service_healthy + networks: + - prod + backend: + container_name: orecart-backend + build: ./backend + restart: always + env_file: + - backend.env + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/docs"] + interval: 30s + timeout: 5s + retries: 10 + start_period: 10s + depends_on: + migration: + condition: service_completed_successfully + networks: + - prod +networks: + prod: + +volumes: + orecart-db-volume: {} diff --git a/staging.docker-compose.yml b/staging.docker-compose.yml new file mode 100644 index 00000000..c3048063 --- /dev/null +++ b/staging.docker-compose.yml @@ -0,0 +1,69 @@ +version: "3.9" + +services: + database: + container_name: orecart-database + image: postgres + restart: always + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 30s + timeout: 5s + retries: 10 + start_period: 10s + volumes: + - orecart-db-volume:/var/lib/postgresql/data + env_file: + - database.env + networks: + - prod + migration: + container_name: orecart-migration + build: ./backend + command: alembic upgrade head + env_file: + - backend.env + depends_on: + database: + condition: service_healthy + networks: + - prod + backend: + container_name: orecart-backend + build: ./backend + restart: always + env_file: + - backend.env + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/docs"] + interval: 30s + timeout: 5s + retries: 10 + start_period: 10s + depends_on: + migration: + condition: service_completed_successfully + networks: + - prod + # frontend-admin: + # container_name: orecart-frontend-admin + # build: ./frontend-admin + # restart: always + # ports: + # - 5173:5173 + # env_file: + # - frontend-admin.env + # healthcheck: + # test: ["CMD", "curl", "-f", "http://localhost:5173/"] + # interval: 30s + # timeout: 5s + # retries: 10 + # start_period: 10s + # depends_on: + # backend: + # condition: service_healthy +networks: + prod: + +volumes: + orecart-db-volume: {}