A minimal GitHub template repository for starting a Dockerized Python application. It gives you
a Dockerfile that installs Python on Ubuntu and runs app/app.py, a skeleton
docker-compose.yaml, a requirements.txt and a VERSION file. You bring the code.
Note:
app/app.pyis an empty placeholder. The image builds an environment for your script, but the template itself contains no application logic.
Warning: the unmodified template does not build today (end-of-life base image and PEP 668). See Notes and known limitations for the fixes.
| File | Purpose |
|---|---|
Dockerfile |
Builds an Ubuntu-based image with Python 3 and pip, installs requirements.txt, copies app/ into /app and runs app/app.py. |
docker-compose.yaml |
Skeleton Compose file with placeholders for the service name, image and container name, plus an example environment variable and a bind mount of ./app. It must be filled in before use. |
requirements.txt |
Python dependencies installed into the image. Contains only loguru (unpinned). |
app/app.py |
Entry point run by the container. Empty. |
VERSION |
Version string (0.1.1). Nothing in the repository reads it. |
LICENSE |
Apache License 2.0. |
- Base image:
ubuntu:24.10 - Labels:
maintainer=""(empty, fill it in) - Environment:
PYTHONIOENCODING=utf-8,LANG=C.UTF-8 - System packages (apt):
python3-pip,libffi-dev,libssl-dev - pip: upgrades
pipandsetuptools, then installsrequirements.txt(copied to/tmp) - Copies: the
app/directory to/app - Working directory:
/app - Entrypoint:
/usr/bin/python3 /app/app.py - No
EXPOSE,USER,HEALTHCHECKorCMDinstructions.
version: "3.6"- One service whose key is a placeholder (
container_name: #Change to your name) that you replace with your service name. image:andcontainer_name:are empty.restart: alwaysenvironment:EXAMPLE_ENV=(an example variable; replace or remove it)volumes:./app:/app, which mounts your local code over the code baked into the image, so edits apply on container restart without rebuilding.- No
build:section and noports:.
- Create a new repository from the template:
- On GitHub, click Use this template → Create a new repository, or
- With the GitHub CLI:
gh repo create my-app --template t0mer/python-docker-template --private --clone
- Write your application in
app/app.py. Additional modules can go next to it inapp/; the whole directory is copied into the image. - Add dependencies to
requirements.txt, one per line (pin versions, e.g.loguru==0.7.2). Removeloguruif you don't use it. - Fill in
LABEL maintainerin theDockerfileand bumpVERSIONif you use it. - Fill in
docker-compose.yaml(see below).
Warning: as shipped,
docker buildfails. Fix the base image and the pip install first; see Notes and known limitations.
With Docker:
docker build -t my-app .
docker run --rm my-appWith Docker Compose, first replace the placeholders. A filled-in example that builds the image locally:
services:
my-app:
build: .
image: my-app:latest
container_name: my-app
restart: always
environment:
- EXAMPLE_ENV=value
volumes:
- ./app:/appdocker compose up -d --build
docker compose logs -fIf your app listens on a port, add a ports: mapping to the Compose file (and optionally
EXPOSE in the Dockerfile for documentation).
- Environment variables: add them under
environment:in the Compose file (or-ewithdocker run) and read them in your code withos.environ. - System packages: add them to the
apt installstep in the Dockerfile. - Different entry point: change the
ENTRYPOINTline. - Versioning:
VERSIONis not wired into the build. If you want it, pass it as a build arg or read it in your code.
These are properties of the template as it stands; review them before using it for anything beyond a quick prototype.
- The build fails: end-of-life base image.
ubuntu:24.10(oracular) is a non-LTS release that reached end of life in July 2025. Its repositories have moved toold-releases.ubuntu.com, andarchive.ubuntu.comreturns 404 for them, soapt updatefails. Switch to a supported base image, such aspython:3.12-slimor an LTS tag likeubuntu:24.04. - The build fails: pip on recent Ubuntu. Even with apt fixed, Ubuntu 23.04 and later mark the
system Python as "externally managed" (PEP 668), so the
pip3 installsteps fail withexternally-managed-environment. Use a base image with its own Python (e.g.python:3.12-slim, where pip works directly) or install into a virtual environment. - Runs as root. There is no
USERinstruction, so the app runs as root inside the container. Add a non-root user for anything exposed to a network. - No healthcheck. Add a
HEALTHCHECKif your app is a long-running service. - Unpinned versions.
requirements.txtis unpinned and pip/setuptools are always upgraded to the latest release, so builds are not reproducible. - Image size and caching.
apt updateruns in its own layer and apt lists are not cleaned up;requirements.txtis installed without--no-cache-dir. There is no.dockerignore. - Compose file is not valid as shipped. The service name,
imageandcontainer_nameare placeholders, and the top-levelversionkey is obsolete in Docker Compose v2. TheEXAMPLE_ENVcomment ("Google account email") is left over from another project. - Bind mount overrides the image.
./app:/appmeans the container runs your local files, not the ones built into the image. Remove the volume for production. - No CI. There are no GitHub Actions workflows for building or publishing the image.
Licensed under the Apache License 2.0.