From bc99e8ddbc618955e0a44f414df92618d6933929 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Thu, 13 Oct 2022 11:21:59 +0900 Subject: [PATCH 01/47] chore: use buildx to build grpc-ping-go Signed-off-by: kahirokunn --- code-samples/serving/grpc-ping-go/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/grpc-ping-go/README.md b/code-samples/serving/grpc-ping-go/README.md index 20d166c1fd..70ed8d5771 100644 --- a/code-samples/serving/grpc-ping-go/README.md +++ b/code-samples/serving/grpc-ping-go/README.md @@ -32,11 +32,8 @@ for production containers. Replace `{username}` with your Docker Hub username then run the commands: ```bash - # Build the container on your local machine. - docker build --tag "{username}/grpc-ping-go" . - - # Push the container to docker registry. - docker push "{username}/grpc-ping-go" + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/grpc-ping-go" --push . ``` 3. Update the `service.yaml` file in the project to reference the published image from step 1. From b9803d2a653dce8c7dd9676b9da63826985d462a Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Thu, 13 Jul 2023 19:58:52 +0900 Subject: [PATCH 02/47] chore: support grpc-ping-go multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/grpc-ping-go/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code-samples/serving/grpc-ping-go/Dockerfile b/code-samples/serving/grpc-ping-go/Dockerfile index 9aad9b4c2e..3fba178798 100644 --- a/code-samples/serving/grpc-ping-go/Dockerfile +++ b/code-samples/serving/grpc-ping-go/Dockerfile @@ -17,6 +17,9 @@ # https://hub.docker.com/_/golang FROM golang as builder +ARG TARGETOS +ARG TARGETARCH + # Copy local code to the container image. WORKDIR /go/src/github.com/knative/docs/code-samples/serving/grpc-ping-go COPY . ./ @@ -26,8 +29,8 @@ RUN go mod tidy # Build the command inside the container. # To facilitate gRPC testing, this container includes a client command. -RUN CGO_ENABLED=0 go build -tags=grpcping -o ./ping-server -RUN CGO_ENABLED=0 go build -tags=grpcping -o ./ping-client ./client +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -tags=grpcping -o ./ping-server +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -tags=grpcping -o ./ping-client ./client # Use a Docker multi-stage build to create a lean production image. # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds From a4b813e3a5cb30abf684c7262236c328477159fa Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 12:58:43 +0900 Subject: [PATCH 03/47] chore: support helloworld-clojure multiple architecture Signed-off-by: kahirokunn --- .../community/serving/helloworld-clojure/README.md | 7 ++----- code-samples/community/serving/helloworld-clojure/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-clojure/README.md b/code-samples/community/serving/helloworld-clojure/README.md index 8a9d2406a3..ef0cd6b734 100644 --- a/code-samples/community/serving/helloworld-clojure/README.md +++ b/code-samples/community/serving/helloworld-clojure/README.md @@ -109,11 +109,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-clojure . - - # Push the container to docker registry - docker push {username}/helloworld-clojure + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-clojure" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you diff --git a/code-samples/community/serving/helloworld-clojure/index.md b/code-samples/community/serving/helloworld-clojure/index.md index 8a9d2406a3..ef0cd6b734 100644 --- a/code-samples/community/serving/helloworld-clojure/index.md +++ b/code-samples/community/serving/helloworld-clojure/index.md @@ -109,11 +109,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-clojure . - - # Push the container to docker registry - docker push {username}/helloworld-clojure + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-clojure" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From c2da2eaf320e07b6b64ba61a301caec047a7b9d2 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:00:59 +0900 Subject: [PATCH 04/47] chore: support helloworld-dart multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-dart/README.md | 7 ++----- code-samples/community/serving/helloworld-dart/index.md | 9 +++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/code-samples/community/serving/helloworld-dart/README.md b/code-samples/community/serving/helloworld-dart/README.md index 3f50d54f53..ec42da4e65 100644 --- a/code-samples/community/serving/helloworld-dart/README.md +++ b/code-samples/community/serving/helloworld-dart/README.md @@ -64,11 +64,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-dart . - - # Push the container to docker registry - docker push {username}/helloworld-dart + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-dart" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you diff --git a/code-samples/community/serving/helloworld-dart/index.md b/code-samples/community/serving/helloworld-dart/index.md index 2031d223a8..ec42da4e65 100644 --- a/code-samples/community/serving/helloworld-dart/index.md +++ b/code-samples/community/serving/helloworld-dart/index.md @@ -8,7 +8,7 @@ that you can use for testing. It reads in the env variable `TARGET` and prints ## Prerequisites - A Kubernetes cluster with Knative installed and DNS configured. Follow the - [Knative installation instructions](https://knative.dev/docs/install/) if + [Knative installation instructions](https://knative.dev/docs/install/) if you need to create one. - [Docker](https://www.docker.com) installed and running on your local machine, and a Docker Hub account configured (we'll use it for a container registry). @@ -64,11 +64,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-dart . - - # Push the container to docker registry - docker push {username}/helloworld-dart + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-dart" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From f762e054c5a3830c53fe1cd9f263178b7a3537db Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:02:30 +0900 Subject: [PATCH 05/47] chore: support helloworld-deno multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-deno/README.md | 7 ++----- code-samples/community/serving/helloworld-deno/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-deno/README.md b/code-samples/community/serving/helloworld-deno/README.md index 0e1d9e478b..ba0452e35b 100644 --- a/code-samples/community/serving/helloworld-deno/README.md +++ b/code-samples/community/serving/helloworld-deno/README.md @@ -83,11 +83,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-deno . - - # Push the container to docker registry - docker push {username}/helloworld-deno + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-deno" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you diff --git a/code-samples/community/serving/helloworld-deno/index.md b/code-samples/community/serving/helloworld-deno/index.md index 76f4ea523b..e41d7b7e51 100644 --- a/code-samples/community/serving/helloworld-deno/index.md +++ b/code-samples/community/serving/helloworld-deno/index.md @@ -83,11 +83,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-deno . - - # Push the container to docker registry - docker push {username}/helloworld-deno + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-deno" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From f94c327d7f0bfebeb4fb9e91c843883fb05fe466 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:03:41 +0900 Subject: [PATCH 06/47] chore: support helloworld-elixir multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-elixir/README.md | 7 ++----- code-samples/community/serving/helloworld-elixir/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-elixir/README.md b/code-samples/community/serving/helloworld-elixir/README.md index 7f8029fe43..62ec1612ae 100644 --- a/code-samples/community/serving/helloworld-elixir/README.md +++ b/code-samples/community/serving/helloworld-elixir/README.md @@ -132,11 +132,8 @@ above. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-elixir . - - # Push the container to docker registry - docker push {username}/helloworld-elixir + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-elixir" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you diff --git a/code-samples/community/serving/helloworld-elixir/index.md b/code-samples/community/serving/helloworld-elixir/index.md index 7f8029fe43..62ec1612ae 100644 --- a/code-samples/community/serving/helloworld-elixir/index.md +++ b/code-samples/community/serving/helloworld-elixir/index.md @@ -132,11 +132,8 @@ above. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-elixir . - - # Push the container to docker registry - docker push {username}/helloworld-elixir + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-elixir" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From 08f9d7b2c5f9bfefcdfc64317961a0ac12d3000a Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:05:12 +0900 Subject: [PATCH 07/47] chore: support helloworld-haskell multiple architecture Signed-off-by: kahirokunn --- .../community/serving/helloworld-haskell/README.md | 7 ++----- code-samples/community/serving/helloworld-haskell/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-haskell/README.md b/code-samples/community/serving/helloworld-haskell/README.md index 9368845be4..fa31df862d 100644 --- a/code-samples/community/serving/helloworld-haskell/README.md +++ b/code-samples/community/serving/helloworld-haskell/README.md @@ -135,11 +135,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-haskell . - - # Push the container to docker registry - docker push {username}/helloworld-haskell + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-haskell" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you diff --git a/code-samples/community/serving/helloworld-haskell/index.md b/code-samples/community/serving/helloworld-haskell/index.md index 9368845be4..fa31df862d 100644 --- a/code-samples/community/serving/helloworld-haskell/index.md +++ b/code-samples/community/serving/helloworld-haskell/index.md @@ -135,11 +135,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-haskell . - - # Push the container to docker registry - docker push {username}/helloworld-haskell + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-haskell" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you From 6c3c5b9144e1d2bd32cfae0f2422b1526adb4f2e Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:05:55 +0900 Subject: [PATCH 08/47] chore: support helloworld-java-micronaut multiple architecture Signed-off-by: kahirokunn --- .../community/serving/helloworld-java-micronaut/README.md | 7 ++----- .../community/serving/helloworld-java-micronaut/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-java-micronaut/README.md b/code-samples/community/serving/helloworld-java-micronaut/README.md index 940d6e7430..20ef5e25d1 100644 --- a/code-samples/community/serving/helloworld-java-micronaut/README.md +++ b/code-samples/community/serving/helloworld-java-micronaut/README.md @@ -215,11 +215,8 @@ your sample app to your cluster: following commands with your Docker Hub username. ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-java-micronaut . - - # Push the container to docker registry - docker push {username}/helloworld-java-micronaut + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java-micronaut" --push . ``` 1. Now that your container image is in the registry, you can deploy it to your diff --git a/code-samples/community/serving/helloworld-java-micronaut/index.md b/code-samples/community/serving/helloworld-java-micronaut/index.md index 940d6e7430..20ef5e25d1 100644 --- a/code-samples/community/serving/helloworld-java-micronaut/index.md +++ b/code-samples/community/serving/helloworld-java-micronaut/index.md @@ -215,11 +215,8 @@ your sample app to your cluster: following commands with your Docker Hub username. ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-java-micronaut . - - # Push the container to docker registry - docker push {username}/helloworld-java-micronaut + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java-micronaut" --push . ``` 1. Now that your container image is in the registry, you can deploy it to your From 1fa16cab493f63ee3630245e59748e8da224f518 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:09:24 +0900 Subject: [PATCH 09/47] chore: support helloworld-java-quarkus multiple architecture Signed-off-by: kahirokunn --- .../serving/helloworld-java-quarkus/README.md | 11 ++++------- .../serving/helloworld-java-quarkus/index.md | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/code-samples/community/serving/helloworld-java-quarkus/README.md b/code-samples/community/serving/helloworld-java-quarkus/README.md index 0d12d03262..bc10c06198 100644 --- a/code-samples/community/serving/helloworld-java-quarkus/README.md +++ b/code-samples/community/serving/helloworld-java-quarkus/README.md @@ -218,15 +218,12 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-java-quarkus . + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java-quarkus" --push . # (OR) - # Build the container on your local machine - Quarkus native mode - docker build -t {username}/helloworld-java-quarkus -f Dockerfile.native . - - # Push the container to docker registry - docker push {username}/helloworld-java-quarkus + # Build and push the container on your local machine. - Quarkus native mode + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java-quarkus" --push . -f Dockerfile.native ``` 1. After the build has completed and the container is pushed to docker hub, you diff --git a/code-samples/community/serving/helloworld-java-quarkus/index.md b/code-samples/community/serving/helloworld-java-quarkus/index.md index 317b95d298..1e5ea02651 100644 --- a/code-samples/community/serving/helloworld-java-quarkus/index.md +++ b/code-samples/community/serving/helloworld-java-quarkus/index.md @@ -217,15 +217,12 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-java-quarkus . + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java-quarkus" --push . # (OR) - # Build the container on your local machine - Quarkus native mode - docker build -t {username}/helloworld-java-quarkus -f Dockerfile.native . - - # Push the container to docker registry - docker push {username}/helloworld-java-quarkus + # Build and push the container on your local machine. - Quarkus native mode + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java-quarkus" --push . -f Dockerfile.native ``` 1. After the build has completed and the container is pushed to docker hub, you From f4cbe358ce95f74ca86608479df15767deab9e11 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:10:16 +0900 Subject: [PATCH 10/47] chore: support helloworld-r multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-r/README.md | 7 ++----- code-samples/community/serving/helloworld-r/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-r/README.md b/code-samples/community/serving/helloworld-r/README.md index 3ba50d976c..3b9001389a 100644 --- a/code-samples/community/serving/helloworld-r/README.md +++ b/code-samples/community/serving/helloworld-r/README.md @@ -131,11 +131,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-r . - - # Push the container to docker registry - docker push {username}/helloworld-r + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-r" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you diff --git a/code-samples/community/serving/helloworld-r/index.md b/code-samples/community/serving/helloworld-r/index.md index 3ba50d976c..3b9001389a 100644 --- a/code-samples/community/serving/helloworld-r/index.md +++ b/code-samples/community/serving/helloworld-r/index.md @@ -131,11 +131,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-r . - - # Push the container to docker registry - docker push {username}/helloworld-r + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-r" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From 10abcecb7ce74b4aac5253e0be64436f5443c1d3 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:11:00 +0900 Subject: [PATCH 11/47] chore: support helloworld-rserver multiple architecture Signed-off-by: kahirokunn --- .../community/serving/helloworld-rserver/README.md | 7 ++----- code-samples/community/serving/helloworld-rserver/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-rserver/README.md b/code-samples/community/serving/helloworld-rserver/README.md index 66177bea36..9f43b0d536 100644 --- a/code-samples/community/serving/helloworld-rserver/README.md +++ b/code-samples/community/serving/helloworld-rserver/README.md @@ -102,11 +102,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-rserver . - - # Push the container to docker registry - docker push {username}/helloworld-rserver + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-rserver" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you diff --git a/code-samples/community/serving/helloworld-rserver/index.md b/code-samples/community/serving/helloworld-rserver/index.md index 66177bea36..9f43b0d536 100644 --- a/code-samples/community/serving/helloworld-rserver/index.md +++ b/code-samples/community/serving/helloworld-rserver/index.md @@ -102,11 +102,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-rserver . - - # Push the container to docker registry - docker push {username}/helloworld-rserver + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-rserver" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From 051535a3a591f01a96787f12918a61e59aed9ac0 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:11:43 +0900 Subject: [PATCH 12/47] chore: support helloworld-rust multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-rust/README.md | 7 ++----- code-samples/community/serving/helloworld-rust/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-rust/README.md b/code-samples/community/serving/helloworld-rust/README.md index 0736b00230..e16b23a70c 100644 --- a/code-samples/community/serving/helloworld-rust/README.md +++ b/code-samples/community/serving/helloworld-rust/README.md @@ -136,11 +136,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-rust . - - # Push the container to docker registry - docker push {username}/helloworld-rust + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-rust" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you diff --git a/code-samples/community/serving/helloworld-rust/index.md b/code-samples/community/serving/helloworld-rust/index.md index 8f9cdc9487..5370e14222 100644 --- a/code-samples/community/serving/helloworld-rust/index.md +++ b/code-samples/community/serving/helloworld-rust/index.md @@ -136,11 +136,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-rust . - - # Push the container to docker registry - docker push {username}/helloworld-rust + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-rust" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you From aa3c156cb623f2f092dc4102aa522123598574d7 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:12:30 +0900 Subject: [PATCH 13/47] chore: support helloworld-swift multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-swift/README.md | 7 ++----- code-samples/community/serving/helloworld-swift/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-swift/README.md b/code-samples/community/serving/helloworld-swift/README.md index 7d1350ec3c..28174a81a7 100644 --- a/code-samples/community/serving/helloworld-swift/README.md +++ b/code-samples/community/serving/helloworld-swift/README.md @@ -116,11 +116,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-swift . - - # Push the container to docker registry - docker push {username}/helloworld-swift + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-swift" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you diff --git a/code-samples/community/serving/helloworld-swift/index.md b/code-samples/community/serving/helloworld-swift/index.md index 7d1350ec3c..28174a81a7 100644 --- a/code-samples/community/serving/helloworld-swift/index.md +++ b/code-samples/community/serving/helloworld-swift/index.md @@ -116,11 +116,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-swift . - - # Push the container to docker registry - docker push {username}/helloworld-swift + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-swift" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you From e483893689e58cde53025a25334b113dd6a1dce1 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:13:07 +0900 Subject: [PATCH 14/47] chore: support helloworld-vertx multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-vertx/README.md | 7 ++----- code-samples/community/serving/helloworld-vertx/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/helloworld-vertx/README.md b/code-samples/community/serving/helloworld-vertx/README.md index 373e473b64..d0976761a6 100644 --- a/code-samples/community/serving/helloworld-vertx/README.md +++ b/code-samples/community/serving/helloworld-vertx/README.md @@ -183,11 +183,8 @@ your sample app to your cluster: following commands with your Docker Hub username. ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-vertx . - - # Push the container to docker registry - docker push {username}/helloworld-vertx + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-vertx" --push . ``` 1. Now that your container image is in the registry, you can deploy it to your diff --git a/code-samples/community/serving/helloworld-vertx/index.md b/code-samples/community/serving/helloworld-vertx/index.md index 373e473b64..d0976761a6 100644 --- a/code-samples/community/serving/helloworld-vertx/index.md +++ b/code-samples/community/serving/helloworld-vertx/index.md @@ -183,11 +183,8 @@ your sample app to your cluster: following commands with your Docker Hub username. ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-vertx . - - # Push the container to docker registry - docker push {username}/helloworld-vertx + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-vertx" --push . ``` 1. Now that your container image is in the registry, you can deploy it to your From 6ec0d50f404763b5880ea07f1b70cfb861824ed3 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:23:40 +0900 Subject: [PATCH 15/47] chore: support iris-classifier multiple architecture Signed-off-by: kahirokunn --- .../serving/machinelearning-python-bentoml/README.md | 7 ++----- .../serving/machinelearning-python-bentoml/index.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/code-samples/community/serving/machinelearning-python-bentoml/README.md b/code-samples/community/serving/machinelearning-python-bentoml/README.md index 1982b9a178..b3975314fd 100644 --- a/code-samples/community/serving/machinelearning-python-bentoml/README.md +++ b/code-samples/community/serving/machinelearning-python-bentoml/README.md @@ -168,11 +168,8 @@ a Dockerfile is automatically generated when saving the model. # instruction at https://stedolan.github.io/jq/download/ saved_path=$(bentoml get IrisClassifier:latest -q | jq -r ".uri.uri") - # Build the container on your local machine - docker build - t {username}/iris-classifier $saved_path - - # Push the container to docker registry - docker push {username}/iris-classifier + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/iris-classifier" --push $saved_path ``` 1. In `service.yaml`, replace `{username}` with your Docker hub username: diff --git a/code-samples/community/serving/machinelearning-python-bentoml/index.md b/code-samples/community/serving/machinelearning-python-bentoml/index.md index 1982b9a178..b3975314fd 100644 --- a/code-samples/community/serving/machinelearning-python-bentoml/index.md +++ b/code-samples/community/serving/machinelearning-python-bentoml/index.md @@ -168,11 +168,8 @@ a Dockerfile is automatically generated when saving the model. # instruction at https://stedolan.github.io/jq/download/ saved_path=$(bentoml get IrisClassifier:latest -q | jq -r ".uri.uri") - # Build the container on your local machine - docker build - t {username}/iris-classifier $saved_path - - # Push the container to docker registry - docker push {username}/iris-classifier + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/iris-classifier" --push $saved_path ``` 1. In `service.yaml`, replace `{username}` with your Docker hub username: From 11b6fd81fd1a17640e6e23dce5492ea37431ee8f Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:24:42 +0900 Subject: [PATCH 16/47] chore: support helloworld-go multiple architecture Signed-off-by: kahirokunn --- code-samples/eventing/helloworld/helloworld-go/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/eventing/helloworld/helloworld-go/README.md b/code-samples/eventing/helloworld/helloworld-go/README.md index d205a7655f..51f4e5b619 100644 --- a/code-samples/eventing/helloworld/helloworld-go/README.md +++ b/code-samples/eventing/helloworld/helloworld-go/README.md @@ -229,11 +229,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-go . - - # Push the container to docker registry - docker push {username}/helloworld-go + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-go" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From 03450f1398c94f9097636221b709fc04c3bcb131 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:25:18 +0900 Subject: [PATCH 17/47] chore: support helloworld-python multiple architecture Signed-off-by: kahirokunn --- .../eventing/helloworld/helloworld-python/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code-samples/eventing/helloworld/helloworld-python/README.md b/code-samples/eventing/helloworld/helloworld-python/README.md index 191bab3de5..dca7863ef7 100644 --- a/code-samples/eventing/helloworld/helloworld-python/README.md +++ b/code-samples/eventing/helloworld/helloworld-python/README.md @@ -161,10 +161,8 @@ folder) you're ready to build and deploy the sample app. 1. Use Docker to build the sample code into a container. To build and push with Docker Hub, run these commands replacing `{username}` with your Docker Hub username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-python . - # Push the container to docker registry - docker push {username}/helloworld-python + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-python" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you From 9348862f5b09106179db743c39f5a4df88eaf90c Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:26:39 +0900 Subject: [PATCH 18/47] chore: support node-heartbeat-source multiple architecture Signed-off-by: kahirokunn --- .../eventing/writing-event-source-easy-way/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code-samples/eventing/writing-event-source-easy-way/README.md b/code-samples/eventing/writing-event-source-easy-way/README.md index a09191ab25..d7acfb945d 100644 --- a/code-samples/eventing/writing-event-source-easy-way/README.md +++ b/code-samples/eventing/writing-event-source-easy-way/README.md @@ -91,8 +91,9 @@ image, and push it to a container registry that your cluster can access. ```bash export REGISTRY=docker.io/myregistry - docker build . -t $REGISTRY/node-heartbeat-source:v1 - docker push $REGISTRY/node-heartbeat-source:v1 + + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "$REGISTRY/node-heartbeat-source:v1" --push . ``` 1. Create the event display service which logs any CloudEvents posted to it: From 2f47e5d5efd21ee7fffd0afb34e8714cc8802165 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:27:45 +0900 Subject: [PATCH 19/47] chore: support cloudevents-dotnet multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/cloudevents/cloudevents-dotnet/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code-samples/serving/cloudevents/cloudevents-dotnet/README.md b/code-samples/serving/cloudevents/cloudevents-dotnet/README.md index 5207743ce8..df7205a43b 100644 --- a/code-samples/serving/cloudevents/cloudevents-dotnet/README.md +++ b/code-samples/serving/cloudevents/cloudevents-dotnet/README.md @@ -53,8 +53,8 @@ cd knative-docs/code-samples/serving/cloudevents/cloudevents-dotnet and push this to your registry of choice via: ```bash - docker build -t . - docker push + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "" --push . ``` 1. If you look in `service.yaml`, take the `` name and insert it From 55ae30e20f8cb4183d1210643c24f66c772c6bf3 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:32:18 +0900 Subject: [PATCH 20/47] chore: support cloudevents-go multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/cloudevents/cloudevents-go/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code-samples/serving/cloudevents/cloudevents-go/README.md b/code-samples/serving/cloudevents/cloudevents-go/README.md index 9041d8a9b4..ddf1d92043 100644 --- a/code-samples/serving/cloudevents/cloudevents-go/README.md +++ b/code-samples/serving/cloudevents/cloudevents-go/README.md @@ -53,8 +53,8 @@ cd knative-docs/code-samples/serving/cloudevents/cloudevents-go * If you look in `Dockerfile`, you will see a method for pulling in the dependencies and building a small Go container based on Alpine. You can build and push this to your registry of choice via: ```bash -docker build -t . -docker push +# Build and push the container on your local machine. +docker buildx build --platform linux/arm64,linux/amd64 -t "" --push . ``` ### ko From 5afbd0c4ed3dfbfcb585829852165238e4518e35 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:32:41 +0900 Subject: [PATCH 21/47] chore: support cloudevents-nodejs multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/cloudevents/cloudevents-nodejs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code-samples/serving/cloudevents/cloudevents-nodejs/README.md b/code-samples/serving/cloudevents/cloudevents-nodejs/README.md index 1f906c684c..c52ed76b39 100644 --- a/code-samples/serving/cloudevents/cloudevents-nodejs/README.md +++ b/code-samples/serving/cloudevents/cloudevents-nodejs/README.md @@ -54,8 +54,8 @@ In the `Dockerfile`, you can see how the dependencies are installed using npm. You can build and push this to your registry of choice via: ```bash - docker build -t . - docker push + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "" --push . ``` ### yaml From f3920c3b7a0822c360576367db60308ff9a7e116 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:32:53 +0900 Subject: [PATCH 22/47] chore: support cloudevents-rust multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/cloudevents/cloudevents-rust/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code-samples/serving/cloudevents/cloudevents-rust/README.md b/code-samples/serving/cloudevents/cloudevents-rust/README.md index 270b303414..714733d9a2 100644 --- a/code-samples/serving/cloudevents/cloudevents-rust/README.md +++ b/code-samples/serving/cloudevents/cloudevents-rust/README.md @@ -47,7 +47,8 @@ cargo build --target x86_64-unknown-linux-musl --release This will build a statically linked binary, in order to create an image from scratch. Now build the docker image: ```bash -docker build -t . +# Build and push the container on your local machine. +docker buildx build --platform linux/arm64,linux/amd64 -t "" --push . ``` ### yaml From 0b77ea1fc066dd5267ac87b3faefc2a934b45457 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:33:36 +0900 Subject: [PATCH 23/47] chore: support gitwebhook-go multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/gitwebhook-go/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/gitwebhook-go/README.md b/code-samples/serving/gitwebhook-go/README.md index 8753ed92bb..129217a93e 100644 --- a/code-samples/serving/gitwebhook-go/README.md +++ b/code-samples/serving/gitwebhook-go/README.md @@ -35,11 +35,8 @@ You must meet the following requirements to run this sample: ```bash export DOCKER_HUB_USERNAME=username - # Build the container, run from the project folder - docker build -t ${DOCKER_HUB_USERNAME}/gitwebhook-go . - - # Push the container to the registry - docker push ${DOCKER_HUB_USERNAME}/gitwebhook-go + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "${DOCKER_HUB_USERNAME}/gitwebhook-go" --push . ``` 1. Create a secret that holds two values from GitHub: From 4a21fa6e6b59f4c5bf183f7df37cfe15286baa11 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:34:22 +0900 Subject: [PATCH 24/47] chore: support helloworld-csharp multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-csharp/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-csharp/README.md b/code-samples/serving/hello-world/helloworld-csharp/README.md index 868e28e0fa..c8e8e3c5b2 100644 --- a/code-samples/serving/hello-world/helloworld-csharp/README.md +++ b/code-samples/serving/hello-world/helloworld-csharp/README.md @@ -121,11 +121,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-csharp . - - # Push the container to docker registry - docker push {username}/helloworld-csharp + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-csharp" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From 183f7ae85466a94ad6dd6bac82c1161d591bb909 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:35:01 +0900 Subject: [PATCH 25/47] chore: support helloworld-go multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/hello-world/helloworld-go/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-go/README.md b/code-samples/serving/hello-world/helloworld-go/README.md index 145700bcb7..fe7f37388e 100644 --- a/code-samples/serving/hello-world/helloworld-go/README.md +++ b/code-samples/serving/hello-world/helloworld-go/README.md @@ -111,11 +111,8 @@ go mod init github.com/knative/docs/code-samples/serving/hello-world/helloworld- To build the sample code into a container, and push using Docker Hub, enter the following commands and replace `{username}` with your Docker Hub username: ```bash -# Build the container on your local machine -docker build -t {username}/helloworld-go . - -# Push the container to docker registry -docker push {username}/helloworld-go +# Build and push the container on your local machine. +docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-go" --push . ``` ### Deploying to knative From b416fe43004141ea8c6b272397d83ad6afd77d23 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:35:30 +0900 Subject: [PATCH 26/47] chore: support helloworld-java-spark multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-java-spark/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-java-spark/README.md b/code-samples/serving/hello-world/helloworld-java-spark/README.md index cde7b74a5f..5c23f68300 100644 --- a/code-samples/serving/hello-world/helloworld-java-spark/README.md +++ b/code-samples/serving/hello-world/helloworld-java-spark/README.md @@ -65,10 +65,8 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java 1. To build the sample code into a container, and push using Docker Hub, enter the following commands and replace `{username}` with your Docker Hub username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-java . - # Push the container to docker registry - docker push {username}/helloworld-java + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java" --push . ``` ## Deploy From fcbb20c30ab6d4cd8566dcfb9df1d4ee755bcc74 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:36:21 +0900 Subject: [PATCH 27/47] chore: support helloworld-java-spring multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-java-spring/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-java-spring/README.md b/code-samples/serving/hello-world/helloworld-java-spring/README.md index 4127b4c5c6..eaf8ba3e71 100644 --- a/code-samples/serving/hello-world/helloworld-java-spring/README.md +++ b/code-samples/serving/hello-world/helloworld-java-spring/README.md @@ -113,11 +113,8 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java-spring 1. Use Docker to build the sample code into a container, then push the container to the Docker registry: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-java-spring . - - # Push the container to docker registry - docker push {username}/helloworld-java-spring + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-java-spring" --push . ``` Where `{username}` is your Docker Hub username. From 6adf20b3c4bca7af7720590297b8b62bbcbdc821 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:36:52 +0900 Subject: [PATCH 28/47] chore: support helloworld-kotlin multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-kotlin/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-kotlin/README.md b/code-samples/serving/hello-world/helloworld-kotlin/README.md index 34117275dc..10d6551774 100644 --- a/code-samples/serving/hello-world/helloworld-kotlin/README.md +++ b/code-samples/serving/hello-world/helloworld-kotlin/README.md @@ -143,11 +143,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-kotlin . - - # Push the container to docker registry - docker push {username}/helloworld-kotlin + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-kotlin" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From bcdedb97541bbdef9ded0eb80ad8203bf75ecfca Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:37:22 +0900 Subject: [PATCH 29/47] chore: support helloworld-nodejs multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-nodejs/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-nodejs/README.md b/code-samples/serving/hello-world/helloworld-nodejs/README.md index 6b6b969652..3eb723122c 100644 --- a/code-samples/serving/hello-world/helloworld-nodejs/README.md +++ b/code-samples/serving/hello-world/helloworld-nodejs/README.md @@ -151,11 +151,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-nodejs . - - # Push the container to docker registry - docker push {username}/helloworld-nodejs + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-nodejs" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From 39fdc46201f21e140ab542e670fe600dc4478c81 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:38:01 +0900 Subject: [PATCH 30/47] chore: support helloworld-php multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-php/README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-php/README.md b/code-samples/serving/hello-world/helloworld-php/README.md index eaf2e770b6..b6122ba5b7 100644 --- a/code-samples/serving/hello-world/helloworld-php/README.md +++ b/code-samples/serving/hello-world/helloworld-php/README.md @@ -96,12 +96,9 @@ Choose one of the following methods: 1. Use Docker to build the sample code into a container. To build and push with Docker Hub, run these commands replacing `{username}` with your Docker Hub username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-php . - - # Push the container to docker registry - docker push {username}/helloworld-php - ``` + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-php" --push . + ``` 1. After the build has completed and the container is pushed to docker hub, you can deploy the app into your cluster. Ensure that the container image value in `service.yaml` matches the container you built in the previous step. Apply the configuration using `kubectl`: From 53925b682b2b2508818715fc1a9bd0ef6f5fd6d2 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:38:36 +0900 Subject: [PATCH 31/47] chore: support helloworld-python multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-python/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-python/README.md b/code-samples/serving/hello-world/helloworld-python/README.md index de6ba35daa..b15cc3057d 100644 --- a/code-samples/serving/hello-world/helloworld-python/README.md +++ b/code-samples/serving/hello-world/helloworld-python/README.md @@ -101,11 +101,8 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-python to the Docker registry: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-python . - - # Push the container to docker registry - docker push {username}/helloworld-python + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-python" --push . ``` ## Deploying the app From eca9addbe309d3ae03e913900cdfa3b933518aa2 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:39:06 +0900 Subject: [PATCH 32/47] chore: support helloworld-shell multiple architecture Signed-off-by: kahirokunn --- .../serving/hello-world/helloworld-shell/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/hello-world/helloworld-shell/README.md b/code-samples/serving/hello-world/helloworld-shell/README.md index bffeaffa49..6dfeb5a012 100644 --- a/code-samples/serving/hello-world/helloworld-shell/README.md +++ b/code-samples/serving/hello-world/helloworld-shell/README.md @@ -71,11 +71,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/helloworld-shell . - - # Push the container to docker registry - docker push {username}/helloworld-shell + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/helloworld-shell" --push . ``` ## Deploying From 9b21923e02a80a29a672c7fe2c43154741f8ea26 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:40:37 +0900 Subject: [PATCH 33/47] chore: support knative-routing-go multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/knative-routing-go/README.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/code-samples/serving/knative-routing-go/README.md b/code-samples/serving/knative-routing-go/README.md index eddb53356e..bbf236fa53 100644 --- a/code-samples/serving/knative-routing-go/README.md +++ b/code-samples/serving/knative-routing-go/README.md @@ -67,21 +67,14 @@ your dockerhub username and run the following command: export REPO="docker.io/" ``` -3. Use Docker to build your application container: +3. Use Docker to build and push your application container: ``` -docker build \ - --tag "${REPO}/knative-routing-go" \ - --file=code-samples/serving/knative-routing-go/Dockerfile . +# Build and push the container on your local machine. +docker buildx build --platform linux/arm64,linux/amd64 -t "${REPO}/knative-routing-go" --push . -f code-samples/serving/knative-routing-go/Dockerfile ``` -4. Push your container to a container registry: - -``` -docker push "${REPO}/knative-routing-go" -``` - -5. Replace the image reference path with our published image path in the +4. Replace the image reference path with our published image path in the configuration file `code-samples/serving/knative-routing-go/sample.yaml`: - Manually replace: From 2c32fa9ea1338c123c61a2b1216d9b9c2b245be0 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:43:01 +0900 Subject: [PATCH 34/47] chore: support kong-routing-go multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/kong-routing-go/README.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/code-samples/serving/kong-routing-go/README.md b/code-samples/serving/kong-routing-go/README.md index 8d1af0a9e6..89f02c6ba6 100644 --- a/code-samples/serving/kong-routing-go/README.md +++ b/code-samples/serving/kong-routing-go/README.md @@ -72,18 +72,11 @@ Build the application container and publish it to a container registry: export REPO="docker.io/" ``` -1. Use Docker to build your application container: +1. Use Docker to build and push your application container: ```bash - docker build \ - --tag "${REPO}/kong-routing-go" \ - --file=code-samples/serving/kong-routing-go/Dockerfile . - ``` - -1. Push your container to a container registry: - - ```bash - docker push "${REPO}/kong-routing-go" + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "${REPO}/kong-routing-go" --push . -f code-samples/serving/kong-routing-go/Dockerfile ``` 1. Replace the image reference path with our published image path in the From 25d2053738e733ea59b83214129e68035311c48a Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:44:47 +0900 Subject: [PATCH 35/47] chore: support multi-container multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/multi-container/README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/code-samples/serving/multi-container/README.md b/code-samples/serving/multi-container/README.md index b49700e625..44ebac1f15 100644 --- a/code-samples/serving/multi-container/README.md +++ b/code-samples/serving/multi-container/README.md @@ -36,7 +36,7 @@ You can update the default files and YAML by using the steps outlined in this se You can do this by copying the following code into the `servingcontainer.go` file: ```go - package main + package main import ( "fmt" "io" @@ -140,9 +140,9 @@ You can do this by copying the following code into the `sidecarcontainer.go` fil # https://hub.docker.com/_/alpine # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds FROM alpine:3 - RUN apk add --no-cache ca-certificates + RUN apk add --no-cache ca-certificates # Copy the binary to the production image from the builder stage. - COPY --from=builder /app/sidecarcontainer /sidecarcontainer + COPY --from=builder /app/sidecarcontainer /sidecarcontainer # Run the web service on container startup. CMD ["/sidecarcontainer"] ``` @@ -198,16 +198,14 @@ After you have modified the sample code files you can build and deploy the sampl username: ```bash - # Build the container on your local machine + # Build and push the container on your local machine. cd - cd knative-docs/code-samples/serving/multi-container/servingcontainer - docker build -t {username}/servingcontainer . + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/servingcontainer" --push . + cd - cd knative-docs/code-samples/serving/multi-container/sidecarcontainer - docker build -t {username}/sidecarcontainer . - # Push the container to docker registry - docker push {username}/servingcontainer - docker push {username}/sidecarcontainer + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/sidecarcontainer" --push . ``` 1. After the build has completed and the container is pushed to Docker Hub, you From a7f55a4c37a34d9833436e1eb1a9d99febcadf74 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:45:18 +0900 Subject: [PATCH 36/47] chore: support secrets-go multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/secrets-go/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code-samples/serving/secrets-go/README.md b/code-samples/serving/secrets-go/README.md index 70765fd766..140a56ac6b 100644 --- a/code-samples/serving/secrets-go/README.md +++ b/code-samples/serving/secrets-go/README.md @@ -198,11 +198,8 @@ folder) you're ready to build and deploy the sample app. username: ```bash - # Build the container on your local machine - docker build -t {username}/secrets-go . - - # Push the container to docker registry - docker push {username}/secrets-go + # Build and push the container on your local machine. + docker buildx build --platform linux/arm64,linux/amd64 -t "{username}/secrets-go" --push . ``` 1. After the build has completed and the container is pushed to docker hub, you From d5110e173d0cc59dc40ab5523d951101f08d6192 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 13:46:44 +0900 Subject: [PATCH 37/47] chore: support knative-docs multiple architecture Signed-off-by: kahirokunn --- hack/docker/build-image.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hack/docker/build-image.sh b/hack/docker/build-image.sh index ca73160c7b..561913b34f 100755 --- a/hack/docker/build-image.sh +++ b/hack/docker/build-image.sh @@ -4,5 +4,4 @@ SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P) set -x -docker build -t ghcr.io/knative/knative-docs:latest -f $SCRIPT_DIR/Dockerfile $SCRIPT_DIR/../.. - +docker buildx build --platform linux/arm64,linux/amd64 -t "ghcr.io/knative/knative-docs:latest" --push -f $SCRIPT_DIR/Dockerfile $SCRIPT_DIR/../.. From 8f83f023fd2a911023275095384f7aa565a4f630 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:40 +0900 Subject: [PATCH 38/47] chore: support helloworld-r Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/community/serving/helloworld-r/Dockerfile | 5 ++++- code-samples/community/serving/helloworld-r/README.md | 5 ++++- code-samples/community/serving/helloworld-r/index.md | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/code-samples/community/serving/helloworld-r/Dockerfile b/code-samples/community/serving/helloworld-r/Dockerfile index 7906d2164f..63be93a88a 100644 --- a/code-samples/community/serving/helloworld-r/Dockerfile +++ b/code-samples/community/serving/helloworld-r/Dockerfile @@ -3,6 +3,9 @@ # https://hub.docker.com/_/golang FROM golang:1.12 as builder +ARG TARGETOS +ARG TARGETARCH + # Copy local code to the container image. WORKDIR /go/src/github.com/knative/docs/helloworld-r COPY invoke.go . @@ -10,7 +13,7 @@ COPY invoke.go . # Build the command inside the container. # (You may fetch or manage dependencies here, # either manually or with a tool like "godep".) -RUN CGO_ENABLED=0 GOOS=linux go build -v -o invoke +RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -v -o invoke # The official R base image # https://hub.docker.com/_/r-base diff --git a/code-samples/community/serving/helloworld-r/README.md b/code-samples/community/serving/helloworld-r/README.md index 3b9001389a..0fd726b98d 100644 --- a/code-samples/community/serving/helloworld-r/README.md +++ b/code-samples/community/serving/helloworld-r/README.md @@ -77,6 +77,9 @@ cd knative-docs/code-samples/community/serving/hello-world/helloworld-r # https://hub.docker.com/_/golang FROM golang:1.12 as builder + ARG TARGETOS + ARG TARGETARCH + # Copy local code to the container image. WORKDIR /go/src/github.com/knative/docs/helloworld-r COPY invoke.go . @@ -84,7 +87,7 @@ cd knative-docs/code-samples/community/serving/hello-world/helloworld-r # Build the command inside the container. # (You may fetch or manage dependencies here, # either manually or with a tool like "godep".) - RUN CGO_ENABLED=0 GOOS=linux go build -v -o invoke + RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -v -o invoke # The official R base image # https://hub.docker.com/_/r-base diff --git a/code-samples/community/serving/helloworld-r/index.md b/code-samples/community/serving/helloworld-r/index.md index 3b9001389a..0fd726b98d 100644 --- a/code-samples/community/serving/helloworld-r/index.md +++ b/code-samples/community/serving/helloworld-r/index.md @@ -77,6 +77,9 @@ cd knative-docs/code-samples/community/serving/hello-world/helloworld-r # https://hub.docker.com/_/golang FROM golang:1.12 as builder + ARG TARGETOS + ARG TARGETARCH + # Copy local code to the container image. WORKDIR /go/src/github.com/knative/docs/helloworld-r COPY invoke.go . @@ -84,7 +87,7 @@ cd knative-docs/code-samples/community/serving/hello-world/helloworld-r # Build the command inside the container. # (You may fetch or manage dependencies here, # either manually or with a tool like "godep".) - RUN CGO_ENABLED=0 GOOS=linux go build -v -o invoke + RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -v -o invoke # The official R base image # https://hub.docker.com/_/r-base From ccd11faae159edd4068a540c3a9a1d4a490e2015 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:40 +0900 Subject: [PATCH 39/47] chore: support helloworld-go Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/eventing/helloworld/helloworld-go/Dockerfile | 5 ++++- code-samples/eventing/helloworld/helloworld-go/README.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/code-samples/eventing/helloworld/helloworld-go/Dockerfile b/code-samples/eventing/helloworld/helloworld-go/Dockerfile index 7c93db9e21..87e643cc15 100644 --- a/code-samples/eventing/helloworld/helloworld-go/Dockerfile +++ b/code-samples/eventing/helloworld/helloworld-go/Dockerfile @@ -3,6 +3,9 @@ # https://hub.docker.com/_/golang FROM golang:1.14 as builder +ARG TARGETOS +ARG TARGETARCH + # Copy local code to the container image. WORKDIR /app @@ -16,7 +19,7 @@ COPY . ./ # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. -RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o helloworld +RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o helloworld # Use a Docker multi-stage build to create a lean production image. # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds diff --git a/code-samples/eventing/helloworld/helloworld-go/README.md b/code-samples/eventing/helloworld/helloworld-go/README.md index 51f4e5b619..34839db057 100644 --- a/code-samples/eventing/helloworld/helloworld-go/README.md +++ b/code-samples/eventing/helloworld/helloworld-go/README.md @@ -108,6 +108,9 @@ cd knative-docs/code-samples/eventing/helloworld/helloworld-go # https://hub.docker.com/_/golang FROM golang:1.14 as builder + ARG TARGETOS + ARG TARGETARCH + # Copy local code to the container image. WORKDIR /app @@ -121,7 +124,7 @@ cd knative-docs/code-samples/eventing/helloworld/helloworld-go # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. - RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o helloworld + RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o helloworld # Use a Docker multi-stage build to create a lean production image. # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds From e4d1c57696fcb2ef808c65f1ab9862e21a06f6be Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:40 +0900 Subject: [PATCH 40/47] chore: support cloudevents-go Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/cloudevents/cloudevents-go/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code-samples/serving/cloudevents/cloudevents-go/Dockerfile b/code-samples/serving/cloudevents/cloudevents-go/Dockerfile index 8e1c0ba417..87c4eeff3b 100644 --- a/code-samples/serving/cloudevents/cloudevents-go/Dockerfile +++ b/code-samples/serving/cloudevents/cloudevents-go/Dockerfile @@ -3,6 +3,9 @@ # https://hub.docker.com/_/golang FROM golang:1.13 as builder +ARG TARGETOS +ARG TARGETARCH + # Create and change to the app directory. WORKDIR /app @@ -13,7 +16,7 @@ COPY . ./ # Also builds the binary ENV GO111MODULE=on RUN go mod init cloudevents.go \ - && CGO_ENABLED=0 GOOS=linux go build -v -o server + && CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -v -o server # Allows the container builds to reuse downloaded dependencies. RUN go mod download From 03973df2556ce678c178f8e54f29a4905d88105b Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:40 +0900 Subject: [PATCH 41/47] chore: support gitwebhook-go Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/gitwebhook-go/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code-samples/serving/gitwebhook-go/Dockerfile b/code-samples/serving/gitwebhook-go/Dockerfile index fb2bedbf4d..807bae9eb9 100644 --- a/code-samples/serving/gitwebhook-go/Dockerfile +++ b/code-samples/serving/gitwebhook-go/Dockerfile @@ -14,6 +14,9 @@ FROM golang AS builder +ARG TARGETOS +ARG TARGETARCH + # copy the source ADD . /go/src/github.com/knative/docs/code-samples/serving/gitwebhook-go WORKDIR /go/src/github.com/knative/docs/code-samples/serving/gitwebhook-go @@ -25,7 +28,7 @@ RUN go get gopkg.in/go-playground/webhooks.v3 RUN go get gopkg.in/go-playground/webhooks.v3/github # build the sample -RUN CGO_ENABLED=0 go build -o /go/bin/webhook-sample . +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /go/bin/webhook-sample . FROM golang:alpine From 6a39a068fc0cc687256fd6eeac6f3f7cf81e0f85 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:40 +0900 Subject: [PATCH 42/47] chore: support knative-routing-go Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/knative-routing-go/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code-samples/serving/knative-routing-go/Dockerfile b/code-samples/serving/knative-routing-go/Dockerfile index 4744fd557a..2deb314781 100644 --- a/code-samples/serving/knative-routing-go/Dockerfile +++ b/code-samples/serving/knative-routing-go/Dockerfile @@ -14,10 +14,13 @@ FROM golang AS builder +ARG TARGETOS +ARG TARGETARCH + WORKDIR /go/src/github.com/knative/docs/ ADD . /go/src/github.com/knative/docs/ -RUN CGO_ENABLED=0 go build ./code-samples/serving/knative-routing-go/ +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build ./code-samples/serving/knative-routing-go/ FROM gcr.io/distroless/base From 99f3841a5b6011c620ab9ec7e4ad545ff462585f Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:40 +0900 Subject: [PATCH 43/47] chore: support kong-routing-go Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/kong-routing-go/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code-samples/serving/kong-routing-go/Dockerfile b/code-samples/serving/kong-routing-go/Dockerfile index 6d12c7c7fe..ee41b299f5 100644 --- a/code-samples/serving/kong-routing-go/Dockerfile +++ b/code-samples/serving/kong-routing-go/Dockerfile @@ -14,10 +14,13 @@ FROM golang AS builder +ARG TARGETOS +ARG TARGETARCH + WORKDIR /go/src/github.com/knative/docs/ ADD . /go/src/github.com/knative/docs/ -RUN CGO_ENABLED=0 go build ./code-samples/serving/kong-routing-go/ +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build ./code-samples/serving/kong-routing-go/ FROM gcr.io/distroless/base From be337656819685a8162ca1257094e3232872d89d Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:40 +0900 Subject: [PATCH 44/47] chore: support servingcontainer Dockerfile multiple architecture Signed-off-by: kahirokunn --- .../serving/multi-container/servingcontainer/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code-samples/serving/multi-container/servingcontainer/Dockerfile b/code-samples/serving/multi-container/servingcontainer/Dockerfile index 4f8bce92e7..89d9d1c6e6 100644 --- a/code-samples/serving/multi-container/servingcontainer/Dockerfile +++ b/code-samples/serving/multi-container/servingcontainer/Dockerfile @@ -3,6 +3,9 @@ # https://hub.docker.com/_/golang FROM golang:1.15 as builder +ARG TARGETOS +ARG TARGETARCH + # Create and change to the app directory. WORKDIR /app @@ -16,7 +19,7 @@ COPY . ./ # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. -RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o servingcontainer +RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o servingcontainer # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine From 66ac14acd3a730afd7a6bdbb81cd9b64a438743e Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:41 +0900 Subject: [PATCH 45/47] chore: support sidecarcontainer Dockerfile multiple architecture Signed-off-by: kahirokunn --- .../serving/multi-container/sidecarcontainer/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code-samples/serving/multi-container/sidecarcontainer/Dockerfile b/code-samples/serving/multi-container/sidecarcontainer/Dockerfile index 1c60e74ae3..a26b29461d 100644 --- a/code-samples/serving/multi-container/sidecarcontainer/Dockerfile +++ b/code-samples/serving/multi-container/sidecarcontainer/Dockerfile @@ -3,6 +3,9 @@ # https://hub.docker.com/_/golang FROM golang:1.15 as builder +ARG TARGETOS +ARG TARGETARCH + # Create and change to the app directory. WORKDIR /app @@ -16,7 +19,7 @@ COPY . ./ # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. -RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o sidecarcontainer +RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o sidecarcontainer # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine From 54429856e64900c6a141e4d523640caf236d7067 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:41 +0900 Subject: [PATCH 46/47] chore: support secrets-go Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/secrets-go/Dockerfile | 5 ++++- code-samples/serving/secrets-go/README.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/code-samples/serving/secrets-go/Dockerfile b/code-samples/serving/secrets-go/Dockerfile index 42776038ec..3f1d286ff5 100644 --- a/code-samples/serving/secrets-go/Dockerfile +++ b/code-samples/serving/secrets-go/Dockerfile @@ -3,12 +3,15 @@ # https://hub.docker.com/_/golang FROM golang as builder +ARG TARGETOS +ARG TARGETARCH + # Copy local code to the container image. WORKDIR /go/src/github.com/knative/docs/hellosecrets COPY . . # Build the output command inside the container. -RUN CGO_ENABLED=0 GOOS=linux go build -v -o hellosecrets +RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -v -o hellosecrets # Use a Docker multi-stage build to create a lean production image. # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds diff --git a/code-samples/serving/secrets-go/README.md b/code-samples/serving/secrets-go/README.md index 140a56ac6b..438fd22da7 100644 --- a/code-samples/serving/secrets-go/README.md +++ b/code-samples/serving/secrets-go/README.md @@ -95,12 +95,15 @@ cd knative-docs/code-samples/serving/secrets-go # https://hub.docker.com/_/golang FROM golang as builder + ARG TARGETOS + ARG TARGETARCH + # Copy local code to the container image. WORKDIR /go/src/github.com/knative/docs/hellosecrets COPY . . # Build the output command inside the container. - RUN CGO_ENABLED=0 GOOS=linux go build -v -o hellosecrets + RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -v -o hellosecrets # Use a Docker multi-stage build to create a lean production image. # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds From 9a3b5b419a7a1c3c91aa9f85c0758d0374650138 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 21 Aug 2023 14:00:59 +0900 Subject: [PATCH 47/47] chore: support multi-container Dockerfile multiple architecture Signed-off-by: kahirokunn --- code-samples/serving/multi-container/README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code-samples/serving/multi-container/README.md b/code-samples/serving/multi-container/README.md index 44ebac1f15..0545fcc794 100644 --- a/code-samples/serving/multi-container/README.md +++ b/code-samples/serving/multi-container/README.md @@ -68,6 +68,10 @@ You can do this by copying the following code into the `servingcontainer.go` fil # This is based on Debian and sets the GOPATH to /go. # https://hub.docker.com/_/golang FROM golang:1.15 as builder + + ARG TARGETOS + ARG TARGETARCH + # Create and change to the app directory. WORKDIR /app # Retrieve application dependencies using go modules. @@ -78,7 +82,7 @@ You can do this by copying the following code into the `servingcontainer.go` fil COPY . ./ # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. - RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o servingcontainer + RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o servingcontainer # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds @@ -125,6 +129,10 @@ You can do this by copying the following code into the `sidecarcontainer.go` fil # This is based on Debian and sets the GOPATH to /go. # https://hub.docker.com/_/golang FROM golang:1.15 as builder + + ARG TARGETOS + ARG TARGETARCH + # Create and change to the app directory. WORKDIR /app # Retrieve application dependencies using go modules. @@ -135,7 +143,7 @@ You can do this by copying the following code into the `sidecarcontainer.go` fil COPY . ./ # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. - RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o sidecarcontainer + RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o sidecarcontainer # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds