From f9f4157a91b1c9e669ad16ed712338cb3deb373d Mon Sep 17 00:00:00 2001 From: Philipp Trulson Date: Mon, 1 Mar 2021 10:09:13 +0100 Subject: [PATCH] Build multiarch docker images (#604) * Build multiarch docker images * Build tags too --- .github/workflows/ci.yaml | 52 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 46 ++++++++++++++++++++++++++++++ Dockerfile | 8 ------ 3 files changed, 98 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index babef5545..28b97b3ba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,3 +28,55 @@ jobs: - name: Build Project run: | make + + docker_build: + runs-on: ubuntu-20.04 + name: Docker Build + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Generate image tags + shell: bash + run: | + if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then + echo "##[set-output name=tags;]quay.io/rebuy/aws-nuke:${GITHUB_HEAD_REF},docker.io/rebuy/aws-nuke:${GITHUB_HEAD_REF}" + else + echo "##[set-output name=tags;]quay.io/rebuy/aws-nuke:main,docker.io/rebuy/aws-nuke:main,\ + quay.io/rebuy/aws-nuke:latest,docker.io/rebuy/aws-nuke:latest" + fi + id: generate_tags + + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64,arm/v7 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to Quay.io + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.generate_tags.outputs.tags }} + platforms: linux/amd64,linux/arm64,linux/arm/v7 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index af5f07e32..8f8129bf4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,3 +30,49 @@ jobs: tag: ${{ github.ref }} overwrite: true file_glob: true + + docker_build: + runs-on: ubuntu-20.04 + name: Docker Build + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Generate image tags + shell: bash + run: echo "##[set-output name=tags;]quay.io/rebuy/aws-nuke:${GITHUB_REF#refs/tags/},docker.io/rebuy/aws-nuke:${GITHUB_REF#refs/tags/}" + id: generate_tags + + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64,arm/v7 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to Quay.io + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.generate_tags.outputs.tags }} + platforms: linux/amd64,linux/arm64,linux/arm/v7 diff --git a/Dockerfile b/Dockerfile index 601d9abad..1032fc46c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -# Source: https://github.com/rebuy-de/golang-template - FROM golang:1.16-alpine as builder RUN apk add --no-cache git make curl openssl @@ -8,11 +6,6 @@ RUN apk add --no-cache git make curl openssl ENV GOPATH=/go PATH=/go/bin:$PATH CGO_ENABLED=0 GO111MODULE=on RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin -ENV GO111MODULE on -# Install Go Tools -RUN go get -u golang.org/x/lint/golint - - WORKDIR /src COPY go.mod . @@ -22,7 +15,6 @@ RUN go mod download COPY . . RUN set -x \ - && make test \ && make build \ && cp /src/dist/aws-nuke /usr/local/bin/