Skip to content

Ralphex image fixes (#18) #2

Ralphex image fixes (#18)

Ralphex image fixes (#18) #2

name: Build ralphex-fe
on:
push:
branches:
- master
paths:
- 'ralphex-fe/Dockerfile'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ralphex-fe
jobs:
build-and-push:
runs-on: ubuntu-latest
# Skip if commit was made by the update workflow to avoid double builds
if: ${{ !contains(github.event.head_commit.message, 'via GitHub Actions workflow dispatch') }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract versions from Dockerfile
id: versions
run: |
DOCKERFILE="ralphex-fe/Dockerfile"
BUN_VERSION=$(grep '^ARG BUN_VERSION=' "$DOCKERFILE" | cut -d'=' -f2)
HUGO_VERSION=$(grep '^ARG HUGO_VERSION=' "$DOCKERFILE" | cut -d'=' -f2)
if [ -z "$BUN_VERSION" ] || [ -z "$HUGO_VERSION" ]; then
echo "Error: Failed to extract version(s) from Dockerfile"
echo " Bun: ${BUN_VERSION:-<empty>}"
echo " Hugo: ${HUGO_VERSION:-<empty>}"
exit 1
fi
echo "bun=$BUN_VERSION" >> $GITHUB_OUTPUT
echo "hugo=$HUGO_VERSION" >> $GITHUB_OUTPUT
echo "Extracted versions:"
echo " Bun: $BUN_VERSION"
echo " Hugo: $HUGO_VERSION"
- name: Generate image tags
id: tags
run: |
NAMESPACE=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BASE_IMAGE="${{ env.REGISTRY }}/${NAMESPACE}/${{ env.IMAGE_NAME }}"
BUN_VERSION="${{ steps.versions.outputs.bun }}"
HUGO_VERSION="${{ steps.versions.outputs.hugo }}"
VERSION_TAG="bun${BUN_VERSION}-hugo${HUGO_VERSION}-ralphex"
TAGS="${BASE_IMAGE}:latest,${BASE_IMAGE}:${VERSION_TAG}"
echo "namespace=$NAMESPACE" >> $GITHUB_OUTPUT
echo "tags=$TAGS" >> $GITHUB_OUTPUT
echo "Generated tags:"
echo "$TAGS" | tr ',' '\n'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.tags.outputs.namespace }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ralphex-fe
file: ralphex-fe/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Verify image
run: |
TAGS="${{ steps.tags.outputs.tags }}"
FIRST_TAG=$(echo "$TAGS" | cut -d',' -f1)
echo "Verifying multiplatform image: $FIRST_TAG"
docker pull --platform linux/amd64 "$FIRST_TAG"
docker pull --platform linux/arm64 "$FIRST_TAG"
echo "Verifying Bun installation (amd64)..."
docker run --rm --platform linux/amd64 "$FIRST_TAG" bun --version
echo "Verifying Hugo installation (amd64)..."
docker run --rm --platform linux/amd64 "$FIRST_TAG" hugo version
echo "Verifying Bun installation (arm64)..."
docker run --rm --platform linux/arm64 "$FIRST_TAG" bun --version
echo "Verifying Hugo installation (arm64)..."
docker run --rm --platform linux/arm64 "$FIRST_TAG" hugo version
echo "Multiplatform image successfully built and pushed!"
echo "Tags: $TAGS"