Skip to content

v0.2.0

v0.2.0 #52

Workflow file for this run

name: Build MikTeX images
on:
push:
workflow_dispatch:
jobs:
MikTeX:
name: 🛳️ Build MikTeX base-image
runs-on: ubuntu-24.04
outputs:
base_image_os_version: ${{ steps.variables.outputs.base_image_os_version }}
base_image_os_codename: ${{ steps.variables.outputs.base_image_os_codename }}
base_image_py_version: ${{ steps.variables.outputs.base_image_py_version }}
miktex_source_repository: ${{ steps.variables.outputs.miktex_source_repository }}
miktex_image_ns: ${{ steps.variables.outputs.miktex_image_ns }}
miktex_image_name: ${{ steps.variables.outputs.miktex_image_name }}
miktex_image_tag: ${{ steps.variables.outputs.miktex_image_tag }}
miktex_image: ${{ steps.variables.outputs.miktex_image }}
miktex_version: ${{ steps.test.outputs.miktex_version }}
steps:
- name: 🖉 Variables
id: variables
run: |
base_image_name="python"
base_image_os_version="13"
base_image_os_codename="Bookworm"
base_image_os_size="-slim"
base_image_py_version="3.14"
miktex_source_repository="${base_image_os_codename,,}"
image_name="miktex"
image_tag="latest"
tee "${GITHUB_OUTPUT}" <<EOF
base_image_name=${base_image_name}
base_image_os_version=${base_image_os_version}
base_image_os_codename=${base_image_os_codename}
base_image_py_version=${base_image_py_version}
base_image=${base_image_name}:${base_image_py_version}${base_image_os_size}-${base_image_os_codename,,}
miktex_source_repository=${miktex_source_repository}
miktex_image_ns=${{ vars.DOCKERHUB_NAMESPACE }}
miktex_image_name=${image_name}
miktex_image_tag=${image_tag}
miktex_image=${{ vars.DOCKERHUB_NAMESPACE }}/${image_name}:${image_tag}
EOF
- name: ⏬ Checkout repository
uses: actions/checkout@v6
- name: 🐋 Building MikTeX image
id: build
run: |
ANSI_RED=$'\x1b[31m'
ANSI_GREEN=$'\x1b[32m'
ANSI_YELLOW=$'\x1b[33m'
ANSI_BLUE=$'\x1b[34m'
ANSI_CYAN=$'\x1b[36m'
ANSI_DARK_GRAY=$'\x1b[90m'
ANSI_LIGHT_BLUE=$'\x1b[94m'
ANSI_NOCOLOR=$'\x1b[0m'
RemoveComments() {
local OutputFile="${2:-$1}"
printf "::group::${ANSI_LIGHT_BLUE}%s${ANSI_NOCOLOR}\n" "Removing comments from '$1' and writing to '${OutputFile}' ..."
grep -v '^\s*$\|^\s*\#' "$1" > "${OutputFile}"
cat "${OutputFile}" | sed 's/^/ /'
printf "::endgroup::\n"
}
DockerImageSizeUncompressed() {
docker image inspect $1 --format='{{.Size}}' | numfmt --to=iec --format '%.2f'
}
printf -- "Convert 'Common.list' to 'Packages.list' ...\n"
RemoveComments Common.list Packages.list
printf -- "Building docker file 'Dockerfile' ...\n"
docker buildx build \
--file Dockerfile \
--build-arg IMAGE=${{ steps.variables.outputs.base_image }} \
--build-arg MIKTEX_SRC_REPO=${{ steps.variables.outputs.miktex_source_repository }} \
--label "org.opencontainers.image.title=MikTeX on Debian ${{ steps.variables.outputs.base_image_os_version }} (${{ steps.variables.outputs.base_image_os_codename }}) + Python ${{ steps.variables.outputs.base_image_py_version }}" \
--label "org.opencontainers.image.description=MikTeX on Debian ${{ steps.variables.outputs.base_image_os_version }} (${{ steps.variables.outputs.base_image_os_codename }}) + Python ${{ steps.variables.outputs.base_image_py_version }} image maintained by pyTooling Authors." \
--label "org.opencontainers.image.authors=Patrick Lehmann <Paebbels@gmail.com>" \
--label "org.opencontainers.image.vendor=pyTooling" \
--label "org.opencontainers.image.version=1.0" \
--label "org.opencontainers.image.revison=${GITHUB_SHA}" \
--label "org.opencontainers.image.created=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--label "org.opencontainers.image.url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \
--label "org.opencontainers.image.documentation=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/blob/main/README.md" \
--label "org.opencontainers.image.license=MIT" \
--label "pyTooling.dockerimages.os.name=Debian" \
--label "pyTooling.dockerimages.os.version=${{ steps.variables.outputs.base_image_os_version }}" \
--label "pyTooling.dockerimages.os.codename=${{ steps.variables.outputs.base_image_os_codename }}" \
--label "pyTooling.dockerimages.os.variant=" \
--label "pyTooling.dockerimages.os.packagemanager=apt" \
--label "pyTooling.dockerimages.os.fullname=Debian ${{ steps.variables.outputs.base_image_os_version }} (${{ steps.variables.outputs.base_image_os_codename }})" \
--label "pyTooling.dockerimages.py.version=${{ steps.variables.outputs.base_image_py_version }}" \
--label "pyTooling.dockerimages.application.name=MikTeX" \
--tag "${{ steps.variables.outputs.miktex_image }}" \
. 2>&1 \
| ./Docker.buildx.sh
# check return codes from docker incase of error.
printf -- "Docker image '%s' has %s\n" "${{ steps.variables.outputs.miktex_image }}" "$(DockerImageSizeUncompressed ${{ steps.variables.outputs.miktex_image }})"
- name: ☑ Checking MikTeX image '${{ steps.variables.outputs.miktex_image }}'
id: test
run: |
DockerImageSizeUncompressed() {
docker image inspect $1 --format='{{.Size}}' | numfmt --to=iec --format '%.2f'
}
printf -- "Docker image '%s' has %s\n" "${{ steps.variables.outputs.miktex_image }}" "$(DockerImageSizeUncompressed ${{ steps.variables.outputs.miktex_image }})"
printf -- "Labels of '${{ steps.variables.outputs.miktex_image }}':\n"
docker inspect --format='{{json .Config.Labels}}' "${{ steps.variables.outputs.miktex_image }}" | jq
docker container run --rm ${{ steps.variables.outputs.miktex_image }} bash -c 'printf "%s\n" "which pdflatex: $(which pdflatex) ($(pdflatex --version | head -n 1))"'
MIKTEX_VERSION="$(docker container run --rm ${{ steps.variables.outputs.miktex_image }} bash -c "miktex --version | head -n 1")"
printf -- "MikTeX version (raw): %s\n" "${MIKTEX_VERSION}"
MIKTEX_VERSION="$(echo "${MIKTEX_VERSION}" | grep -oP '\(MiKTeX \d+\.\d+\)' | grep -oP '\d+\.\d+')"
tee "${GITHUB_OUTPUT}" <<EOF
miktex_version=${MIKTEX_VERSION}
EOF
- name: 🔑 Login and push '${{ steps.variables.outputs.miktex_image }}' to Docker Hub
run: |
DockerImageSizeUncompressed() {
docker image inspect $1 --format='{{.Size}}' | numfmt --to=iec --format '%.2f'
}
printf "%s\n" "Login at Docker Hub ..."
printf "%s\n" "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ vars.DOCKERHUB_USERNAME }} --password-stdin
printf -- "Docker image '%s' has %s\n" "${{ steps.variables.outputs.miktex_image }}" "$(DockerImageSizeUncompressed ${{ steps.variables.outputs.miktex_image }})"
docker image push ${{ steps.variables.outputs.miktex_image }}
Specific:
name: ${{ matrix.icon }} Build specific MikTeX image for ${{ matrix.name }}
runs-on: ubuntu-24.04
needs:
- MikTeX
strategy:
fail-fast: false
matrix:
include:
- {'icon': '📓', 'name': 'Sphinx', 'image': 'sphinx'}
steps:
- name: 🖉 Variables
id: variables
run: |
tee "${GITHUB_OUTPUT}" <<EOF
specific_image_ns="${{ needs.MikTeX.outputs.miktex_image_ns }}"
specific_image_name="${{ needs.MikTeX.outputs.miktex_image_name }}"
specific_image_tag="${{ matrix.name }}"
specific_image=${{ needs.MikTeX.outputs.miktex_image_ns }}/${{ needs.MikTeX.outputs.miktex_image_name }}:${{ matrix.image }}
EOF
- name: ⏬ Checkout repository
uses: actions/checkout@v6
- name: 🐋 Building MikTeX image for ${{ matrix.name }}
id: build
run: |
ANSI_RED=$'\x1b[31m'
ANSI_GREEN=$'\x1b[32m'
ANSI_YELLOW=$'\x1b[33m'
ANSI_BLUE=$'\x1b[34m'
ANSI_CYAN=$'\x1b[36m'
ANSI_DARK_GRAY=$'\x1b[90m'
ANSI_LIGHT_BLUE=$'\x1b[94m'
ANSI_NOCOLOR=$'\x1b[0m'
RemoveComments() {
local OutputFile="${2:-$1}"
printf "::group::${ANSI_LIGHT_BLUE}%s${ANSI_NOCOLOR}\n" "Removing comments from '$1' and writing to '${OutputFile}' ..."
grep -v '^\s*$\|^\s*\#' "$1" > "${OutputFile}"
cat "${OutputFile}" | sed 's/^/ /'
printf "::endgroup::\n"
}
DockerImageSizeUncompressed() {
docker image inspect $1 --format='{{.Size}}' | numfmt --to=iec --format '%.2f'
}
printf -- "Convert '${{ matrix.name }}.list' to 'Packages.list' ...\n"
RemoveComments ${{ matrix.name }}.list Packages.list
printf -- "Building docker file 'Dockerfile' ...\n"
docker buildx build \
--file Dockerfile.Specific \
--build-arg "IMAGE=${{ needs.MikTeX.outputs.miktex_image }}" \
--label "org.opencontainers.image.title=MikTeX specific for ${{ matrix.name }} on Debian ${{ steps.variables.outputs.base_image_os_version }} (${{ steps.variables.outputs.base_image_os_codename }}) + Python ${{ steps.variables.outputs.base_image_py_version }}" \
--label "org.opencontainers.image.description=MikTeX specific for ${{ matrix.name }} on Debian ${{ steps.variables.outputs.base_image_os_version }} (${{ steps.variables.outputs.base_image_os_codename }}) + Python ${{ steps.variables.outputs.base_image_py_version }} image maintained by pyTooling Authors." \
--label "org.opencontainers.image.authors=Patrick Lehmann <Paebbels@gmail.com>" \
--label "org.opencontainers.image.vendor=pyTooling" \
--label "org.opencontainers.image.version=1.0" \
--label "org.opencontainers.image.revison=${GITHUB_SHA}" \
--label "org.opencontainers.image.created=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--label "org.opencontainers.image.url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \
--label "org.opencontainers.image.documentation=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/blob/main/README.md" \
--label "org.opencontainers.image.license=MIT" \
--label "pyTooling.dockerimages.application.variant=${{ matrix.name }}" \
--tag "${{ steps.variables.outputs.specific_image }}" \
. 2>&1 \
| ./Docker.buildx.sh
printf -- "Docker image '%s' has %s\n" "${{ steps.variables.outputs.specific_image }}" "$(DockerImageSizeUncompressed ${{ steps.variables.outputs.specific_image }})"
- name: ☑ Checking MikTeX image '${{ steps.variables.outputs.specific_image }}'
run: |
DockerImageSizeUncompressed() {
docker image inspect $1 --format='{{.Size}}' | numfmt --to=iec --format '%.2f'
}
printf -- "Docker image '%s' has %s\n" "${{ steps.variables.outputs.specific_image }}" "$(DockerImageSizeUncompressed ${{ steps.variables.outputs.specific_image }})"
printf -- "Labels of '${{ steps.variables.outputs.miktex_image }}':\n"
docker inspect --format='{{json .Config.Labels}}' "${{ steps.variables.outputs.miktex_image }}" | jq
docker container run --rm ${{ steps.variables.outputs.specific_image }} bash -c 'xelatex --version'
- name: 🔑 Login and push '${{ steps.variables.outputs.specific_image }}' to Docker Hub
run: |
DockerImageSizeUncompressed() {
docker image inspect $1 --format='{{.Size}}' | numfmt --to=iec --format '%.2f'
}
printf -- "Login at Docker Hub ...\n"
printf "%s\n" "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ vars.DOCKERHUB_USERNAME }} --password-stdin
printf -- "Docker image '%s' has %s\n" "${{ steps.variables.outputs.specific_image }}" "$(DockerImageSizeUncompressed ${{ steps.variables.outputs.specific_image }})"
docker image push ${{ steps.variables.outputs.specific_image }}