Skip to content

Commit

Permalink
goos & goarch in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo committed Sep 14, 2023
1 parent b23f2a8 commit 90a5a4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 0 additions & 11 deletions Dockerfile.build

This file was deleted.

0 comments on commit 90a5a4f

Please sign in to comment.