Skip to content

Commit

Permalink
Fix the docker compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Mar 27, 2024
1 parent ad9c573 commit 9f5b635
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 89 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
73 changes: 23 additions & 50 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 10 additions & 10 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
40 changes: 23 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

0 comments on commit 9f5b635

Please sign in to comment.