Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
KOMPANION_VERSION=${{ steps.get_tag.outputs.TAG }}
push: true
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Step 1: Modules caching
FROM golang:1.22.5-alpine as modules
FROM --platform=${BUILDPLATFORM} golang:1.22.5-alpine as modules
COPY go.mod go.sum /modules/
WORKDIR /modules
RUN go mod download

# Step 2: Builder
FROM golang:1.22.5-alpine as builder
FROM --platform=${BUILDPLATFORM} golang:1.22.5-alpine as builder
RUN apk add --update gcc musl-dev
COPY --from=modules /go/pkg /go/pkg
COPY . /app
Expand All @@ -14,11 +14,13 @@ WORKDIR /app
ARG KOMPANION_VERSION=local
ENV KOMPANION_VERSION=$KOMPANION_VERSION

RUN GOOS=linux GOARCH=amd64 \
go build -ldflags "-X main.Version=$KOMPANION_VERSION" -tags migrate -o /bin/app ./cmd/app
ARG TARGETARCH
RUN GOOS=linux GOARCH=${TARGETARCH:-amd64} \
go build -ldflags "-X main.Version=$KOMPANION_VERSION" -tags migrate -o /bin/app ./cmd/app


# Step 3: Final
FROM golang:1.22.5-alpine
FROM --platform=${TARGETPLATFORM} golang:1.22.5-alpine
ENV GIN_MODE=release

WORKDIR /
Expand Down
Loading