diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..7f3a62d --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,86 @@ +name: Docker + +on: + push: + branches: [master] + pull_request: + schedule: + # Weekly rebuild to pick up patched base images + - cron: "0 4 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + IMAGE: tecktron/python-bjoern + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python: ["3.11", "3.12", "3.13", "3.14", "latest"] + variant: ["", "-slim"] + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Resolve base image and tag + id: vars + env: + PY: ${{ matrix.python }} + VARIANT: ${{ matrix.variant }} + run: | + if [ "$PY" = "latest" ]; then + # Floating tags: python:latest -> latest, python:slim -> latest-slim + base="${VARIANT#-}" + base="${base:-latest}" + tag="latest${VARIANT}" + else + base="${PY}${VARIANT}" + tag="python-${PY}${VARIANT}" + fi + echo "base=$base" >> "$GITHUB_OUTPUT" + echo "tag=$tag" >> "$GITHUB_OUTPUT" + + - name: Set up QEMU + uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + + - name: Log in to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker metadata + id: meta + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 + with: + images: ${{ env.IMAGE }} + flavor: latest=false + tags: type=raw,value=${{ steps.vars.outputs.tag }} + + - name: Build and push + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-args: PYTHON_TAG=${{ steps.vars.outputs.base }} + pull: true + # Scheduled runs skip the cache so apt and pip layers are refreshed too + no-cache: ${{ github.event_name == 'schedule' }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha,scope=${{ steps.vars.outputs.tag }} + cache-to: type=gha,mode=max,scope=${{ steps.vars.outputs.tag }} diff --git a/Dockerfile b/Dockerfile index 7721268..1b2ecaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ -FROM python:latest +ARG PYTHON_TAG=latest +FROM python:${PYTHON_TAG} ARG DEBIAN_FRONTEND=noninteractive RUN apt-get clean && apt-get update && \ apt-get -y install --no-install-recommends \ gcc \ + libc6-dev \ libev-dev \ && rm -rf /var/lib/apt/lists/* diff --git a/README.md b/README.md index 49d2266..336c2e6 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ # Python Bjoern Docker Container A Docker container to run a WSGI Python application using -[Bjoern](https://github.com/jonashaag/bjoern). Images support python 3.6+ and are +[Bjoern](https://github.com/jonashaag/bjoern). Images support python 3.11+ and are based on the [official python containers](https://hub.docker.com/_/python). The `-slim` versions are based on the similarly named python versions. +Published tags (`linux/amd64` and `linux/arm64`, rebuilt weekly): +`python-3.11`, `python-3.12`, `python-3.13`, `python-3.14`, `latest` (each also with a `-slim` variant). + [Pull from Docker Hub](https://hub.docker.com/r/tecktron/python-bjoern/) [View on GitHub](https://github.com/Tecktron/docker-python-bjoern)