diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml new file mode 100644 index 00000000..505e037f --- /dev/null +++ b/.github/workflows/docker-push.yml @@ -0,0 +1,108 @@ +name: Build octopus-cli Docker image + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +env: + REGISTRY_IMAGE: octopusdeploy/octopus-cli + +jobs: + build-linux: + strategy: + matrix: + os: + - ubuntu-latest + platform: + - linux/amd64 + - linux/arm64 + runs-on: ${{ matrix.os }} + env: + VERSION: ${{ github.ref_name }} + steps: + + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + echo "PLATFORM_ARCH=${platform//[linux\/]/}" >> $GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ secrets.INTERNAL_DOCKER_REGISTRY_URL }} + username: ${{ secrets.INTERNAL_DOCKER_READ_ONLY_USER_NAME }} + password: ${{ secrets.INTERNAL_DOCKER_READ_ONLY_ACCESS_TOKEN }} + + - name: Build and push by digest + id: build + uses: docker/build-push-action@v5 + with: + context: docker/${{ env.PLATFORM_PAIR }} + platforms: ${{ matrix.platform }} + provenance: false + build-args: | + OCTOPUS_CLI_VERSION=${{ env.VERSION }} + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + merge: + needs: [build-linux] + runs-on: ubuntu-latest + env: + VERSION_NUMBER: ${{ github.ref_name }} + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + ${{ env.VERSION_NUMBER }} + latest + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ secrets.INTERNAL_DOCKER_REGISTRY_URL }} + username: ${{ secrets.INTERNAL_DOCKER_READ_ONLY_USER_NAME }} + password: ${{ secrets.INTERNAL_DOCKER_READ_ONLY_ACCESS_TOKEN }} + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} \ No newline at end of file diff --git a/docker/linux-amd64/Dockerfile b/docker/linux-amd64/Dockerfile new file mode 100644 index 00000000..1a0ff805 --- /dev/null +++ b/docker/linux-amd64/Dockerfile @@ -0,0 +1,18 @@ +FROM --platform=linux/amd64 alpine:latest + +ARG OCTOPUS_CLI_VERSION=2.4.0 + +RUN apk update && apk upgrade && apk add --no-cache bash curl + +RUN curl -L https://github.com/OctopusDeploy/cli/raw/main/scripts/install.sh | VERSION=v$OCTOPUS_CLI_VERSION bash + +LABEL \ + org.label-schema.schema-version="1.0" \ + org.label-schema.name="Octopus Deploy CLI" \ + org.label-schema.vendor="Octopus Deploy" \ + org.label-schema.url="https://octopus.com" \ + org.label-schema.vcs-url="https://github.com/OctopusDeploy/cli" \ + org.label-schema.license="Apache" \ + org.label-schema.description="Octopus Deploy CLI: octopus" + +ENTRYPOINT ["octopus"] \ No newline at end of file diff --git a/docker/linux-arm64/Dockerfile b/docker/linux-arm64/Dockerfile new file mode 100644 index 00000000..c4fda8cb --- /dev/null +++ b/docker/linux-arm64/Dockerfile @@ -0,0 +1,18 @@ +FROM --platform=linux/arm64 arm64v8/alpine:latest + +ARG OCTOPUS_CLI_VERSION=2.4.0 + +RUN apk update && apk upgrade && apk add --no-cache bash curl + +RUN curl -L https://github.com/OctopusDeploy/cli/raw/main/scripts/install.sh | VERSION=v$OCTOPUS_CLI_VERSION bash + +LABEL \ + org.label-schema.schema-version="1.0" \ + org.label-schema.name="Octopus Deploy CLI" \ + org.label-schema.vendor="Octopus Deploy" \ + org.label-schema.url="https://octopus.com" \ + org.label-schema.vcs-url="https://github.com/OctopusDeploy/cli" \ + org.label-schema.license="Apache" \ + org.label-schema.description="Octopus Deploy CLI: octopus" + +ENTRYPOINT ["octopus"] \ No newline at end of file