Add cloudbuild configuration for fastcgi test image
This commit is contained in:
parent
a24ce45b89
commit
9107a042de
5 changed files with 70 additions and 26 deletions
1
images/fastcgi-helloserver/rootfs/.gitignore
vendored
1
images/fastcgi-helloserver/rootfs/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
fastcgi-helloserver
|
||||
|
|
@ -12,8 +12,21 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM scratch
|
||||
FROM golang:1.14-alpine as builder
|
||||
|
||||
COPY . /
|
||||
WORKDIR /go/src/k8s.io/ingress-nginx/images/fastcgi
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 go build -a -installsuffix cgo \
|
||||
-ldflags "-s -w" \
|
||||
-o fastcgi-helloserver main.go
|
||||
|
||||
# Use distroless as minimal base image to package the binary
|
||||
# Refer to https://github.com/GoogleContainerTools/distroless for more details
|
||||
FROM gcr.io/distroless/static:nonroot
|
||||
|
||||
COPY --from=builder /go/src/k8s.io/ingress-nginx/images/fastcgi/fastcgi-helloserver /
|
||||
USER nonroot:nonroot
|
||||
|
||||
CMD ["/fastcgi-helloserver"]
|
||||
|
|
|
|||
30
images/fastcgi-helloserver/rootfs/main.go
Normal file
30
images/fastcgi-helloserver/rootfs/main.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/fcgi"
|
||||
)
|
||||
|
||||
func hello(w http.ResponseWriter, r *http.Request) {
|
||||
keys, ok := r.URL.Query()["name"]
|
||||
|
||||
if !ok || len(keys[0]) < 1 {
|
||||
fmt.Fprintf(w, "Hello world!")
|
||||
return
|
||||
}
|
||||
|
||||
key := keys[0]
|
||||
fmt.Fprintf(w, "Hello "+string(key)+"!")
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/hello", hello)
|
||||
|
||||
l, err := net.Listen("tcp", "0.0.0.0:9000")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fcgi.Serve(l, nil)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue