Package xkcdpass in container with podman
xkcdpass is a Python package that provides a CLI to generate password according to this strip:
Let's package this in a container !
First, start by editing Dockerfile:
FROM python:3.9-alpine AS BUILD
RUN pip install shiv xkcdpass==1.17.4
RUN shiv -c xkcdpass -o xkcdpass xkcdpass==1.17.4
FROM python:3.9-alpine
COPY --from=BUILD /xkcdpass /bin/
CMD xkcdpass
We're using multi-stage build:
- first, we install required package with
pip
. The xkcdpass
command and its dependencies are packaged with shiv
- then, we copy the created paclage in the final container
Next, let's build the container:
podman build -t blog/xkcdpass .
That should give the following output:
STEP 1: FROM python:3.9-alpine AS BUILD
STEP 2: RUN pip install shiv xkcdpass==1.17.4
Collecting xkcdpass==1.17.4
Downloading xkcdpass-1.17.4.tar.gz (2.3 MB)
|████████████████████████████████| 2.3 MB 2.6 MB/s
Collecting shiv
Downloading shiv-0.4.0-py2.py3-none-any.whl (19 kB)
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packages (from shiv) (51.0.0)
Requirement already satisfied: pip>=9.0.3 in /usr/local/lib/python3.9/site-packages (from shiv) (20.3.3)
Collecting click!=7.0,>=6.7
Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
|████████████████████████████████| 82 kB 769 kB/s
Building wheels for collected packages: xkcdpass
Building wheel for xkcdpass (setup.py) ... done
Created wheel for xkcdpass: filename=xkcdpass-1.17.4-py3-none-any.whl size=2325695 sha256=8842e679fb07eb4958067d3a10dd5b5bce223fdb4f841e900f6180bdbf4b0173
Stored in directory: /root/.cache/pip/wheels/5c/59/b1/f022dc79b4977e1da978c895469b6796a98c49ce98e792e050
Successfully built xkcdpass
Installing collected packages: click, xkcdpass, shiv
Successfully installed click-7.1.2 shiv-0.4.0 xkcdpass-1.17.4
--> 6470d6c91b8
STEP 3: RUN shiv -c xkcdpass -o xkcdpass xkcdpass==1.17.4
Collecting xkcdpass==1.17.4
Using cached xkcdpass-1.17.4-py3-none-any.whl
Installing collected packages: xkcdpass
Successfully installed xkcdpass-1.17.4
--> 76343ef238a
STEP 4: FROM python:3.9-alpine
STEP 5: COPY --from=BUILD /xkcdpass /bin/
--> 564d0812986
STEP 6: CMD xkcdpass
STEP 7: COMMIT blog/xkcdpass
--> 2afb25f65e7
2afb25f65e70fba8d0649f5037c9475ca9824c654af0e10a3adac00580ca606e
Try the command with:
podman run -it blog/xkcdpass
Gives the following output:
ERRO[0000] could not find slirp4netns, the network namespace won't be configured: exec: "slirp4netns": executable file not found in $PATH
skyward wharf nutlike crescent cannabis steep