mirror of https://github.com/knative/docs.git
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:
parent
725f3b1023
commit
c5c7cc7cb4
|
@ -12,21 +12,17 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
FROM golang AS builder
|
FROM golang:1.15 as builder
|
||||||
|
|
||||||
# copy the source
|
# copy the source
|
||||||
ADD . /go/src/github.com/knative/docs/docs/serving/samples/gitwebhook-go
|
ADD . /go/src/github.com/knative/docs/docs/serving/samples/gitwebhook-go
|
||||||
WORKDIR /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
|
# Ensure Go modules are on and create the go.mod and go.sum files.
|
||||||
RUN go get github.com/google/go-github/github
|
# Also builds the binary
|
||||||
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
|
|
||||||
RUN CGO_ENABLED=0 go build -o /go/bin/webhook-sample .
|
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
|
FROM golang:alpine
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
|
@ -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
|
||||||
|
)
|
|
@ -15,10 +15,7 @@
|
||||||
# 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.
|
||||||
# https://hub.docker.com/_/golang
|
# https://hub.docker.com/_/golang
|
||||||
FROM golang:1.12 as builder
|
FROM golang:1.15 as builder
|
||||||
|
|
||||||
# Retrieve the dependencies.
|
|
||||||
RUN go get google.golang.org/grpc
|
|
||||||
|
|
||||||
# Copy local code to the container image.
|
# Copy local code to the container image.
|
||||||
WORKDIR /go/src/github.com/knative/docs/docs/serving/samples/grpc-ping-go
|
WORKDIR /go/src/github.com/knative/docs/docs/serving/samples/grpc-ping-go
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// +build grpcping
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -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
|
||||||
|
)
|
|
@ -1,5 +1,3 @@
|
||||||
// +build grpcping
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// source: ping.proto
|
// source: ping.proto
|
||||||
|
|
||||||
// +build grpcping
|
|
||||||
|
|
||||||
package ping
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# 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.
|
||||||
# https://hub.docker.com/_/golang
|
# https://hub.docker.com/_/golang
|
||||||
FROM golang as builder
|
FROM golang:1.15 as builder
|
||||||
|
|
||||||
# Copy local code to the container image.
|
# Copy local code to the container image.
|
||||||
WORKDIR /go/src/github.com/knative/docs/hellosecrets
|
WORKDIR /go/src/github.com/knative/docs/hellosecrets
|
||||||
|
|
|
@ -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
|
|
@ -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
|
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
|
block below into it. For detailed instructions on dockerizing a Go app, see
|
||||||
[Deploying Go servers with Docker](https://blog.golang.org/docker).
|
[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.
|
# 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.
|
||||||
# https://hub.docker.com/_/golang
|
# https://hub.docker.com/_/golang
|
||||||
FROM golang as builder
|
FROM golang:1.15 as builder
|
||||||
|
|
||||||
# Copy local code to the container image.
|
# Copy local code to the container image.
|
||||||
WORKDIR /go/src/github.com/knative/docs/hellosecrets
|
WORKDIR /go/src/github.com/knative/docs/hellosecrets
|
||||||
|
|
Loading…
Reference in New Issue