Docker-based Development (Optional)¶
This method provides a containerized environment using Docker and Docker Compose. It can be useful for ensuring consistency across different machines or isolating dependencies.
However, be aware that:
- It bypasses the built-in Python hot-reloading mechanism in favor of Docker's file synchronization (
develop: watch:
), which can sometimes be less reliable or performant depending on your OS and Docker setup. - Running commands requires executing them inside the container using
docker exec
.
Docker Setup Overview:
docker-compose.yml
: Defines the base configuration, primarily intended for production deployments.docker-compose.dev.yml
: Contains overrides specifically for local development. It:- Uses the
dev
stage from theDockerfile
. - Enables file watching/synchronization via
develop: watch:
. Dockerfile
: A multi-stage Dockerfile defining the build process for different environments (development, production).
Starting the Docker Environment:
-
Build Images (First time or after Dockerfile/dependency changes): Use the
tux
CLI wrapper for Docker Compose commands. -
Run Services:
Bash# Start services using development overrides poetry run tux --dev docker up # Rebuild images before starting if needed poetry run tux --dev docker up --build # Start in detached mode (background) poetry run tux --dev docker up -d
This uses
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
. Thedevelop: watch:
feature attempts to sync code changes from your host into the running container. The container entrypoint runspoetry run prisma generate
followed bypoetry run tux --dev start
.
Stopping the Docker Environment:
Interacting with Docker Environment:
All interactions (running the bot, database commands, quality checks) must be executed inside the app
service container.
-
View Logs:
-
Open a Shell inside the Container:
From within this shell, you can run
poetry run tux ...
commands directly. -
Database Commands (via Docker
exec
): -
Linting/Formatting/Type Checking (via Docker
exec
):