This repository includes Docker configuration for development, testing, and deployment.
docker-compose run testdocker-compose run devThen inside the container:
python calculator.py
pytest
ruff check .
black .docker-compose run lintBuild the Docker image:
docker build -t sandbox:latest .docker-compose up testdocker-compose run -it dev bashdocker-compose up lintThe Dockerfile uses a multi-stage build:
- Builder stage: Installs Python dependencies
- Production stage: Strips down to essentials, adds security (non-root user), and includes a health check
- Python 3.13-slim base image (minimal, ~150MB)
- Non-root user (
appuser) for security - Health check validates calculator functionality
- Default command runs pytest
| Service | Purpose |
|---|---|
dev |
Interactive development shell with mounted volumes |
test |
Runs pytest with verbose output |
lint |
Runs ruff, black, and other checks |
Remove containers and images:
docker-compose down
docker image rm sandbox:latestSet PYTHONUNBUFFERED=1 to see real-time output from Python applications.
- Volume mounts allow live code editing reflected in containers
__pycache__is excluded to prevent host/container conflicts- Multi-stage build reduces final image size
- Health check ensures application stability in production