diff --git a/.gitea/workflows/update.yml b/.gitea/workflows/update.yml index 6859dc4..c522535 100644 --- a/.gitea/workflows/update.yml +++ b/.gitea/workflows/update.yml @@ -28,65 +28,32 @@ jobs: env: CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }} run: | - # Get a bearer token for authentication - REGISTRY_TOKEN=$(curl -s -X GET \ - -u "${{ gitea.actor }}:${{ secrets.CI_RUNNER_TOKEN }}" \ - "https://gitea.gt-proj.com/v2/token?service=container_registry&scope=repository:brian/mlflow-full:pull" \ - | jq -r '.token // empty') - if [ -z "$REGISTRY_TOKEN" ]; then + # Configure Docker for insecure registry + mkdir -p ~/.docker + echo '{ + "auths": {}, + "insecure-registries": ["10.0.0.2:3000"] + }' > ~/.docker/config.json + + # Login to internal registry + echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login 10.0.0.2:3000 --username "${{ gitea.actor }}" --password-stdin + + # Pull and inspect the image + if docker pull 10.0.0.2:3000/brian/mlflow-full:latest 2>/dev/null; then + BASE_IMAGE_DIGEST=$(docker inspect 10.0.0.2:3000/brian/mlflow-full:latest | jq -r '.[0].Config.Labels["org.opencontainers.image.base.digest"] // empty') + + if [ -n "$BASE_IMAGE_DIGEST" ] && [ "$BASE_IMAGE_DIGEST" != "null" ]; then + echo "base_image_digest=$BASE_IMAGE_DIGEST" >> $GITHUB_OUTPUT + echo "success=true" >> $GITHUB_OUTPUT + echo "Base image digest from MLflow-full image: $BASE_IMAGE_DIGEST" + else + echo "success=false" >> $GITHUB_OUTPUT + echo "No base image digest label found" + fi + else echo "success=false" >> $GITHUB_OUTPUT - echo "Failed to obtain registry token" - exit 1 + echo "Failed to pull MLflow-full image - this might be the first run" fi - # Inspect the manifest of the MLflow-full image - MANIFEST=$(docker manifest inspect "gitea.gt-proj.com/brian/mlflow-full:latest" 2>/dev/null || echo "{}") - if [ "$MANIFEST" == "{}" ]; then - echo "success=false" >> $GITHUB_OUTPUT - echo "MLflow-full manifest not found" - exit 1 - fi - # Extract digest for linux/amd64 platform - DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty') - if [ -z "$DIGEST" ]; then - echo "success=false" >> $GITHUB_OUTPUT - echo "No suitable manifest found for linux/amd64" - exit 1 - fi - # Get the manifest for the specific platform - PLATFORM_MANIFEST=$(curl -s -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ - -H "Authorization: Bearer $REGISTRY_TOKEN" \ - "https://gitea.gt-proj.com/v2/brian/mlflow-full/manifests/$DIGEST" 2>/dev/null || echo "{}") - if [ "$PLATFORM_MANIFEST" == "{}" ]; then - echo "success=false" >> $GITHUB_OUTPUT - echo "Failed to fetch platform-specific manifest" - exit 1 - fi - # Extract config blob digest - CONFIG_DIGEST=$(echo "$PLATFORM_MANIFEST" | jq -r '.config.digest // empty') - if [ -z "$CONFIG_DIGEST" ]; then - echo "success=false" >> $GITHUB_OUTPUT - echo "No config digest found in platform manifest" - exit 1 - fi - # Fetch the configuration blob to get labels - CONFIG_BLOB=$(curl -s \ - -H "Authorization: Bearer $REGISTRY_TOKEN" \ - "https://gitea.gt-proj.com/v2/brian/mlflow-full/blobs/$CONFIG_DIGEST" 2>/dev/null || echo "{}") - if [ "$CONFIG_BLOB" == "{}" ]; then - echo "success=false" >> $GITHUB_OUTPUT - echo "Failed to fetch config blob" - exit 1 - fi - # Extract base image digest label from config - BASE_IMAGE_DIGEST=$(echo "$CONFIG_BLOB" | jq -r '.config.Labels["base-image.digest"] // empty') - if [ -z "$BASE_IMAGE_DIGEST" ]; then - echo "success=false" >> $GITHUB_OUTPUT - echo "No base-image.digest label found in MLflow-full image" - exit 1 - fi - echo "base_image_digest=$BASE_IMAGE_DIGEST" >> $GITHUB_OUTPUT - echo "success=true" >> $GITHUB_OUTPUT - echo "Base image digest from MLflow-full image: $BASE_IMAGE_DIGEST" get-mlflow-digest: runs-on: ubuntu-latest outputs: