diff --git a/.github/workflows/knative-mkdocs-dockerimage.yaml b/.github/workflows/knative-mkdocs-dockerimage.yaml index 45aca4f37..f0cd75ebc 100644 --- a/.github/workflows/knative-mkdocs-dockerimage.yaml +++ b/.github/workflows/knative-mkdocs-dockerimage.yaml @@ -1,4 +1,4 @@ -name: Docker Image CI +name: Build Images on: push: @@ -6,7 +6,7 @@ on: jobs: build-and-push-image: - name: Build knative mkdocs dockerfile + name: Build Knative Images runs-on: ubuntu-latest permissions: contents: read @@ -15,6 +15,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to the Container registry uses: docker/login-action@v1 with: @@ -22,9 +25,17 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push docker image - uses: docker/build-push-action@v2 + - name: Build mkdocs image + uses: docker/build-push-action@v4 with: push: true file: ./hack/docker/Dockerfile tags: ghcr.io/knative/knative-docs:latest + + - name: Build helloworld-go image + uses: docker/build-push-action@v4 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: ./code-samples/serving/hello-world/helloworld-go + tags: ghcr.io/knative/helloworld-go:latest diff --git a/code-samples/serving/hello-world/helloworld-go/Dockerfile b/code-samples/serving/hello-world/helloworld-go/Dockerfile index ef57f8009..4de3b9eec 100644 --- a/code-samples/serving/hello-world/helloworld-go/Dockerfile +++ b/code-samples/serving/hello-world/helloworld-go/Dockerfile @@ -1,6 +1,9 @@ # Use the official Golang image to create a build artifact. # This is based on Debian and sets the GOPATH to /go. -FROM golang:1.13 as builder +FROM golang:latest as builder + +ARG TARGETOS +ARG TARGETARCH # Create and change to the app directory. WORKDIR /app @@ -15,7 +18,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 server +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o server # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine diff --git a/code-samples/serving/hello-world/helloworld-go/README.md b/code-samples/serving/hello-world/helloworld-go/README.md index 423965739..145700bcb 100644 --- a/code-samples/serving/hello-world/helloworld-go/README.md +++ b/code-samples/serving/hello-world/helloworld-go/README.md @@ -65,7 +65,10 @@ Navigate to your project directory and copy the following code into a new file n ```dockerfile # Use the official Golang image to create a build artifact. # This is based on Debian and sets the GOPATH to /go. -FROM golang:1.13 as builder +FROM golang:latest as builder + +ARG TARGETOS +ARG TARGETARCH # Create and change to the app directory. WORKDIR /app @@ -80,7 +83,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 server +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o server # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine