Files
shot-crafter-calculator/.gitea/workflows/ci.yml
T
darroyo 6e3db41ba4
CI / Build Native (push) Failing after 6m13s
fix(ci): force musl linking for the static native binary
binary-type=STATIC alone picks glibc on Ubuntu jammy hosts, hence
the GLIBC_2.35 error at runtime. Explicitly force musl:

- -Dquarkus.native.libc=musl
- -Dquarkus.native.additional-build-args=--libc=musl
- delete target/*-runner first so we don't reuse a previously-built
  glibc-based binary that the Quarkus plugin cache might return

Verify step now exits 1 if the binary isn't statically linked, so
the next CI run tells us definitively whether we shipped static.
2026-08-14 14:53:39 -04:00

129 lines
4.5 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-native:
name: Build Native
runs-on: ubuntu-latest
container:
image: maven:3.9.6-eclipse-temurin-21
options: --memory=8g
steps:
- name: Install git, node, gcc, musl, docker, buildx, and basic tools
run: |
apt-get update
apt-get install -y git curl ca-certificates build-essential zlib1g-dev musl musl-tools docker.io docker-buildx
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
rm -rf /var/lib/apt/lists/*
git --version
node --version
gcc --version
docker --version
docker buildx version
musl-gcc --version 2>/dev/null || echo "musl-gcc not present (binary-type=STATIC won't produce static binaries)"
- name: Checkout
uses: actions/checkout@v4
- name: Cache Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm'
java-version: '21'
components: 'native-image'
- name: Cache Node + npm
uses: actions/cache@v4
with:
path: |
target/node
src/frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Build (Native)
run: |
rm -f target/shot-crafter-calculator-1.0.0-runner
mvn package -Pnative -B -DskipTests \
-Dquarkus.native.native-image-xmx=4g \
-Dquarkus.native.binary-type=STATIC \
-Dquarkus.native.libc=musl \
-Dquarkus.native.additional-build-args=--libc=musl
- name: Verify native binary
run: |
ls -la target/shot-crafter-calculator-1.0.0-runner
echo ""
echo "=== Library dependencies ==="
out=$(ldd target/shot-crafter-calculator-1.0.0-runner 2>&1 || true)
if echo "$out" | grep -q "not a dynamic executable"; then
echo "OK: binary is statically linked."
else
echo "FAIL: binary has dynamic dependencies:"
echo "$out"
exit 1
fi
- name: Stage binary for Docker
run: |
mkdir -p build-output
cp target/shot-crafter-calculator-1.0.0-runner build-output/
chmod 775 build-output/shot-crafter-calculator-1.0.0-runner
echo "securerandom.source=file:/dev/urandom" >> build-output/shot-crafter-calculator-1.0.0-runner
- name: Build & Push Docker image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
set -e
echo "=== Build Docker image ==="
docker buildx build -t shot-crafter-calculator:ci .
echo "=== Login to Gitea Registry ==="
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login gitea.danielarroyo.cl -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
echo "=== Tag ==="
docker tag shot-crafter-calculator:ci gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest
docker tag shot-crafter-calculator:ci gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${SHORT_SHA}
push_with_retry() {
local ref="$1"
local attempt=1
local max_attempts=5
while [ $attempt -le $max_attempts ]; do
echo "=== Push (attempt $attempt/$max_attempts): $ref ==="
if docker push "$ref"; then
return 0
fi
echo "::warning::Push of $ref failed, retrying in 30s..."
sleep 30
attempt=$((attempt + 1))
done
echo "::error::Push of $ref failed after $max_attempts attempts"
return 1
}
push_with_retry "gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest"
push_with_retry "gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${SHORT_SHA}"
echo "=== Logout ==="
docker logout gitea.danielarroyo.cl
echo "=== Done ==="