diff --git a/Makefile b/Makefile index d60f6b5d..69359c71 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,10 @@ drop-mysql: ## stops the mysql dev project $(error MySQL is not supported) stop-psql: ## stops the psql dev project - docker compose -f docker-compose.yml down -t 60 + docker compose down -t 60 drop-psql: ## stops the psql dev project - docker compose -f docker-compose.yml down -v -t 60 + docker compose down -v -t 60 stop-prod: ## stops the mysql dev project docker compose -f docker-compose.prod.yml down -t 60 @@ -44,10 +44,10 @@ upd-mysql: ## run the project with mysql in detached mode $(error MySQL is not supported) up-psql: ## run the project with psql - docker compose -f docker-compose.yml up --build + docker compose up --build upd-psql: ## run the project with psql in detached mode - docker compose -f docker-compose.yml up -d --build + docker compose up -d --build up-prod: ## run the project with mysql docker compose -f docker-compose.prod.yml up --build @@ -65,23 +65,23 @@ build-prod: --build-arg $$(cat .env.prod | grep REACT_APP_DJANGO_API_ENDPOINT) ### Using the SQLite database -run-sqlite: +run-sqlite: $(error SQLite is not supported) ## run the project with sqlite and stop the mysql project beforehand -rund-sqlite: +rund-sqlite: $(error SQLite is not supported) ## run the project with sqlite in detached mode and stop the mysql project beforehand -redo-sqlite: +redo-sqlite: $(error SQLite is not supported) ## delete the db and rerun the project with sqlite -redod-sqlite: +redod-sqlite: $(error SQLite is not supported) ## delete the db and rerun the project with sqlite in detached mode ### Using the MySQL database -run-mysql: +run-mysql: $(error SQLite is not supported) ## run the project with mysql and stop the sqlite project beforehand -rund-mysql: +rund-mysql: $(error SQLite is not supported) ## run the project with mysql in detached mode and stop the sqlite project beforehand -redo-mysql: +redo-mysql: $(error SQLite is not supported) ## delete the db and rerun the project with mysql -redod-mysql: +redod-mysql: $(error SQLite is not supported) ## delete the db and rerun the project with mysql in detached mode ### Using the PostgreSQL database diff --git a/docker-compose.base.yml b/docker-compose.base.yml index 5c347f4c..45ac6b7b 100644 --- a/docker-compose.base.yml +++ b/docker-compose.base.yml @@ -1,66 +1,39 @@ services: - backend_base: - container_name: seismic_backend_dev - env_file: - - .env - environment: - - "PYTHONUNBUFFERED=1" - restart: on-failure - - backend_dev_base: - extends: - service: backend_base - build: - context: . - dockerfile: ./docker/dockerfiles/Dockerfile.backend.dev + db_base_psql: + container_name: seismic_db_dev + image: postgres:16.2 volumes: - - ./api:/var/www/seismic/api - - ./client/src:/var/www/seismic/client/src + - seismic_psql:/var/lib/postgresql/data env_file: - .env environment: - - "ENVIRONMENT=development" + POSTGRES_DB: "${DATABASE_NAME}" + POSTGRES_USER: "${DATABASE_USER}" + POSTGRES_PASSWORD: "${DATABASE_PASSWORD}" + restart: always ports: - - "${WEBAPP_PORT:-8080}:8000" - - "${CLIENT_PORT:-3000}:3000" - - client_base: - container_name: seismic_client_dev - env_file: - - .env - restart: on-failure + - "${DATABASE_PORT:-5432}:5432" - client_dev_base: - build: - context: ./ - dockerfile: ./docker/dockerfiles/Dockerfile.frontend.dev - args: - - ENVIRONMENT=development + backend_base: + container_name: seismic_backend_dev env_file: - .env environment: ENVIRONMENT: "development" - volumes: - - ./client:/code - ports: - - "${CLIENT_PORT:-3030}:3000" - - db_base: - container_name: seismic_db_dev - env_file: - - .env - restart: always - - db_base_psql: - extends: - service: db_base - image: postgres:16.2 - volumes: - - seismic_psql:/var/lib/postgresql/data - environment: + DATABASE_ENGINE: "postgresql" + DATABASE_HOST: "seismic_db_dev" + DATABASE_PORT: "5432" DATABASE_NAME: "${DATABASE_NAME}" DATABASE_USER: "${DATABASE_USER}" DATABASE_PASSWORD: "${DATABASE_PASSWORD}" + PYTHONUNBUFFERED: "1" ports: - - "${DATABASE_PORT:-5432}:5432" + - "${WEBAPP_PORT:-8030}:8000" + restart: on-failure + + client_base: + container_name: seismic_client_dev + env_file: + - .env + restart: on-failure diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index fc778f5c..298a4e9e 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -2,7 +2,14 @@ name: seismic_multi services: + db: + extends: + file: docker-compose.base.yml + service: db_base_psql + container_name: seismic_db + backend: + container_name: seismic_backend extends: file: docker-compose.base.yml service: backend_base @@ -11,12 +18,8 @@ services: dockerfile: ./docker/dockerfiles/Dockerfile.backend volumes: - ./api/media:/var/www/seismic/api/media - environment: - - "ENVIRONMENT=production" - ports: - - "${WEBAPP_PORT:-8080}:80" depends_on: - - db_psql + - db client: extends: @@ -29,11 +32,8 @@ services: - "ENVIRONMENT=production" ports: - "${CLIENT_PORT:-3030}:80" - - db_psql: - extends: - file: docker-compose.base.yml - service: db_base_psql + depends_on: + - backend volumes: seismic_psql: diff --git a/docker-compose.yml b/docker-compose.yml index e223bdcd..332d7ef9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,32 +2,38 @@ name: seismic_dev services: - backend_psql: + db: extends: file: docker-compose.base.yml - service: backend_dev_base - environment: - - "DATABASE_ENGINE=postgresql" - - "DATABASE_HOST=db_psql_dev" - - "DATABASE_PORT=5432" - depends_on: - - db_psql_dev + service: db_base_psql - client_dev: + backend: extends: file: docker-compose.base.yml - service: client_dev_base - environment: - - "ENVIRONMENT=development" - ports: - - "${CLIENT_PORT:-3030}:3000" + service: backend_base + build: + context: . + dockerfile: ./docker/dockerfiles/Dockerfile.backend.dev + volumes: + - ./api:/var/www/seismic/api + depends_on: + - db - db_psql_dev: + client: extends: file: docker-compose.base.yml - service: db_base_psql + service: client_base + build: + context: ./ + dockerfile: ./docker/dockerfiles/Dockerfile.frontend.dev + args: + - ENVIRONMENT=development + ports: + - "${CLIENT_PORT:-3030}:3000" volumes: - - ./docker/init-psql:/docker-entrypoint-initdb.d + - ./client:/code + depends_on: + - backend volumes: seismic_psql: