Skip to content

Commit

Permalink
Adicionado postgres como banco para desenvolvimento
Browse files Browse the repository at this point in the history
close #8
  • Loading branch information
renzo authored and renzon committed Jul 12, 2024
1 parent 40a0e50 commit 2c04da1
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16.3
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports: [ '5432:5432' ]

defaults:
run:
working-directory: backend # Set the global working directory
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ ENV/
env.bak/
venv.bak/

#Postgres local volume
docker/.pgdata/


# Spyder project settings
.spyderproject
.spyproject
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ Template de projeto Django com as boas práticas da DevPro
## Princípios

1. A organização de pastas deve ser clara. Seus nomes devem deixar claro do que se trata essa porção de projeto.
2. Idealmente cada pasta deve possuir um Readme para explicar sua organização e funcionamento
1. Idealmente cada pasta deve possuir um Readme para explicar sua organização e funcionamento

## Pastas do projeto

Na pasta raiz se encontra a pasta backend. Dentro dela se encontram os arquivos respectivos ao backend feito em Django.
Na pasta raiz se encontram:

1. A pasta backend. Dentro dela se encontram os arquivos respectivos ao backend feito em Django.
1. A pasta docker. Nela se encontram os arquivos de conteinerização usando docker.
1. A pasta config. Nela se encontra um arquivo de configuração para o projeto.


10 changes: 7 additions & 3 deletions backend/devpro/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "postgres",
"USER": "postgres",
"PASSWORD": "postgres",
"HOST": "localhost",
"PORT": "5432",
}
}

Expand Down
24 changes: 23 additions & 1 deletion backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.12"
django = ">4"
psycopg2 = "^2.9.9"


[tool.poetry.group.dev]
Expand Down
1 change: 1 addition & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Pasta de configurações
13 changes: 13 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Pasta de Arquivos docker

Nessa pasta está o arquivo docker-compose.yml.

Ele possui um postgres para execução do ambiente local. Por padrão ele roda com configurações padrão da imagem do Posgres:
Usuário e senha: postgres
Porta: 5432

Para rodar, navegue até o diretório docker e rode o comando:

```bash
docker compose up -d
```
14 changes: 14 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.3"

services:
database:
container_name: postgres
image: postgres:16.3
volumes:
- ./.pgdata:/var/lib/postgresql/data
environment:
- LC_ALL=C.UTF-8
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
ports:
- 5432:5432

0 comments on commit 2c04da1

Please sign in to comment.