-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from banzaicloud/docker-build
build docker image
- Loading branch information
Showing
3 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters