Skip to content

Commit

Permalink
fix: BUILDPLATFORM of final image (#453)
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Yang <[email protected]>
  • Loading branch information
reaver-flomesh authored Nov 20, 2024
1 parent b1f5d63 commit 190ee95
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o fsm-bootstrap -ldflags "$LDFLAGS" ./cmd/fsm-bootstrap

FROM --platform=$BUILDPLATFORM gcr.io/distroless/static
FROM gcr.io/distroless/static
COPY --from=builder /fsm/fsm-bootstrap /
COPY ./cmd/fsm-bootstrap/crds /fsm-crds/
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-connector
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o fsm-connector -ldflags "$LDFLAGS" ./cmd/fsm-connector

FROM --platform=$BUILDPLATFORM gcr.io/distroless/static
FROM gcr.io/distroless/static
COPY --from=builder /fsm/fsm-connector /
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-controller
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o fsm-controller -ldflags "$LDFLAGS" ./cmd/fsm-controller

FROM --platform=$BUILDPLATFORM gcr.io/distroless/static
FROM gcr.io/distroless/static
COPY --from=builder /fsm/fsm-controller /
3 changes: 2 additions & 1 deletion dockerfiles/Dockerfile.fsm-crds
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ ARG TARGETPLATFORM
# amd64 Mac, so download the kubectl binary in a stage running the native arch.
RUN wget https://dl.k8s.io/release/v1.22.2/bin/$TARGETPLATFORM/kubectl -O /bin/kubectl && \
chmod +x /bin/kubectl
FROM --platform=$BUILDPLATFORM busybox:1.36

FROM busybox:1.36
COPY --from=builder /bin/kubectl /bin
COPY ./cmd/fsm-bootstrap/crds/* /fsm-crds/
ENTRYPOINT ["/bin/kubectl"]
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-curl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# syntax = docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM flomesh/curl:latest
FROM flomesh/curl:latest
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-gateway
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o bin/fsm-gateway -ldflags "$LDFLAGS" ./cmd/fsm-gateway

# Build the final image
FROM --platform=$BUILDPLATFORM flomesh/pipy:1.5.5-$DISTROLESS_TAG
FROM flomesh/pipy:1.5.5-$DISTROLESS_TAG
WORKDIR /
COPY --from=builder /fsm/bin/fsm-gateway .

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-healthcheck
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o fsm-healthcheck -ldflags "$LDFLAGS" ./cmd/fsm-healthcheck

FROM --platform=$BUILDPLATFORM gcr.io/distroless/static
FROM gcr.io/distroless/static
COPY --from=builder /fsm/fsm-healthcheck /
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-ingress
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o bin/fsm-ingress -ldflags "$LDFLAGS" ./cmd/fsm-ingress

# Build the final image
FROM --platform=$BUILDPLATFORM flomesh/pipy:1.5.5-$DISTROLESS_TAG
FROM flomesh/pipy:1.5.5-$DISTROLESS_TAG
WORKDIR /
COPY --from=builder /fsm/bin/fsm-ingress .

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-injector
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o fsm-injector -ldflags "$LDFLAGS" ./cmd/fsm-injector

FROM --platform=$BUILDPLATFORM gcr.io/distroless/static
FROM gcr.io/distroless/static
COPY --from=builder /fsm/fsm-injector /
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-preinstall
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o fsm-preinstall -ldflags "$LDFLAGS" ./cmd/fsm-preinstall

FROM --platform=$BUILDPLATFORM gcr.io/distroless/static
FROM gcr.io/distroless/static
COPY --from=builder /fsm/fsm-preinstall /
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-sidecar-init
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# syntax = docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM flomesh/alpine:3
FROM flomesh/alpine:3
RUN apk add --no-cache iptables
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.fsm-xnetmgmt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o fsm-xnet-mgmt -ldflags "$LDFLAGS" ./cmd/fsm-xnetmgmt

#FROM gcr.io/distroless/static
FROM --platform=$BUILDPLATFORM ubuntu:22.04
FROM ubuntu:22.04
COPY --from=builder /fsm/fsm-xnet-mgmt /
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.pipy-debian
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax = docker/dockerfile:1.4
# Build the pipy binary
FROM --platform=$BUILDPLATFORM debian:12 AS builder
FROM debian:12 AS builder

ENV pkg_prefix /usr/local
ENV pkg_confdir /etc/pipy
Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/Dockerfile.pipy-nonroot
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ ARG DISTROLESS_TAG
ARG PIPY_VERSION

# Build the pipy binary
FROM --platform=$BUILDPLATFORM flomesh/pipy:${PIPY_VERSION}-debian AS builder
FROM flomesh/pipy:${PIPY_VERSION}-debian AS builder

# Build the final image
FROM --platform=$BUILDPLATFORM gcr.io/distroless/cc-debian12:$DISTROLESS_TAG
FROM gcr.io/distroless/cc-debian12:$DISTROLESS_TAG
WORKDIR /
COPY --from=builder /usr/local/bin/pipy /usr/local/bin/pipy

Expand Down

0 comments on commit 190ee95

Please sign in to comment.