My poetry configuration is as follows. When executing poetry build, the .venv folder cannot be included in the tar.gz package.
include = [
{ path = ".venv", format = "sdist" },
{ path = "docker", format = "sdist" },
{ path = "env", format = "sdist" },
{ path = "logging.conf", format = "sdist" },
{ path = "poetry.lock", format = "sdist" },
{ path = "poetry.toml", format = "sdist" },
]
Requirement: Use poetry build
to build a tar package with .venv using Poetry at CI/CD, copy the tar package into a Docker container, and start the project using poetry run start
.
Environment: Both CI/CD and Kubernetes Docker are using CentOS 7.
Common Practice: After CI/CD Poetry build, copy .venv and related project code and configurations into the Docker container.
Question: CI/CD needs additional configuration. Since Poetry has the package/include functionality, can the above configuration code be placed in pyproject.toml as follows:
include = [
{ path = ".venv", format = "sdist" },
{ path = "docker", format = "sdist" },
{ path = "env", format = "sdist" },
{ path = "logging.conf", format = "sdist" },
{ path = "poetry.lock", format = "sdist" },
{ path = "poetry.toml", format = "sdist" },
]
Since Poetry provides build and run script functionalities, can it offer a standardized packaging and startup process?
In CI/CD
- Execute poetry install to install dependencies.
- Execute poetry build to package the project source code, configuration, and .venv into dist/app.tar.gz.
- Use the Dockerfile command ADD dist/app.tar.gz /app.
In Docker
- Use poetry run start to start the project.
Benefits:
- Standardizes and simplifies the packaging and deployment process.
- Simplifies CI/CD configuration by centralizing related configurations in pyproject.toml.
4