From ec786c7a4de44489e6a2ea7f9c30e33e839241a6 Mon Sep 17 00:00:00 2001 From: Mate Ory Date: Wed, 9 Sep 2020 16:36:36 +0200 Subject: [PATCH 1/5] add initial Dockerfile --- Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..51874d8f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +ARG GO_VERSION=1.15 +ARG FROM_IMAGE=alpine:latest + +FROM golang:${GO_VERSION}-alpine3.12 AS builder +RUN apk add --update --no-cache bash ca-certificates make curl git mercurial tzdata + +# Install kubectl +ARG KUBECTL_VERSION=v1.16.1 +RUN curl -L -s https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl +RUN curl -L -s https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/aws-iam-authenticator -o /usr/local/bin/aws-iam-authenticator + +RUN chmod +x /usr/local/bin/* + +RUN mkdir -p /build +WORKDIR /build + +COPY go.* /build/ +RUN go mod download + +ARG VERSION + +COPY . /build +RUN make build-release + +FROM ${FROM_IMAGE} +RUN apk add --update --no-cache openssh-client +COPY --from=builder /usr/local/bin/* /bin/ +COPY --from=builder /build/build/banzai /bin/ From 8b03a0be913be728d5309e01ac2631d17fc4e4d8 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Thu, 17 Sep 2020 10:58:29 +0200 Subject: [PATCH 2/5] update readme Signed-off-by: Peter Balogh --- Dockerfile | 2 ++ README.md | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 51874d8f..89920d34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,3 +26,5 @@ FROM ${FROM_IMAGE} RUN apk add --update --no-cache openssh-client COPY --from=builder /usr/local/bin/* /bin/ COPY --from=builder /build/build/banzai /bin/ + +ENTRYPOINT [ "/bin/banzai" ] diff --git a/README.md b/README.md index bb0b5003..f126f333 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This is a command-line interface under heavy development for the [Banzai Cloud Pipeline](https://beta.banzaicloud.io/) platform. +This is a command-line interface for the [Banzai Cloud Pipeline](https://try.pipeline.banzai.cloud/) platform. ### Installation @@ -44,3 +44,25 @@ For interactive login, just run `banzai login`, and follow the instructions give ### Use See [command reference](https://banzaicloud.com/docs/pipeline/cli/reference/) in the [official documentation](https://banzaicloud.com/docs/pipeline/cli/). + +### Use Docker image + +Logging in +``` +$ docker run --rm -v $(PWD)/banzai-cli:/root/ ghcr.io/banzaicloud/banzai-cli login --token -e https://try.pipeine.banzai.cloud/pipeline +``` + +Select organization +``` +$ docker run --rm -ti -v $(PWD)/banzai-cli:/root/ ghcr.io/banzaicloud/banzai-cli organization select +``` + +List clusters: +``` +$ docker run --rm -ti -v $(PWD)/banzai-cli:/root/ ghcr.io/banzaicloud/banzai-cli cluster list +``` + +Run cluster shell +``` +$ docker run --rm -ti -v $(PWD)/banzai-cli:/root/ ghcr.io/banzaicloud/banzai-cli cluster shell +``` From ef628b675226c238eb01953432030531e0ee7e59 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Thu, 17 Sep 2020 11:03:04 +0200 Subject: [PATCH 3/5] add docker build gh action Signed-off-by: Peter Balogh --- .github/workflows/docker.yaml | 26 ++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 00000000..9b2b77c6 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,26 @@ +name: Docker Build +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + branches: + - docker-build + +jobs: + docker: + name: Docker + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build banzai-cli + uses: docker/build-push-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.CR_PAT }} + registry: ghcr.io + repository: banzaicloud/banzai-cli + dockerfile: Dockerfile + tag_with_ref: true + add_git_labels: true + tags: latest diff --git a/README.md b/README.md index f126f333..a75bdec8 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Select organization $ docker run --rm -ti -v $(PWD)/banzai-cli:/root/ ghcr.io/banzaicloud/banzai-cli organization select ``` -List clusters: +List clusters ``` $ docker run --rm -ti -v $(PWD)/banzai-cli:/root/ ghcr.io/banzaicloud/banzai-cli cluster list ``` From 2d7c8277d585032b97c6be19cd958becbb8b004c Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Thu, 17 Sep 2020 11:44:12 +0200 Subject: [PATCH 4/5] update push-action to v2 Signed-off-by: Peter Balogh --- .github/workflows/docker.yaml | 47 ++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 9b2b77c6..c15f4a55 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -11,16 +11,45 @@ jobs: name: Docker runs-on: ubuntu-latest steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - name: Checkout code uses: actions/checkout@v2 - - name: Build banzai-cli - uses: docker/build-push-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.ref }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Determine tag or commit + uses: haya14busa/action-cond@v1 + id: refortag + with: + cond: ${{ startsWith(github.ref, 'refs/tags/') }} + if_true: ${{ github.ref }} + if_false: latest + - name: Determine image tag + id: imagetag + run: echo "::set-output name=value::${TAG_OR_BRANCH##*/}" + env: + TAG_OR_BRANCH: ${{ steps.refortag.outputs.value }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 with: - username: ${{ github.actor }} - password: ${{ secrets.CR_PAT }} registry: ghcr.io - repository: banzaicloud/banzai-cli - dockerfile: Dockerfile - tag_with_ref: true - add_git_labels: true - tags: latest + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Build banzai-cli + uses: docker/build-push-action@v2 + with: + tags: ghcr.io/banzaicloud/banzai-cli:${{ steps.imagetag.outputs.value }} + file: Dockerfile + push: true + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache From 3cb2c540e241d395cad43eda031bfc94b5519ca1 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Thu, 17 Sep 2020 14:04:27 +0200 Subject: [PATCH 5/5] remove push on branch Signed-off-by: Peter Balogh --- .github/workflows/docker.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index c15f4a55..a852c539 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -3,8 +3,6 @@ on: push: tags: - "[0-9]+.[0-9]+.[0-9]+" - branches: - - docker-build jobs: docker: @@ -48,7 +46,9 @@ jobs: - name: Build banzai-cli uses: docker/build-push-action@v2 with: - tags: ghcr.io/banzaicloud/banzai-cli:${{ steps.imagetag.outputs.value }} + tags: | + ghcr.io/banzaicloud/banzai-cli:latest + ghcr.io/banzaicloud/banzai-cli:${{ steps.imagetag.outputs.value }} file: Dockerfile push: true cache-from: type=local,src=/tmp/.buildx-cache