Skip to content

Add removeDiacritics helper and use it for image cache filenames #1171

Add removeDiacritics helper and use it for image cache filenames

Add removeDiacritics helper and use it for image cache filenames #1171

Workflow file for this run

# The reason this is so complicated is because github actions cache for docker
# build doesn't seem to work as well as it should. Ideally it just caches the
# work it has done before but I couldn't get this to work with much trying.
# So we manually compute the hash of the files which the base docker image layer
# depends upon and use this to tag images. If for some reason at some point
# the github actions docker cache works more efficiently, we can simplyify.
# The goals are:
# - reproducible builds
# - fast tests
# - fast deployments
name: build
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/blot
jobs:
build:
strategy:
matrix:
include:
- arch: amd64
platform: linux/amd64
runs-on: ubuntu-latest
- arch: arm64
platform: linux/arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
# Per-arch registry cache. Keeps layers hot on each native runner.
- name: Build and push (${{ matrix.arch }})
id: build
uses: docker/build-push-action@v6
with:
context: .
target: prod
platforms: ${{ matrix.platform }} # native, no QEMU
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ github.sha }}-${{ matrix.arch }}
cache-from: |
type=registry,ref=${{ env.IMAGE_NAME }}:cache-${{ matrix.arch }}
cache-to: |
type=registry,ref=${{ env.IMAGE_NAME }}:cache-${{ matrix.arch }},mode=max
- name: Verify health check (${{ matrix.arch }})
env:
IMAGE: ${{ env.IMAGE_NAME }}:${{ github.sha }}-${{ matrix.arch }}
run: |
set -euo pipefail
docker network create test_network
redis_container_id=$(docker run -d --name test_redis --network test_network redis:latest)
timeout=30; interval=2; elapsed=0
until docker exec "$redis_container_id" redis-cli ping | grep -q PONG; do
if [ $elapsed -ge $timeout ]; then
echo "Redis not ready in $timeout s"
docker logs "$redis_container_id" || true
exit 1
fi
sleep $interval; elapsed=$((elapsed+interval))
done
app_id=$(docker run -d --network test_network -e BLOT_REDIS_HOST=test_redis -p 8080:8080 "$IMAGE")
timeout=60; interval=5; elapsed=0
until [ "$(docker inspect --format='{{json .State.Health.Status}}' "$app_id")" = '"healthy"' ]; do
if [ $elapsed -ge $timeout ]; then
echo "App health check failed"
docker logs "$app_id" || true
exit 1
fi
sleep $interval; elapsed=$((elapsed+interval))
done
docker rm -f "$app_id" "$redis_container_id"
docker network rm test_network
manifest:
needs: build
runs-on: ubuntu-latest
if: ${{ always() && needs.build.result == 'success' }}
steps:
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Create and push multi-arch manifest
run: |
set -euo pipefail
IMAGE="ghcr.io/${{ github.repository_owner }}/blot"
SHA="${{ github.sha }}"
docker buildx imagetools create \
-t "$IMAGE:$SHA" \
"$IMAGE:$SHA-amd64" \
"$IMAGE:$SHA-arm64"
# Optional: tag branch and latest on default branch
if [ "${{ github.ref_name }}" = "master" ]; then
docker buildx imagetools create \
-t "$IMAGE:latest" \
"$IMAGE:$SHA"
fi