A poetry plugin for configure and build docker images.
Project description
Poetry Docker Plugin
A Poetry plugin for configuring and building docker images directly from python projects.
Installation
In order to install the plugin you need to have installed a poetry version >1.0
and type:
poetry self add poetry-docker-plugin
Simple Example
Let's assume that you have created a Poetry project having the following pyproject.toml
configuration:
[tool.poetry]
name = "example_project"
version = "1.0.0"
description = "An example poetry project."
authors = ["Evangelos"]
[tool.poetry.dependencies]
python = "3.11"
[tool.poetry.scripts]
run_service = "app.service:start"
your project also declares a poetry script that starts a service. Then, by adding the following minimal docker configuration in your pyproject.toml
you can build your docker image:
[tool.docker]
copy = [
{ source = "example_project-1.0.0.tar.gz", target = "/app/example_project.tar.gz" },
]
flow = [
{ run = "pip install /app/example_project.tar.gz" },
]
expose = [8000]
cmd = ["run_service"]
Note that there is no docker FROM command, and thus poetry-docker-plugin
automatically figures out the python version and use python:3.11
as the base image. Moreover, since we have not defined a name for the image, it derives one, using the first author name and the project name. Thus, by running the command poetry docker
, poetry builds a docker image ready to run your service in port 8000.
Docker Configuration Skeleton
The configuration below outlines all supported commands:
[tool.docker]
image_name = "org/image_name:version"
args = { version = "1.2.0" } # default values for args
from = "python:3.11"
labels = { "description" = "Poetry docker plugin is awesome." }
copy = [
{ source = "./poetry-docker-plugin-0.1.0.tar.gz", target = "/opt/pdp.tar.gz" },
]
env.SERVICE_CONFIGURATION = "/opt/service.conf"
volume = ["/data"]
flow = [
# a sequence of WORKDIR and RUN commands
{ work_dir = "/opt" },
{ run = "ls" },
{ work_dir = "/tmp" },
{ run = "ls /opt" },
]
expose = [8888, 9999]
# alternatively you may use entrypoint = []
cmd = ["run_service", "--verbose"]
then, as soon as you are done configuring, type:
poetry docker
License
This project is licensed under the terms of the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for poetry_docker_plugin-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55d5b446884a8bfd9611bf0364776da887795d4bf6fc5cda5678d33537664469 |
|
MD5 | 7fa14e0a2fb73827a3ab58c66da0e030 |
|
BLAKE2b-256 | 2b49948641bab730f43d2408eebb5cb9213859dc7ae3c7d2bbe6498b2daf629e |
Hashes for poetry_docker_plugin-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e3beb453ac8ff848a0e81f9c5396f330bdca38a03df7f8623b5790bba3a6d74 |
|
MD5 | ac12c9484efcb7d885fa1405de2261f5 |
|
BLAKE2b-256 | 548c9d137b5b30ae172f8d0924b37fd0431bbb154e22eeacaf2570cc272d9baf |