Create a hello world image to be used by the docs (#5550)

This commit is contained in:
Dave Protasowski 2023-05-09 10:53:00 -04:00 committed by GitHub
parent e97b41c495
commit 66cab03f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 8 deletions

View File

@ -1,4 +1,4 @@
name: Docker Image CI name: Build Images
on: on:
push: push:
@ -6,7 +6,7 @@ on:
jobs: jobs:
build-and-push-image: build-and-push-image:
name: Build knative mkdocs dockerfile name: Build Knative Images
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
@ -15,6 +15,9 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry - name: Log in to the Container registry
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
@ -22,9 +25,17 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image - name: Build mkdocs image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v4
with: with:
push: true push: true
file: ./hack/docker/Dockerfile file: ./hack/docker/Dockerfile
tags: ghcr.io/knative/knative-docs:latest 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

View File

@ -1,6 +1,9 @@
# Use the official Golang image to create a build artifact. # Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go. # 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. # Create and change to the app directory.
WORKDIR /app WORKDIR /app
@ -15,7 +18,7 @@ COPY . ./
# Build the binary. # Build the binary.
# -mod=readonly ensures immutable go.mod and go.sum in container builds. # -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. # Use the official Alpine image for a lean production container.
# https://hub.docker.com/_/alpine # https://hub.docker.com/_/alpine

View File

@ -65,7 +65,10 @@ Navigate to your project directory and copy the following code into a new file n
```dockerfile ```dockerfile
# Use the official Golang image to create a build artifact. # Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go. # 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. # Create and change to the app directory.
WORKDIR /app WORKDIR /app
@ -80,7 +83,7 @@ COPY . ./
# Build the binary. # Build the binary.
# -mod=readonly ensures immutable go.mod and go.sum in container builds. # -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. # Use the official Alpine image for a lean production container.
# https://hub.docker.com/_/alpine # https://hub.docker.com/_/alpine