Chainguard.dev now has it's own python image
TLDR: This repo contains sample apko.yaml files for generating Chainguard's distroless container base images for building and running containerized python apps.
example/Dockerfile
shows sample multi-stage build (separate "builder" and "runner" base images). These two base images must be built and hosted in your repo. They are generated by apko. The builder image is generated using apko-python-builder.yaml
and the run image is generated using apko-python.yaml
. Note, this example is tailored around a python flask application with gunicorn such as this one; you may need to adjust base image packages in the apko-python.yaml
file for your use case.
To create these distroless base images you will need the apko tool. Follow the docs to pull the apko docker image.
- Use the distroless.dev/apko image to build and output the python-builder.tar file:
docker run -v $PWD:/work distroless.dev/apko build apko-python-builder.yaml \
YOUR-REPO/python-distroless-builder:latest python-builder.tar
Be sure to replace YOUR-REPO.
- Load the builder image from the tar file:
docker image load --input python-builder.tar
- Replace YOUR-REPO and push the image:
docker push YOUR-REPO/python-distroless-builder:latest
- Use the distroless.dev/apkoimage to build and output the python.tar file:
docker run -v $PWD:/work distroless.dev/apko build apko-python.yaml \
YOUR-REPO/python-distroless:latest python.tar
Be sure to replace YOUR-REPO.
- Load the builder image from the tar file:
docker image load --input python.tar
- Replace YOUR-REPO and push the image:
docker push YOUR-REPO/python-distroless:latest
See the example/Dockerfile
for example usage.
Please send me any feedback and pull requests.