fix serving samples application cannot build docker image (#3532)

* fix serving samples cannot build docker image

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* fix secrets-go documentation

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* fix build fail

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* fix build fail

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* fix secrets-go documentation

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* fix secrets-go docs

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* fix secrets-go docs

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* gix secrets-go docs

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>

* fix secrets-go docs

Signed-off-by: zufardhiyaulhaq <zufardhiyaulhaq@gmail.com>
This commit is contained in:
Zufar Dhiyaulhaq 2021-05-26 19:40:28 +07:00 committed by GitHub
parent 725f3b1023
commit c5c7cc7cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 20 deletions

View File

@ -12,21 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM golang AS builder
FROM golang:1.15 as builder
# copy the source
ADD . /go/src/github.com/knative/docs/docs/serving/samples/gitwebhook-go
WORKDIR /go/src/github.com/knative/docs/docs/serving/samples/gitwebhook-go
# install dependencies
RUN go get github.com/google/go-github/github
RUN go get golang.org/x/oauth2
RUN go get gopkg.in/go-playground/webhooks.v3
RUN go get gopkg.in/go-playground/webhooks.v3/github
# build the sample
# Ensure Go modules are on and create the go.mod and go.sum files.
# Also builds the binary
RUN CGO_ENABLED=0 go build -o /go/bin/webhook-sample .
# Use a Docker multi-stage build to create a lean production image.
FROM golang:alpine
EXPOSE 8080

View File

@ -0,0 +1,10 @@
module github.com/knative/docs/docs/serving/samples/gitwebhook-go
go 1.15
require (
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.1.0 // indirect
golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c
gopkg.in/go-playground/webhooks.v3 v3.13.0
)

View File

@ -15,10 +15,7 @@
# Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.12 as builder
# Retrieve the dependencies.
RUN go get google.golang.org/grpc
FROM golang:1.15 as builder
# Copy local code to the container image.
WORKDIR /go/src/github.com/knative/docs/docs/serving/samples/grpc-ping-go

View File

@ -1,5 +1,3 @@
// +build grpcping
package main
import (

View File

@ -0,0 +1,9 @@
module github.com/knative/docs/docs/serving/samples/grpc-ping-go
go 1.15
require (
github.com/golang/protobuf v1.5.2
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125
google.golang.org/grpc v1.37.0
)

View File

@ -1,5 +1,3 @@
// +build grpcping
package main
import (

View File

@ -1,8 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: ping.proto
// +build grpcping
package ping
import (

View File

@ -1,7 +1,7 @@
# Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang as builder
FROM golang:1.15 as builder
# Copy local code to the container image.
WORKDIR /go/src/github.com/knative/docs/hellosecrets

View File

@ -0,0 +1,5 @@
module github.com/knative/docs/docs/serving/samples/secrets-go
go 1.15
require cloud.google.com/go/storage v1.15.0

View File

@ -91,6 +91,16 @@ cd knative-docs/docs/serving/samples/secrets-go
}
```
1. Create a new file named `go.mod` and paste the following code. This code is Golang module that
specifies a module name, dependencies, and the minimal versions.
```go
module github.com/knative/docs/docs/serving/samples/secrets-go
go 1.15
require cloud.google.com/go/storage v1.15.0
```
1. In your project directory, create a file named `Dockerfile` and copy the code
block below into it. For detailed instructions on dockerizing a Go app, see
[Deploying Go servers with Docker](https://blog.golang.org/docker).
@ -99,7 +109,7 @@ cd knative-docs/docs/serving/samples/secrets-go
# Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang as builder
FROM golang:1.15 as builder
# Copy local code to the container image.
WORKDIR /go/src/github.com/knative/docs/hellosecrets