From 552a153fdf86e27bde498eb49de1afb0dbfc5725 Mon Sep 17 00:00:00 2001 From: zwnk Date: Thu, 16 Jan 2025 22:00:22 -0300 Subject: [PATCH] finally fixed ... --- dc_files/build_and_run.sh | 40 +++++++++++++++++++ .../docker-compose.override.yml | 0 .../docker-compose_ssh_git.yml | 0 docker-compose.yml | 9 +++-- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100755 dc_files/build_and_run.sh rename docker-compose.override.yml => dc_files/docker-compose.override.yml (100%) rename docker-compose_ssh_git.yml => dc_files/docker-compose_ssh_git.yml (100%) diff --git a/dc_files/build_and_run.sh b/dc_files/build_and_run.sh new file mode 100755 index 0000000..d6d50d3 --- /dev/null +++ b/dc_files/build_and_run.sh @@ -0,0 +1,40 @@ +#!/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.override.yml b/dc_files/docker-compose.override.yml similarity index 100% rename from docker-compose.override.yml rename to dc_files/docker-compose.override.yml diff --git a/docker-compose_ssh_git.yml b/dc_files/docker-compose_ssh_git.yml similarity index 100% rename from docker-compose_ssh_git.yml rename to dc_files/docker-compose_ssh_git.yml diff --git a/docker-compose.yml b/docker-compose.yml index 98aa1cb..b9ddce9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,6 @@ services: db: + container_name: demo-db image: postgres:13 volumes: - postgres_data:/var/lib/postgresql/data @@ -12,8 +13,8 @@ services: backend: build: - context: ../backend/ - dockerfile: Dockerfile + context: ${PWD}/../backend/ + # dockerfile: Dockerfile # entrypoint: ["${PWD}/../backend/entrypoint.sh"] command: sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000" ports: @@ -30,8 +31,8 @@ services: frontend: build: - context: ../frontend - dockerfile: Dockerfile + context: ${PWD}/../frontend + # dockerfile: Dockerfile # entrypoint: ["${PWD}/../frontend/entrypoint.sh"] command: sh -c "npm run dev -- --host 0.0.0.0" ports: