Skip to content

Commit

Permalink
Adjusting Dockerfile to do a native compile + emulated image build
Browse files Browse the repository at this point in the history
  • Loading branch information
bathina2 committed Dec 2, 2024
1 parent 95bf2c2 commit f07da37
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM golang:1.22-bookworm AS builder
ARG BUILDPLATFROM

FROM --platform=$BUILDPLATFORM golang:1.22-bookworm AS builder

ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFROM

ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
GOBIN=/dist
GOARCH=${TARGETARCH}

WORKDIR /app

Expand All @@ -18,9 +20,9 @@ RUN go mod download

COPY . .

RUN go install -ldflags="-w -s" .
RUN go build -o /dist/kubestr -ldflags="-w -s" .

FROM alpine:3.19
FROM --platform=$TARGETPLATFORM alpine:3.19

Check warning on line 25 in Dockerfile

View workflow job for this annotation

GitHub Actions / push

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

RUN apk --no-cache add fio

Expand Down

0 comments on commit f07da37

Please sign in to comment.