From 6ff519aecd49d7991a30086c8001bb96aa68dbff Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 7 Aug 2022 10:36:18 -0500 Subject: [PATCH] Initial commit --- .gitignore | 1 + Config.in | 0 README.md | 42 ++++++++++++++++++++++++++++++++++++ configs/pythonctnr_defconfig | 14 ++++++++++++ external.desc | 2 ++ external.mk | 0 6 files changed, 59 insertions(+) create mode 100644 .gitignore create mode 100644 Config.in create mode 100644 README.md create mode 100644 configs/pythonctnr_defconfig create mode 100644 external.desc create mode 100644 external.mk diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba65b13 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/_build/ diff --git a/Config.in b/Config.in new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..04bef10 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Minimal Base Python Container Image + +The *pythonctnr* image contains ONLY the Python runtime, and nothing else. It +is suitable for deploying applications written in pure Python, without any +external library dependencies. No shell or other OS utilities are included. +Just `/usr/bin/python3` and the libraries it needs to run. + + +## Building + +The contents of the container image are built with [buildroot][0]. + +```sh +make -C ~/src/buildroot O=${PWD}/_build pythonctnr_defconfig +make -C _build +``` + +This will produce a `rootfs.tar` tarball in `_build/images`, which is then +converted to a container image using `buildah`. + +```sh +ctnr=$(buildah from scratch) +buildah add ${ctnr} _build/images/rootfs.tar / +buildah commit ${ctnr} pythonctnr:latest +``` + +[0]: https://buildroot.org/ + + +## Usage + +The container image can be used like any other image, e.g. in a `Dockerfile`. +*pip* is included, to allow installing Python distribution packages. + +```Dockerfile +FROM pythonctnr + +RUN ["/usr/bin/python3", "-m", "pip", "install", "mypkg"] +``` + +**NOTE**: Because there is no shell, the default string form of the `RUN` +instruction does not work. You must use the *exec* form. diff --git a/configs/pythonctnr_defconfig b/configs/pythonctnr_defconfig new file mode 100644 index 0000000..aca678d --- /dev/null +++ b/configs/pythonctnr_defconfig @@ -0,0 +1,14 @@ +BR2_x86_64=y +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_TARGET_GENERIC_HOSTNAME="pythonctnr" +BR2_TARGET_GENERIC_ISSUE="" +BR2_INIT_NONE=y +BR2_ROOTFS_MERGED_USR=y +# BR2_TARGET_ENABLE_ROOT_LOGIN is not set +BR2_SYSTEM_BIN_SH_NONE=y +# BR2_TARGET_GENERIC_GETTY is not set +# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set +BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin" +# BR2_PACKAGE_BUSYBOX is not set +BR2_PACKAGE_PYTHON3=y +BR2_PACKAGE_PYTHON_PIP=y diff --git a/external.desc b/external.desc new file mode 100644 index 0000000..7d5a4da --- /dev/null +++ b/external.desc @@ -0,0 +1,2 @@ +name: pythonctnr +desc: Python container image diff --git a/external.mk b/external.mk new file mode 100644 index 0000000..e69de29