Skip to content

Commit

Permalink
application dockerized
Browse files Browse the repository at this point in the history
  • Loading branch information
davijonm committed Jan 12, 2024
1 parent a18fe6d commit 963dfb4
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use a imagem base do Python
FROM python:3.11

# Configuração do diretório de trabalho
WORKDIR /mnt/code

# Copie os arquivos de requisitos para o contêiner
COPY requirements.txt .

# Instale as dependências
RUN pip install --no-cache-dir -r requirements.txt

# Copie o código-fonte do Django para o contêiner
COPY backend ./backend

# Executar o servidor na inicialização do container e aguardar 3s para o db inicializar antes
CMD ["sh", "-c", "sleep 3 && python manage.py runserver 0.0.0.0:8000"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# In development

## Application builded with Django, React and PostgreSQL

## For local installation

***In the backend directory, create a new vitual environment using venv***

python -m venv venv

***Activate the environment***

source venv/bin/activate

***Install the dependencies that django needs***

pip install -r ../requirements.txt

## For dockerized installation

***Create the environment variables in a file .env***

***Build the images and the containers***

docker compose build
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3.9'

services:

db:
image: postgres:latest
ports:
- "5432:5432"
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data

api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
depends_on:
- db
env_file:
- .env
volumes:
- ./backend:/mnt/code

volumes:
postgres_data:
3 changes: 2 additions & 1 deletion backend/requirements.text → requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Django==5.0.1
django-cors-headers==4.3.1
djangorestframework==3.14.0
pytz==2023.3.post1
sqlparse==0.4.4
sqlparse==0.4.4
psycopg2-binary==2.9.9

0 comments on commit 963dfb4

Please sign in to comment.