From 229be9e4a952087e038de2c486bce36495885ee9 Mon Sep 17 00:00:00 2001 From: Pedro Lucas Garcia <190115548@aluno.unb.br> Date: Thu, 1 Aug 2024 09:05:55 -0300 Subject: [PATCH 1/7] backend: altera host do banco --- api/sigeie/docker-compose.yml | 19 ------------------- api/sigeie/settings.py | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 api/sigeie/docker-compose.yml diff --git a/api/sigeie/docker-compose.yml b/api/sigeie/docker-compose.yml deleted file mode 100644 index 2645fb73..00000000 --- a/api/sigeie/docker-compose.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: "3.9" -services: - db: - image: mysql:8.1.0 - restart: always - environment: - MYSQL_DATABASE: 'sigeie_db' - MYSQL_ROOT_PASSWORD: 'root' - container_name: sigeie_mysql_db - ports: - - "3306:3306" - volumes: - - ./data/mysql/db:/var/lib/mysql - redis: - image: redis:7.2 - restart: always - container_name: sigeie_redis_db - ports: - - "6379:6379" diff --git a/api/sigeie/settings.py b/api/sigeie/settings.py index ce84ca99..fa63a638 100644 --- a/api/sigeie/settings.py +++ b/api/sigeie/settings.py @@ -61,7 +61,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'HOST': '127.0.0.1', + 'HOST': 'db', 'PORT': '3306', 'USER': 'root', 'PASSWORD': 'root', From cbf52e10d8dbd96eca89c4b5b84c6a8471af7975 Mon Sep 17 00:00:00 2001 From: Pedro Lucas Garcia <190115548@aluno.unb.br> Date: Thu, 1 Aug 2024 09:06:28 -0300 Subject: [PATCH 2/7] backend: configura docker para usar a imagem do django --- api/docker-compose.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 api/docker-compose.yml diff --git a/api/docker-compose.yml b/api/docker-compose.yml new file mode 100644 index 00000000..64954f82 --- /dev/null +++ b/api/docker-compose.yml @@ -0,0 +1,37 @@ +version: "3.9" +services: + db: + image: mysql:8.1.0 + restart: always + environment: + MYSQL_DATABASE: 'sigeie_db' + MYSQL_ROOT_PASSWORD: 'root' + container_name: sigeie_mysql_db + ports: + - "3306:3306" + volumes: + - ./data/mysql/db:/var/lib/mysql + redis: + image: redis:7.2 + restart: always + container_name: sigeie_redis_db + ports: + - "6379:6379" + web: + build: . + restart: always + container_name: sigeie_web + command: ["python", "manage.py", "runserver", "0.0.0.0:8000"] + volumes: + - .:/app + ports: + - "8000:8000" + depends_on: + - db + - redis + environment: + - DB_HOST=db + - DB_NAME=sigeie_db + - DB_USER=root + - DB_PASSWORD=root + - REDIS_HOST=redis From f6e1f63d2a1f118023c87e61ed0824d1b593ad63 Mon Sep 17 00:00:00 2001 From: Pedro Lucas Garcia <190115548@aluno.unb.br> Date: Thu, 1 Aug 2024 09:06:49 -0300 Subject: [PATCH 3/7] backend: cria Dockerfile para a imagem do django --- api/Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 api/Dockerfile diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 00000000..3d6b28de --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.11 + +WORKDIR /app + +COPY requirements.txt /app/ + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . /app/ + +EXPOSE 8000 From 236cffde04f1c83cc56b3461e2a5249744714b90 Mon Sep 17 00:00:00 2001 From: Pedro Lucas Garcia <190115548@aluno.unb.br> Date: Thu, 1 Aug 2024 09:07:19 -0300 Subject: [PATCH 4/7] backend: cria dockerignore --- api/.dockerignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 api/.dockerignore diff --git a/api/.dockerignore b/api/.dockerignore new file mode 100644 index 00000000..354168f2 --- /dev/null +++ b/api/.dockerignore @@ -0,0 +1 @@ +data/mysql/db From 30f161c9f873dd590cb16c28e65915f2e93a37a0 Mon Sep 17 00:00:00 2001 From: Pedro Lucas Garcia <190115548@aluno.unb.br> Date: Thu, 1 Aug 2024 09:22:16 -0300 Subject: [PATCH 5/7] backend: fix bug do nome do host --- api/sigeie/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/sigeie/settings.py b/api/sigeie/settings.py index fa63a638..ce84ca99 100644 --- a/api/sigeie/settings.py +++ b/api/sigeie/settings.py @@ -61,7 +61,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'HOST': 'db', + 'HOST': '127.0.0.1', 'PORT': '3306', 'USER': 'root', 'PASSWORD': 'root', From f3d0727c1c22d4416e5758d5f77203924318f040 Mon Sep 17 00:00:00 2001 From: Pedro Lucas Garcia <190115548@aluno.unb.br> Date: Thu, 1 Aug 2024 09:37:04 -0300 Subject: [PATCH 6/7] backend: fix docker-compose e settings.py Co-authored-by: Kauan --- api/docker-compose.yml | 8 +------- api/sigeie/settings.py | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/api/docker-compose.yml b/api/docker-compose.yml index 64954f82..e38f4b8a 100644 --- a/api/docker-compose.yml +++ b/api/docker-compose.yml @@ -28,10 +28,4 @@ services: - "8000:8000" depends_on: - db - - redis - environment: - - DB_HOST=db - - DB_NAME=sigeie_db - - DB_USER=root - - DB_PASSWORD=root - - REDIS_HOST=redis + - redis \ No newline at end of file diff --git a/api/sigeie/settings.py b/api/sigeie/settings.py index ce84ca99..fa63a638 100644 --- a/api/sigeie/settings.py +++ b/api/sigeie/settings.py @@ -61,7 +61,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'HOST': '127.0.0.1', + 'HOST': 'db', 'PORT': '3306', 'USER': 'root', 'PASSWORD': 'root', From 4e28734e1a05a03b2153a22adbe1b4e5cb54a1fe Mon Sep 17 00:00:00 2001 From: Pedro Lucas Garcia <190115548@aluno.unb.br> Date: Thu, 1 Aug 2024 09:44:04 -0300 Subject: [PATCH 7/7] atualiza como subir o projeto em README.md Co-authored-by: Kauan --- README.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fdc10c32..ebdcb4be 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ SIGE IE ## Fase Release 1 ✔️ Ir para milestone da release 1 -Release 2 ✔️Ir para milestone da release 2 +Release 2 ✔️ Ir para milestone da release 2 Release 3 (atual) Ir para milestone da release 3 ## Visão geral do produto @@ -172,13 +172,13 @@ Vá para dentro da pasta raiz `api`: pip install -r requirements.txt ``` -3. Inicie o Docker, depois vá para o diretório `api/sigeie` e crie a imagem do banco de dados pela primeira vez: +3. Inicie o Docker, depois vá para o diretório `api` e crie a imagem do banco de dados e da api pela primeira vez: ``` - docker-compose up -d + docker-compose up --build ``` -4. Ainda no mesmo terminal, retorne para o diretório raiz `api` e aplique as migrações: +4. Em outro terminal, retorne para o diretório raiz `api` e aplique as migrações: ``` python manage.py makemigrations @@ -188,12 +188,6 @@ Vá para dentro da pasta raiz `api`: python manage.py migrate ``` -5. Inicie o servidor: - - ``` - python manage.py runserver - ``` - Pronto, o servidor já está rodando com o banco de dados configurado. ##### Pela segunda vez @@ -210,7 +204,7 @@ Garanta que não haja nenhum processo que use o porto 8080, 3306 e 6379. Por fim - Atualizar as dependências, fazer as migrações e iniciar o servidor: ``` - source venv/bin/activate && pip install -r requirements.txt && python manage.py makemigrations && python manage.py migrate && python manage.py runserver + source venv/bin/activate && python manage.py makemigrations && python manage.py migrate ``` Isso é tudo, pessoal.