From 43f5031d674cd367fab61f2cad992dd4bbd42f15 Mon Sep 17 00:00:00 2001 From: Derek Wang Date: Fri, 25 Sep 2020 15:03:11 -0700 Subject: [PATCH] fix(ci): Clean up multi arch build (#885) * fix(ci): fix release github action * rename * delete Dockerfile of building in docker --- .github/workflows/docker-image.yml | 42 --------------- .github/workflows/release.yml | 13 +++++ Dockerfile | 87 ++++++------------------------ Dockerfile.dev | 61 --------------------- Makefile | 2 +- 5 files changed, 31 insertions(+), 174 deletions(-) delete mode 100644 .github/workflows/docker-image.yml delete mode 100644 Dockerfile.dev diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index 5ca4233721..0000000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,42 +0,0 @@ - -name: Docker Image CI - -on: - push: - tags: - - v* - -defaults: - run: - shell: bash - -jobs: - build-linux: - name: Build & Push Linux Docker Images - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Docker Login - uses: Azure/docker-login@v1 - with: - username: ${{ secrets.DOCKERIO_USERNAME }} - password: ${{ secrets.DOCKERIO_PASSWORD }} - - name: Build & Push Linux Docker Images - env: - DOCKERIO_ORG: ${{ secrets.DOCKERIO_ORG }} - run: | - /usr/bin/docker pull -q multiarch/qemu-user-static:latest - /usr/bin/docker run --rm --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes - /usr/bin/docker buildx create --name builder --driver docker-container --use - /usr/bin/docker buildx inspect --bootstrap - - tag=$(basename $GITHUB_REF) - - targets="eventbus-controller eventsource-controller sensor-controller eventsource sensor" - for target in $targets; do - docker buildx build \ - --output "type=image,push=true" \ - --platform="linux/amd64,linux/arm64" \ - --target $target \ - --tag "${DOCKERIO_ORG}/${target}:${tag}" . - done \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2c08e5dae..67d5b87fa8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,3 +30,16 @@ jobs: files: release.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker Login + uses: Azure/docker-login@v1 + with: + username: ${{ secrets.DOCKERIO_USERNAME }} + password: ${{ secrets.DOCKERIO_PASSWORD }} + + - name: Build & Push Linux Docker Images + env: + DOCKERIO_ORG: ${{ secrets.DOCKERIO_ORG }} + run: | + tag=$(basename $GITHUB_REF) + make eventsource-image sensor-image eventbus-controller-image eventsource-controller-image sensor-controller-image IMAGE_TAG=${tag} IMAGE_NAMESPACE=${DOCKERIO_ORG} DOCKER_PUSH=true diff --git a/Dockerfile b/Dockerfile index 205ee0e3fa..031aff65d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,96 +1,44 @@ #################################################################################################### -# Builder image -# Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image -# Also used as the image in CI jobs so needs all dependencies +# base #################################################################################################### -FROM golang:1.13.4 as builder - -RUN apt-get update && apt-get --no-install-recommends install -y \ - git \ - make \ - apt-utils \ - apt-transport-https \ - ca-certificates \ - wget \ - gcc \ - zip && \ - apt-get clean \ - && rm -rf \ - /var/lib/apt/lists/* \ - /tmp/* \ - /var/tmp/* \ - /usr/share/man \ - /usr/share/doc \ - /usr/share/doc-base - -WORKDIR /tmp - -#################################################################################################### -# Argo Build stage which performs the actual build of Argo binaries -#################################################################################################### -FROM builder as build - -ARG IMAGE_OS=linux - -# Perform the build -WORKDIR /go/src/github.com/argoproj/argo-events -COPY . . -# check we can use Git -RUN git rev-parse HEAD - -# Make sure there are not prebuilt binaries -RUN rm dist/* - -# eventbus-controller -RUN . hack/image_arch.sh && make dist/eventbus-controller-linux-${IMAGE_ARCH} - -# eventsource-controller -RUN . hack/image_arch.sh && make dist/eventsource-controller-linux-${IMAGE_ARCH} - -# sensor-controller -RUN . hack/image_arch.sh && make dist/sensor-controller-linux-${IMAGE_ARCH} - -# eventsource -RUN . hack/image_arch.sh && make dist/eventsource-linux-${IMAGE_ARCH} - -# sensor -RUN . hack/image_arch.sh && make dist/sensor-linux-${IMAGE_ARCH} - +FROM golang:alpine as base +RUN apk --update add ca-certificates +RUN apk --no-cache add tzdata #################################################################################################### # eventbus-controller #################################################################################################### FROM scratch as eventbus-controller -COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=build /go/src/github.com/argoproj/argo-events/dist/eventbus-controller /bin/eventbus-controller +COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY dist/eventbus-controller /bin/eventbus-controller ENTRYPOINT [ "/bin/eventbus-controller" ] #################################################################################################### # eventsource-controller #################################################################################################### FROM scratch as eventsource-controller -COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=build /go/src/github.com/argoproj/argo-events/dist/eventsource-controller /bin/eventsource-controller +COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY dist/eventsource-controller /bin/eventsource-controller ENTRYPOINT [ "/bin/eventsource-controller" ] #################################################################################################### # sensor-controller #################################################################################################### FROM scratch as sensor-controller -COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=build /go/src/github.com/argoproj/argo-events/dist/sensor-controller /bin/sensor-controller +COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY dist/sensor-controller /bin/sensor-controller ENTRYPOINT [ "/bin/sensor-controller" ] #################################################################################################### # eventsource #################################################################################################### FROM scratch as eventsource -COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=build /go/src/github.com/argoproj/argo-events/dist/eventsource /bin/eventsource +COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY dist/eventsource /bin/eventsource ENTRYPOINT [ "/bin/eventsource" ] #################################################################################################### @@ -108,7 +56,6 @@ COPY assets/argo-linux-amd64 /usr/local/bin/argo RUN chmod +x /usr/local/bin/argo RUN argo version || true -COPY --from=build /go/src/github.com/argoproj/argo-events/dist/sensor /bin/sensor +COPY dist/sensor /bin/sensor ENTRYPOINT [ "/bin/sensor" ] - diff --git a/Dockerfile.dev b/Dockerfile.dev deleted file mode 100644 index 031aff65d0..0000000000 --- a/Dockerfile.dev +++ /dev/null @@ -1,61 +0,0 @@ -#################################################################################################### -# base -#################################################################################################### -FROM golang:alpine as base -RUN apk --update add ca-certificates -RUN apk --no-cache add tzdata - -#################################################################################################### -# eventbus-controller -#################################################################################################### -FROM scratch as eventbus-controller -COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY dist/eventbus-controller /bin/eventbus-controller -ENTRYPOINT [ "/bin/eventbus-controller" ] - -#################################################################################################### -# eventsource-controller -#################################################################################################### -FROM scratch as eventsource-controller -COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY dist/eventsource-controller /bin/eventsource-controller -ENTRYPOINT [ "/bin/eventsource-controller" ] - -#################################################################################################### -# sensor-controller -#################################################################################################### -FROM scratch as sensor-controller -COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY dist/sensor-controller /bin/sensor-controller -ENTRYPOINT [ "/bin/sensor-controller" ] - -#################################################################################################### -# eventsource -#################################################################################################### -FROM scratch as eventsource -COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY dist/eventsource /bin/eventsource -ENTRYPOINT [ "/bin/eventsource" ] - -#################################################################################################### -# sensor -#################################################################################################### -FROM alpine as sensor -RUN apk update && apk upgrade && \ - apk add --no-cache git - -COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -# Argo Workflow CLI -COPY assets/argo-linux-amd64 /usr/local/bin/argo -RUN chmod +x /usr/local/bin/argo -RUN argo version || true - -COPY dist/sensor /bin/sensor - -ENTRYPOINT [ "/bin/sensor" ] diff --git a/Makefile b/Makefile index 804c8aa19a..80da91f62d 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PACKAGE=github.com/argoproj/argo-events CURRENT_DIR=$(shell pwd) DIST_DIR=${CURRENT_DIR}/dist -DOCKERFILE:=Dockerfile.dev +DOCKERFILE:=Dockerfile VERSION=$(shell cat ${CURRENT_DIR}/VERSION) BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')