examples/docker/README.md
This example demonstrates using docker in combination with solve-groups and per-environment editability.
The project uses solve-groups to ensure that the default environment (for development and testing) and the prod environment use exactly the same versions of dependencies. Both environments include the local docker-project package, but with different editability:
default environment: The package is installed as editable (editable = true) for fast development iterationprod environment: The package is installed as non-editable (editable = false) for a clean production deploymentThis is configured in pyproject.toml:
[tool.pixi.feature.dev.pypi-dependencies]
docker-project = { path = ".", editable = true }
[tool.pixi.feature.prod.pypi-dependencies]
docker-project = { path = ".", editable = false }
[tool.pixi.environments]
default = { features = ["test", "dev"], solve-group = "default" }
prod = { features = ["prod"], solve-group = "default" }
In the docker container, we only copy the prod environment into the final layer, so the default environment and all its dependencies are not included in the final image.
Also, pixi itself is not included in the final image and we activate the environment using pixi -e prod shell-hook.
To build and run the docker container you require docker or podman and docker-compose.
docker compose up --build
docker build -t pixi-docker .
docker run -p 8000:8000 pixi-docker