Our goal to manage python packages via poetry.
Poetry is a modern package manager inspired but tools such javascript npm. If you don't familiar with this tool check my another gist
Init project via poetry and install python-black
poetry new demo-po-alpine && cd demo-po-alpine
poetry add black
Inside the project folder we should create Dockerfile
, docker-compose.yml
.
Also, it's good practise to specify all things that you don't need in runtime in .dockerignore
.
So desired result should looks like this:
❯ tree
.
├── Dockerfile
├── README.rst
├── demo_po_alpine
│ └── __init__.py
├── docker-compose.yml
├── poetry.lock
├── pyproject.toml
└── tests
├── __init__.py
└── test_demo_po_alpine.py
2 directories, 8 files
Build the image and check black version:
docker compose up
[+] Running 1/1
⠿ Container demo-po-alpine Started 0.6s
Attaching to demo-po-alpine
demo-po-alpine | black, 21.12b0 (compiled: no)
demo-po-alpine exited with code 0