fb021b165b
CI / Build Native (push) Successful in 6m17s
Cut the dependency on the public hostname gitea.danielarroyo.cl and push straight to the LAN Gitea instance. Internal Gitea is plain HTTP, so the docker daemon on the LXC needs 'insecure-registries' set, and the gitea-runner-lxc has to be re-registered against the new URL (separate manual steps; not in this repo). - ci.yml: docker login, both docker tag, both push_with_retry, and docker logout now target 10.5.0.195:3000 - compose.yaml: image URL switched to 10.5.0.195:3000 The CI workflow itself, the Dockerfile, and the build command are unchanged - only the registry target moved.
113 lines
3.7 KiB
YAML
113 lines
3.7 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, docker, buildx, and basic tools
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y git curl ca-certificates build-essential zlib1g-dev 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
|
|
|
|
- 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: mvn package -Pnative -B -DskipTests -Dquarkus.native.native-image-xmx=4g
|
|
|
|
- name: Verify native binary
|
|
run: |
|
|
ls -la target/shot-crafter-calculator-1.0.0-runner
|
|
echo ""
|
|
echo "=== Library dependencies ==="
|
|
ldd target/shot-crafter-calculator-1.0.0-runner 2>&1 || echo "(unable to determine)"
|
|
|
|
- name: Stage binary for Docker
|
|
run: |
|
|
mkdir -p build-output
|
|
cp target/shot-crafter-calculator-1.0.0-runner build-output/
|
|
|
|
- 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 10.5.0.195:3000 -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
|
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
|
|
echo "=== Tag ==="
|
|
docker tag shot-crafter-calculator:ci 10.5.0.195:3000/proyectos/shot-crafter-calculator:latest
|
|
docker tag shot-crafter-calculator:ci 10.5.0.195:3000/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 "10.5.0.195:3000/proyectos/shot-crafter-calculator:latest"
|
|
push_with_retry "10.5.0.195:3000/proyectos/shot-crafter-calculator:${SHORT_SHA}"
|
|
echo "=== Logout ==="
|
|
docker logout 10.5.0.195:3000
|
|
echo "=== Done ==="
|