Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push docker image #407

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -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 }}
18 changes: 18 additions & 0 deletions docker/linux-amd64/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
18 changes: 18 additions & 0 deletions docker/linux-arm64/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Loading