diff --git a/build_and_run.sh b/build_and_run.sh deleted file mode 100755 index d6d50d3..0000000 --- a/build_and_run.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# Build images -docker build -t demo-frontend ../frontend -docker build -t demo-backend ../backend - -# Create network if it doesn't exist -docker network create demo-network || true - -# Start PostgreSQL -docker run -d \ - --name demo-db \ - --network demo-network \ - -e POSTGRES_DB=todo_db \ - -e POSTGRES_USER=postgres \ - -e POSTGRES_PASSWORD=postgres \ - -p 5432:5432 \ - -v postgres_data:/var/lib/postgresql/data \ - postgres:13 - -# Start Backend -docker run -d \ - --name demo-backend \ - --network demo-network \ - -e DB_NAME=todo_db \ - -e DB_USER=postgres \ - -e DB_PASSWORD=postgres \ - -e DB_HOST=demo-db \ - -e DB_PORT=5432 \ - -e DEBUG=1 \ - -p 8000:8000 \ - demo-backend - -# Start Frontend -docker run -d \ - --name demo-frontend \ - --network demo-network \ - -e VITE_API_URL=http://localhost:8000/api \ - -p 5173:5173 \ - demo-frontend diff --git a/docker-compose.yml b/docker-compose.yml index b4aa0bb..927539e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,6 @@ services: demo-db: + container_name: db image: postgres:13 volumes: - postgres_data:/var/lib/postgresql/data diff --git a/docker-compose_development.yml b/docker-compose_development.yml new file mode 100644 index 0000000..84034e0 --- /dev/null +++ b/docker-compose_development.yml @@ -0,0 +1,46 @@ +services: + demo-db: + container_name: db + image: postgres:13 + volumes: + - postgres_data:/var/lib/postgresql/data + environment: + - POSTGRES_DB=todo_db + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - "5432:5432" + + backend: + build: + context: ./backend/ + command: sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000" + ports: + - "8000:8000" + environment: + - DB_NAME=todo_db + - DB_USER=postgres + - DB_PASSWORD=postgres + - DB_HOST=db + - DB_PORT=5432 + - DEBUG=1 + volumes: + - ./backend:/app + depends_on: + - demo-db + + frontend: + build: + context: ./frontend + command: sh -c "npm run dev -- --host 0.0.0.0" + ports: + - "5173:5173" + environment: + - VITE_API_URL=http://localhost:8000/api + volumes: + - ./frontend:/app + depends_on: + - backend + +volumes: + postgres_data: