From a70dc8ee61997c48a581a4f8a048fccd5f58ab53 Mon Sep 17 00:00:00 2001 From: soup-zhang Date: Tue, 13 Aug 2019 10:46:46 +0800 Subject: [PATCH] test --- .gitignore | 3 +++ Dockerfile | 15 +++++++++++++++ main.go | 23 +++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 Dockerfile create mode 100644 main.go diff --git a/.gitignore b/.gitignore index f1c181e..dd17b0b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +*.idea + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9c8be52 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM golang:latest as build-env + +ENV GO111MODULE=on +ENV BUILDPATH=github.com/soup-zhang/soup-hello +#ENV GOPROXY=goproxy.io +ENV GOPATH=/go +RUN mkdir -p /go/src/${BUILDPATH} +COPY ./ /go/src/${BUILDPATH} +RUN cd /go/src/${BUILDPATH} && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install -v + +FROM alpine:latest + +COPY --from=build-env /go/bin/soup-hello /go/bin/soup-hello +WORKDIR /go/bin/ +CMD ["/go/bin/soup-hello"] \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..42ff624 --- /dev/null +++ b/main.go @@ -0,0 +1,23 @@ +/** + * @Time : 2019-08-13 10:41 + * @Author : soupzhb@gmail.com + * @File : main.go + * @Software: GoLand + */ + +package main + +import ( + "fmt" + "html" + "log" + "net/http" +) + +func main() { + fmt.Println("main start ...") + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + _, _ = fmt.Fprintf(w, "Soup Hello, %q", html.EscapeString(r.URL.Path)) + }) + log.Fatal(http.ListenAndServe(":8080", nil)) +}