Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker image support multi OS archs #1462

Merged
merged 7 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

9 changes: 4 additions & 5 deletions hack/build-and-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
docker buildx build --build-arg COMMIT=${COMMIT} --build-arg TAG=${BINARY_TAG} \
-t ${REGISTRY}/admission-server:${GIT_TAG} . --platform linux/amd64,linux/arm64 --push

# 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}
docker buildx build --build-arg COMMIT=${COMMIT} --build-arg TAG=${BINARY_TAG} \
-t ${REGISTRY}/admission-server:${VERSION_TAG} . --platform linux/amd64,linux/arm64 --push
wilsonwu marked this conversation as resolved.
Show resolved Hide resolved