From 35a471ed4ab27e24a71607c9871a78c37b39976c Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Tien Date: Mon, 30 Oct 2023 09:47:04 +0700 Subject: [PATCH] Integrade ARM support --- .github/workflows/docker-publish.yaml | 24 ++++++++++++++++++------ .github/workflows/release.yml | 12 ++++++++++-- docker-debugging-tools/Dockerfile | 20 +++++++++++--------- docker-debugging-tools/Dockerfile-sshd | 2 +- docker-debugging-tools/bin/build.sh | 4 ++-- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index 033896c..600f3ec 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -13,17 +13,29 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Install regctl + uses: iarekylew00t/regctl-installer@v1 + with: + regctl-release: v0.5.3 + - name: Login to Artifactory run: | docker login -u ${{ secrets.ARTIFACTORY_USER }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} "$ARTIFACTORY_URL" - - name: Publish Docker Image + - name: Publish The Version Docker Image + id: publish_image run: | ARMORY_TOOLS_VERSION="$(python3 -c 'import sys; print(sys.argv[1].split("/")[2])' $GITHUB_REF)-$GITHUB_SHA" ARMORY_IMAGE_NAME="$ARTIFACTORY_URL/armory-io/docker-debugging-tools:$ARMORY_TOOLS_VERSION" - ARMORY_IMAGE_NAME_LATEST="$ARTIFACTORY_URL/armory-io/docker-debugging-tools:latest" - docker build -t "$ARMORY_IMAGE_NAME" ./docker-debugging-tools/ - docker tag "$ARMORY_IMAGE_NAME" "$ARMORY_IMAGE_NAME_LATEST" + docker buildx build --push --platform linux/arm64,linux/amd64 -t "$ARMORY_IMAGE_NAME" ./docker-debugging-tools/ + echo "version_image=$ARMORY_IMAGE_NAME" >> $GITHUB_OUTPUT - docker push "$ARMORY_IMAGE_NAME" - docker push "$ARMORY_IMAGE_NAME_LATEST" + - name: Re-Tagging Docker Image Version + run: | + regctl image copy ${{ steps.publish_image.outputs.version_image }} ${{ env.ARTIFACTORY_URL }}/armory-io/docker-debugging-tools:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ff4380..9fcf2ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,10 +13,18 @@ jobs: GITHUB_REF: '${{ github.ref }}' steps: - uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker Login + run: docker login -u "${{ secrets.DOCKER_HUB_USER }}" -p "${{ secrets.DOCKER_HUB_PASS }}" + - name: Build Debugging Tools Container run: | export DOCKER_TAG="${GITHUB_REF##*/}" cd docker-debugging-tools ./bin/build.sh - docker login -u "${{ secrets.DOCKER_HUB_USER }}" -p "${{ secrets.DOCKER_HUB_PASS }}" - ./bin/push.sh diff --git a/docker-debugging-tools/Dockerfile b/docker-debugging-tools/Dockerfile index cdf75a1..e9683c0 100644 --- a/docker-debugging-tools/Dockerfile +++ b/docker-debugging-tools/Dockerfile @@ -1,7 +1,9 @@ -FROM alpine:3 +FROM --platform=$TARGETPLATFORM alpine:3 MAINTAINER Armory -ENV KUBECTL_RELEASE=1.26.2 +ARG TARGETARCH + +ENV KUBECTL_RELEASE=1.27.3 ENV AWS_IAM_AUTHENTICATOR_VERSION=0.6.2 ENV JQ_VERSION=1.6-r2 ENV AWS_CLI_VERSION=1.27.87 @@ -27,20 +29,20 @@ RUN apk update && apk add --no-cache \ && rm -rf /var/cache/apk/* # install kubectl, latest version can be found here: https://storage.googleapis.com/kubernetes-release/release/stable.txt -RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_RELEASE}/bin/linux/amd64/kubectl \ - && chmod +x ./kubectl \ - && mv ./kubectl /usr/local/bin/kubectl \ - && ln -sv /usr/local/bin/kubectl /usr/local/bin/k \ - && ln -sv /usr/local/bin/kubectl /usr/local/bin/kub +RUN curl -Lo https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_RELEASE}/bin/linux/${TARGETARCH}/kubectl \ + && chmod +x kubectl \ + && mv ./kubectl /usr/local/bin/kubectl \ + && ln -sv /usr/local/bin/kubectl /usr/local/bin/k \ + && ln -sv /usr/local/bin/kubectl /usr/local/bin/kub # install aws-iam-authenticator, latest version can be found here: https://github.com/kubernetes-sigs/aws-iam-authenticator/releases # note: for EKS you can also use `aws eks get-token` now, see https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html -RUN curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${AWS_IAM_AUTHENTICATOR_VERSION}/aws-iam-authenticator_${AWS_IAM_AUTHENTICATOR_VERSION}_linux_amd64 \ +RUN curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${AWS_IAM_AUTHENTICATOR_VERSION}/aws-iam-authenticator_${AWS_IAM_AUTHENTICATOR_VERSION}_linux_${TARGETARCH} \ && chmod +x ./aws-iam-authenticator \ && mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator # install vault, latest version can be found here: https://www.vaultproject.io/downloads.html -RUN curl -O https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip \ +RUN curl -O https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_${TARGETARCH}.zip \ && unzip vault* \ && mv vault /usr/bin/ \ && rm -rf vault* diff --git a/docker-debugging-tools/Dockerfile-sshd b/docker-debugging-tools/Dockerfile-sshd index e2b9384..d5e77ea 100644 --- a/docker-debugging-tools/Dockerfile-sshd +++ b/docker-debugging-tools/Dockerfile-sshd @@ -1,7 +1,7 @@ # # To login to the SSH server, put a public key (id_rsa.pub) in /root/.ssh/authorized_keys # -FROM alpine:3.5 +FROM alpine:3.7 RUN apk --update add --no-cache openssh bash curl diff --git a/docker-debugging-tools/bin/build.sh b/docker-debugging-tools/bin/build.sh index 3f4f10e..1f235b8 100755 --- a/docker-debugging-tools/bin/build.sh +++ b/docker-debugging-tools/bin/build.sh @@ -2,5 +2,5 @@ cd "$(dirname "$0")/.." source bin/env -docker build -t "${DOCKER_IMAGE}" . -docker build -t "${DOCKER_SSH_IMAGE}" -f Dockerfile-sshd . +docker buildx build --push --platform linux/arm64,linux/amd64 -t "${DOCKER_IMAGE}" . +docker buildx build --push --platform linux/arm64,linux/amd64 -t "${DOCKER_SSH_IMAGE}" -f Dockerfile-sshd .