I want to create a design for utilizing Poetry within a Docker environment. During development, I want to have separate directories for PyTest test files (tests/
) and Sphinx documentation (docs/
) on the host machine, rather than including them directly in the Docker image. Is there a way I could run tests for the Python files within the Docker image and create auto-updating documentation from Sphinx, which is only present on the host machine?
Context:
I am utilizing Docker for my development environment and Poetry for dependency management. My goal is to establish a workflow where the PyTest test files and Sphinx documentation directories remain on the host machine, while the actual code and dependencies are contained within the Docker image. This approach allows for easier test execution within the Docker environment and ensures that Sphinx generates up-to-date documentation without the need to rebuild the entire Docker image.
Directory Structure:
Host Machine:
├── project/
│ ├── code/
│ │ ├── file1.py
│ │ ├── file2.py
│ │ └── ...
│ ├── tests/
│ │ ├── test_file1.py
│ │ ├── test_file2.py
│ │ └── ...
│ └── docs/
│ ├── conf.py
│ ├── index.rst
│ ├── ...
│ └── ...
└── Dockerfile
Docker Machine:
├── code/
│ ├── file1.py
│ ├── file2.py
│ └── ...
└── Dockerfile
Specifically, I would like to know:
- How can I run PyTest tests against the Python code within the Docker image, while keeping the test files (
tests/
) on the host machine? - Is there a way to configure Sphinx to generate the documentation from the Sphinx source files (
docs/
) on the host machine, without including them in the Docker image? - What would be the recommended setup and workflow for achieving this combination of Docker, Poetry, PyTest, and Sphinx in terms of file organization and command configurations?
I appreciate any guidance or suggestions on how to design this development environment to meet these requirements.
Aucun commentaire:
Enregistrer un commentaire