Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docker-compose.base.yml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it required to have both docker-compose.base.yml and docker-compose.yml?
It seems docker-compose,yml restates the content.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked a bit into the future with the development and production environments in mind. Maintaining this structure makes it easier to add environment-specific configurations later without having to restructure that configuration. (Core configuration, Development overrides, Production overrides).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this issue: zeton_django Issue #119

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
services:
db:
image: postgres:16
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- db

web:
build: ./zeton_django
command: python manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"
env_file:
- ./zeton_django/env_config/local.env
depends_on:
- db
- migration
healthcheck:
test: curl -s -o /dev/null localhost:8000
interval: 3s
timeout: 5s
retries: 5
networks:
- db

migration:
build: ./zeton_django
command: ["bash", "-c", "while !</dev/tcp/db/5432; do sleep 1; done; python manage.py migrate"]
depends_on:
- db
networks:
- db

react-client:
build: ./zeton_react
volumes:
- ./zeton_react/:/app/
- /app/node_modules
ports:
- 3000:3000
environment:
REACT_APP_API_URL: http://localhost:8000

volumes:
postgres_data:

networks:
db:
61 changes: 17 additions & 44 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,23 @@
version: "3.8"

services:
web:
build: ./zeton_django
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./zeton_django/:/code
ports:
- 8000:8000
env_file:
- ./zeton_django/env_config/local.env
depends_on:
- db
- migration
networks:
- db
db:
image: postgres:16
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
networks:
- db
extends:
file: docker-compose.base.yml
service: db

web:
extends:
file: docker-compose.base.yml
service: web

migration:
extends:
file: docker-compose.base.yml
service: migration

react-client:
build: ./zeton_react
volumes:
- ./zeton_react/:/app/
- /app/node_modules
ports:
- 3000:3000
environment:
REACT_APP_API_URL: http://localhost:8000
migration:
build: ./zeton_django
command: ["bash", "-c", "while !</dev/tcp/db/5432; do sleep 1; done; python zeton_django/manage.py migrate"]
volumes:
- .:/code
depends_on:
- db
networks:
- db
extends:
file: docker-compose.base.yml
service: react-client

volumes:
postgres_data:
Expand Down