diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 00000000..a852c539 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,55 @@ +name: Docker Build +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + docker: + 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: 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: + registry: ghcr.io + 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:latest + 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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..89920d34 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +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/ + +ENTRYPOINT [ "/bin/banzai" ] diff --git a/README.md b/README.md index bb0b5003..a75bdec8 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 +```