-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Contexto
Atualmente, montamos um volume no contêiner da api contendo o código do repositório, para refletir as mudanças em tempo real durante o desenvolvimento:
volumes: [.:/app, $HOME/.basedosdados/credentials:/app/credentials:ro]Porém, isso gera algumas complicações, como por exemplo, a necessidade de regerar os arquivos estáticos novamente no nosso script `start-server-dev.sh:
# The compose.yaml file mounts our repository as a volume in the /app folder,
# which overwrites the static files collected during image build.
# So we need to collect the static files again at runtime.
echo "> Collecting static files"
(cd /app; python manage.py collectstatic --no-input --settings=backend.settings.base)Proposta
Podemos utilizar o Compose Watch para refletir as mudanças no código, eliminando a necessidade de montar volumes no contêiner e sobrescrever os arquivos criados durante o build da imagem. Exemplo:
api:
build: .
command: poetry run /app/start-server-dev.sh
env_file: .env
develop:
# Live-reload configuration for local development
watch:
# Sync the working directory with the `/app` directory in the container
- action: sync
path: .
target: /app
# Exclude the host virtual environment (if any) to avoid
# platform mismatches and invalid symlinks
ignore:
- .venv/
# Rebuild the image when dependencies change
- action: rebuild
path: ./poetry.lock
ports:
...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels