Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs/
tests/
71 changes: 71 additions & 0 deletions .github/workflows/container-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Create and publish Container image

Check warning on line 1 in .github/workflows/container-build.yaml

View workflow job for this annotation

GitHub Actions / Linters

1:1 [document-start] missing document start "---"

on:

Check warning on line 3 in .github/workflows/container-build.yaml

View workflow job for this annotation

GitHub Actions / Linters

3:1 [truthy] truthy value should be one of [false, true]
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- container: Containerfile
autotag: auto

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=edge
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
latest=${{ matrix.autotag }}
suffix=${{ matrix.suffix }}

- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6
context: .
file: ${{ matrix.container }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
30 changes: 30 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Copyright (C) 2025 Olliver Schinagl <oliver@schinagl.nl>

ARG TARGET_VERSION="3-alpine"
ARG TARGET_ARCH="library"

FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION}

WORKDIR /usr/local/app

COPY . /usr/local/app

RUN _venv_dir="$(mktemp -d -p "${TMPDIR:-/tmp}" '_venv.XXXXXX')" && \
python -m 'venv' "${_venv_dir}" && \
"${_venv_dir}/bin/pip" install \
'build' \
'setuptools' \
'wheel' \
&& \
"${_venv_dir}/bin/python" -m build --wheel --no-isolation && \
pip install './dist/yamllint-'*'.whl' && \
rm -f -r "${_venv_dir}" && \
rm -f -r "/usr/local/app"

COPY "./container-entrypoint.sh" "/init"

WORKDIR /usr/local/bin

ENTRYPOINT [ "/init" ]
1 change: 1 addition & 0 deletions Dockerfile
24 changes: 24 additions & 0 deletions container-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2025 Olliver Schinagl <oliver@schinagl.nl>
#
# A beginning user should be able to docker run image bash (or sh) without
# needing to learn about --entrypoint
# https://github.com/docker-library/official-images#consistency

set -eu

bin='yamllint'

# run command if it is not starting with a "-" and is an executable in PATH
if [ "${#}" -le 0 ] || \
[ "${1#-}" != "${1}" ] || \
[ -d "${1}" ] || \
! command -v "${1}" > '/dev/null' 2>&1; then
entrypoint='true'
fi

exec ${entrypoint:+${bin:?}} "${@}"

exit 0
Loading