- Overview
- Quick Links
- Prerequisites
- Getting Started
- Help
- Docker Image Development and Management
- Interact with Python3
This repository manages the customised Docker image build of Python3 on Ubuntu. You can target any Python 3 verions against any Ubuntu release. Just follow the makester
settings below.
Bypassing the Docker Hub Official Image Python image build is much more work, but gives us more flexibility to address CVEs.
The image build process is based on GitHub Python project's Docker build with a switch to Ubuntu base. Not sure why there isn't a Ubuntu variant available in the Official Python images?
- GNU make
- Python 3 Interpreter. We recommend installing pyenv
- Docker
Makester is used as the Integrated Developer Platform.
Follow these notes to get GNU make.
Get the code and change into the top level git
project directory:
git clone https://github.com/loum/python3-ubuntu.git && cd python3-ubuntu
Note
Run all commands from the top-level directory of the git
repository.
For first-time setup, get the Makester project:
Initialise the environment:
make init
There should be a make
target to be able to get most things done. Check the help for more information:
make help
Note
Ubuntu base image is noble 24.04
Build the image with:
make image-buildx
By default, the container image will build with the user:group
combinatation user:user
. The
user
uid
is 49899
. It is possible to override these values during the container build
process by providing values for the Makefile
variables IMAGE_UID
, IMAGE_USER
and
IMAGE_GROUP
. This is demonstrated in the following make
plan:
make -n IMAGE_UID=2000 IMAGE_USER=dodge IMAGE_GROUP=dodgier image-buildx
To list the available Docker images::
make image-search
By default, makester
will tag the new Docker image with the current branch hash. This provides a degree of uniqueness but is not very intuitive. That is where the tag-version
Makefile
target can help. To apply tag as per project tagging convention <ubuntu-code>-<python3-version>-<image-release-number>
:
make image-tag-version
Example output: loum/python3-ubuntu:noble-3.11.1-1
To tag the image as latest
make image-tag-latest
Example output: loum/python3-ubuntu:latest
To tag the image main line (without the <image-release-number>
that ensures the latest Ubuntu release:
make image-tag-major
Example output: loum/python3-noble-3.11
During the image build, a fresh compile of the Python binaries is performed. In theory, any Python release under https://www.python.org/ftp/python/ can be used. You will need to supply the PYTHON_MAJOR_MINOR_VERSION
and PYTHON_RELEASE_VERSION
to the image build target. For example, to build an image with Python 3.10.4:
PYTHON_MAJOR_MINOR_VERSION=3.10 PYTHON_RELEASE_VERSION=4 make image-buildx
To validate the image runs as expected:
make container-run
On success this will drop you into the Python interpreter.
To get the python3
version:
make python-version