From 90a5a4f578a87dc31e8f9975f6c5ce773894fe0f Mon Sep 17 00:00:00 2001 From: Matthieu Moquet Date: Thu, 14 Sep 2023 21:36:46 +0200 Subject: [PATCH] goos & goarch in dockerfile --- .github/workflows/docker.yaml | 19 +++++++------------ Dockerfile | 4 ++++ Dockerfile.build | 11 ----------- 3 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 Dockerfile.build diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 06aa8f6..c7bef01 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -69,6 +69,9 @@ jobs: run: | echo "BUILD_ID=${GITHUB_REF##*/}" >> $GITHUB_ENV + - name: 'Generate App Version' + run: echo "VERSION=$(make version)" >> $GITHUB_ENV + - name: Log in to the Container registry uses: docker/login-action@v2 with: @@ -90,25 +93,17 @@ jobs: type=raw,value=${{ env.BUILD_ID }} type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - - # Build binary outside of Docker - - name: 'Build binary' - run: | - export GOOS=${{ matrix.os }} - export GOARCH=${{ matrix.arch }} - make build - - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - file: Dockerfile.build push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: ${{ matrix.os }}/${{ matrix.arch }} cache-from: type=gha,scope=${{ matrix.os }}/${{ matrix.arch }} cache-to: type=gha,mode=max,scope=${{ matrix.os }}/${{ matrix.arch }} + build-args: | + GOOS=${{ matrix.os }} + GOARCH=${{ matrix.arch }} + VERSION=${{ env.VERSION }} diff --git a/Dockerfile b/Dockerfile index 621c105..07c4f55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ # Builder FROM golang:1.20-alpine3.18 as builder +ARG GOOS +ENV GOOS=$GOOS +ARG GOARCH +ENV GOARCH=$GOARCH ARG VERSION="0.0.0-build" ENV VERSION=$VERSION diff --git a/Dockerfile.build b/Dockerfile.build deleted file mode 100644 index a46a6ea..0000000 --- a/Dockerfile.build +++ /dev/null @@ -1,11 +0,0 @@ -# Build the docker image with precompiled binary -FROM alpine:3.18 -RUN apk upgrade && apk add --no-cache bash curl - -RUN addgroup -g 1001 app -RUN adduser -D -G app -u 1001 app - -COPY ./build/cosmos-validator-watcher / - -WORKDIR / -ENTRYPOINT ["/cosmos-validator-watcher"]