docker-build
This commit is contained in:
parent
5c13e4eb2d
commit
4a0b3c4e7a
|
@ -0,0 +1,13 @@
|
||||||
|
FROM golang:latest
|
||||||
|
|
||||||
|
RUN apt update -y && apt install -y git apache2 supervisor
|
||||||
|
|
||||||
|
COPY src /src/testserver
|
||||||
|
|
||||||
|
WORKDIR /src/testserver
|
||||||
|
|
||||||
|
RUN cd testserver && go build -v -i && cp server /usr/local/bin
|
||||||
|
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
CMD ["server"]
|
|
@ -0,0 +1,3 @@
|
||||||
|
module example/server
|
||||||
|
|
||||||
|
go 1.17
|
Binary file not shown.
|
@ -0,0 +1,22 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"html"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
|
||||||
|
})
|
||||||
|
|
||||||
|
http.HandleFunc("/hi", func(w http.ResponseWriter, r *http.Request){
|
||||||
|
fmt.Fprintf(w, "Hi")
|
||||||
|
})
|
||||||
|
|
||||||
|
log.Fatal(http.ListenAndServe(":8081", nil))
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue