diff --git a/Dockerfile b/Dockerfile index eaa859a9b1..c73c441559 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,13 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.18 AS build-env +ARG BUILDPLATFORM=linux/amd64 +FROM --platform=$BUILDPLATFORM golang:1.18 AS build-env RUN mkdir -p /go/src/sig.k8s.io/gateway-api WORKDIR /go/src/sig.k8s.io/gateway-api COPY . . +ARG TARGETARCH ARG TAG ARG COMMIT -RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -a -o gateway-api-webhook \ +RUN CGO_ENABLED=0 GOARCH=$TARGETARCH GOOS=linux go build -a -o gateway-api-webhook \ -ldflags "-s -w -X main.VERSION=$TAG -X main.COMMIT=$COMMIT" ./cmd/admission FROM gcr.io/distroless/static:nonroot diff --git a/README.md b/README.md index 2bb66e2130..e3d885fbd9 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,3 @@ Participation in the Kubernetes community is governed by the [spec]: https://gateway-api.sigs.k8s.io/v1alpha2/references/spec [concepts]: https://gateway-api.sigs.k8s.io/concepts/api-overview [security-model]: https://gateway-api.sigs.k8s.io/concepts/security-model - diff --git a/hack/build-and-push.sh b/hack/build-and-push.sh index 5488eefd8c..e5d18ec8f0 100755 --- a/hack/build-and-push.sh +++ b/hack/build-and-push.sh @@ -64,10 +64,9 @@ fi # First, build the image, with the version info passed in. # Note that an image will *always* be built tagged with the GIT_TAG, so we know when it was built. -docker build --build-arg COMMIT=${COMMIT} --build-arg TAG=${BINARY_TAG} \ - -t ${REGISTRY}/admission-server:${GIT_TAG} . -docker push ${REGISTRY}/admission-server:${GIT_TAG} - -# Then, we add an extra version tag - either :latest or semver. -docker tag ${REGISTRY}/admission-server:${GIT_TAG} ${REGISTRY}/admission-server:${VERSION_TAG} -docker push ${REGISTRY}/admission-server:${VERSION_TAG} +# And, we add an extra version tag - either :latest or semver. +# The buildx integrate build and push in one line. +docker buildx build --build-arg COMMIT=${COMMIT} --build-arg TAG=${BINARY_TAG} \ + -t ${REGISTRY}/admission-server:${GIT_TAG} \ + -t ${REGISTRY}/admission-server:${VERSION_TAG} \ + . --platform linux/amd64,linux/arm64 --push