From 6b5e02861bc5023715b3f926f05d91c844a1a569 Mon Sep 17 00:00:00 2001 From: "M. Scott Ford" Date: Mon, 25 Sep 2023 08:31:49 -0400 Subject: [PATCH] Another attempt at building a valid ARM Docker image * Switches to `debian:bullseye` as the base image for the `final` stage * Pushes test image to GitHub packages repository and tests it from there. This is an attempt to determine if the `load: true` is causing problems with the way the ARM image is being built. --- .github/workflows/ci.yml | 55 +++++++++++++++++++++------------------- Dockerfile | 13 +++++++++- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0c72988..bb017673 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -268,45 +268,48 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: "[Publish, Docker] - Build" + - name: "[Publish, Docker] - Login to GitHub Container Registry" + if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: "[Publish, Docker] - Build, Push to GitHub Container Registry" if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }} uses: docker/build-push-action@v5 with: context: . - platforms: linux/amd64 - load: true + platforms: linux/amd64,linux/arm64 + push: true tags: - corgibytes/freshli-cli:latest, - corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }}, - corgibytes/freshli-cli:${{ steps.gitversion.outputs.semVer }}-${{ steps.gitversion.outputs.fullBuildMetadata }} - cache-from: type=registry,ref=corgibytes/freshli-cli:buildcache - cache-to: type=registry,ref=corgibytes/freshli-cli:buildcache,mode=max + ghcr.io/corgibytes/freshli-cli:latest, + ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }}, + ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.semVer }}-${{ steps.gitversion.outputs.fullBuildMetadata }} + cache-from: type=registry,ref=ghcr.io/corgibytes/freshli-cli:buildcache + cache-to: type=registry,ref=ghcr.io/corgibytes/freshli-cli:buildcache,mode=max - - name: "[Publish, Docker] - Smoke Test - `agents detect`" + - name: "[Publish, Docker] - Smoke Test - `agents detect` via GitHub Container Registry image" if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }} run: | - docker run --rm corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} agents detect + docker run --rm ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} agents detect - - name: "[Publish, Docker] - Smoke Test - Analyze Java Fixture Repo" + - name: "[Publish, Docker] - Smoke Test - Analyze Java Fixture Repo via GitHub Container Registry image" if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }} run: | - docker run --rm corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} analyze https://github.com/corgibytes/freshli-fixture-java-test + docker run --rm ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} analyze https://github.com/corgibytes/freshli-fixture-java-test - - name: "[Publish, Docker] - Smoke Test - Analyze DotNet Fixture Repo" + - name: "[Publish, Docker] - Smoke Test - Analyze DotNet Fixture Repo via GitHub Container Registry image" if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }} run: | - docker run --rm corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} analyze https://github.com/corgibytes/freshli-fixture-csharp-test + docker run --rm ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} analyze https://github.com/corgibytes/freshli-fixture-csharp-test - - name: "[Publish, Docker] - Push" + - name: "[Publish, Docker] - Push to Docker Hub" if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }} - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: - corgibytes/freshli-cli:latest, - corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }}, - corgibytes/freshli-cli:${{ steps.gitversion.outputs.semVer }}-${{ steps.gitversion.outputs.fullBuildMetadata }} - cache-from: type=registry,ref=corgibytes/freshli-cli:buildcache - cache-to: type=registry,ref=corgibytes/freshli-cli:buildcache,mode=max + run: | + docker buildx imagetools create \ + --tag corgibytes/freshli-cli:latest, + --tag corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }}, + --tag corgibytes/freshli-cli:${{ steps.gitversion.outputs.semVer }}-${{ steps.gitversion.outputs.fullBuildMetadata }} + ghcr.io/corgibytes/freshli-cli:latest diff --git a/Dockerfile b/Dockerfile index 3575ef02..d6f5626e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,7 +66,10 @@ RUN ./gradlew installDist ### Runtime container # Use .NET SDK as the base image, because it is required by the dotnet agent -FROM dotnet_build_platform_specific AS final +FROM debian:bullseye AS final + +# Install dependencies +RUN apt update -y && apt install -y curl gnupg2 ca-certificates # Install Java JDK RUN apt update -y && apt install -y wget apt-transport-https @@ -75,6 +78,14 @@ RUN wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee RUN echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list RUN apt update -y && apt-get install temurin-17-jdk -y +# Install dotnet SDK +WORKDIR /tmp +RUN wget https://dot.net/v1/dotnet-install.sh +RUN chmod +x dotnet-install.sh +RUN ./dotnet-install.sh --install-dir /usr/local/share/dotnet-sdk --os linux --channel 7.0 +RUN ln -s /usr/local/share/dotnet-sdk/dotnet /usr/local/bin/dotnet +ENV DOTNET_ROOT=/usr/local/share/dotnet-sdk + # Install git RUN apt update -y && apt install git lsof -y