Skip to content

Commit

Permalink
Also pass platform on from
Browse files Browse the repository at this point in the history
  • Loading branch information
danquack committed Nov 24, 2023
1 parent d35d09a commit af46262
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,20 +1,22 @@
# Use an official Golang runtime as the base image
FROM golang:1.18 as builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18 as builder

ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM
ARG BUILDPLATFORM

# Set the working directory in the container
WORKDIR /app

# Copy the source code to the container
COPY . .

ARG TARGETOS
ARG TARGETARCH

# Build the application
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build

# Use a lightweight Alpine image as the base image for the final container
FROM alpine:latest
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:latest

# Set the working directory in the container
WORKDIR /app
Expand Down

0 comments on commit af46262

Please sign in to comment.