pyinfra
pyinfra copied to clipboard
Support for docker compose files
Is your feature request related to a problem? Please describe
The new docker operations in pyinfra 3.x are really nice. But it would be even nicer if one could deploy a whole stack of docker containers using docker compose files. At the moment doing this is a bit of a hassle
files.directory(DIR_DOCKER)
files.directory(DIR_STORAGE)
for dir_name in ["umbrel"]:
compose = files.put("apps/" + dir_name + "/docker-compose.yml", DIR_DOCKER + "/" + dir_name + "/docker-compose.yml")
if compose.changed:
server.shell("docker-compose down --remove-orphans && docker-compose up -d",
_shell_executable="zsh -l",
_chdir=DIR_DOCKER + "/" + dir_name,
_env={"DIR_STORAGE": storage_path})
Describe the solution you'd like
It would be nice to have a operation like
docker.stack("docker-compose.yml", _env={"DIR_STORAGE": storage_path})
which would make sure that the containers, networks and volumes defined in the compose file will run. The _env dictionary could be used to enable https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/ within the docker-compose.yml file.