The .dodocker file is a configuration file that specifies commands to be executed inside a Docker container during the testing and validation process. It works in conjunction with taskguard to ensure consistent testing environments.
The .dodocker file is a simple text file where each line represents a shell command to be executed in sequence within the Docker container. Comments start with #.
-
Environment Setup
- taskguard automatically creates a clean Docker container
- The container is based on the specified Docker image (default:
python:3.13-slim) - The project directory is mounted into the container
-
Command Execution
- Each non-comment line in
.dodockeris executed as a shell command - Commands are executed in the order they appear
- The working directory is set to the project root
- If any command fails (non-zero exit code), execution stops immediately
- Each non-comment line in
-
Environment Variables
- All environment variables from the host are available in the container
- Additional container-specific variables are set:
CONTAINER_WORKDIR: Path to the project directory in the containerCONTAINER_ID: The ID of the running container
# Install dependencies
pip install -e .
# Run tests
pytest -v
# Run linters
black --check .
isort --check-only .
flake8
mypy .
# Test the CLI
python -m domd --help
python -m domd --version
-
Order of Commands
- Install dependencies first
- Run tests before linters
- Keep related commands together
-
Error Handling
- Each command should be idempotent when possible
- Include error handling within complex commands
- Use
|| trueto allow specific commands to fail without stopping execution
-
Performance
- Group similar commands together
- Cache dependencies between runs when possible
- Avoid unnecessary package installations
taskguard automatically detects the .dodocker file and executes its contents in a Docker container. The process is:
- taskguard starts and detects the
.dodockerfile - A Docker container is created with the project directory mounted
- Each command in
.dodockeris executed in sequence - Output is captured and displayed in the taskguard interface
- The container is automatically cleaned up after execution
Specify a custom Docker image by adding a comment at the top of the file:
# DOCKER_IMAGE=python:3.13-slim
Set environment variables for the container:
# ENV PYTHONPATH=/app
# ENV DEBUG=true
-
Permission Denied
- Ensure the container user has write permissions to mounted volumes
-
Command Not Found
- Make sure all required binaries are installed in the container
- Consider using absolute paths to binaries
-
Network Issues
- Check if the container has network access
- Ensure any required ports are exposed
- Add
set -xat the top of your commands to enable verbose output - Use
echostatements to log progress - Check taskguard logs for detailed error messages