Skip to content

Commit

Permalink
Update Dockerfile to support multiarch build (#1120)
Browse files Browse the repository at this point in the history
Replace go compile args to TARGETOS and TARGETARCH to support multiarch compile

Signed-off-by: Allen Chen <[email protected]>
  • Loading branch information
watchword authored Oct 4, 2024
1 parent 8d894b0 commit a5415af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM golang:1.17.5-alpine3.15 AS build
FROM --platform=${BUILDPLATFORM} golang:1.17.5-alpine3.15 AS build
ARG TARGETARCH
ARG TARGETOS

WORKDIR /bfe
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=`cat VERSION`"
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-X main.version=`cat VERSION`"

FROM alpine:3.15 AS run
RUN apk update && apk add --no-cache ca-certificates
Expand Down

0 comments on commit a5415af

Please sign in to comment.