File tree 3 files changed +35
-0
lines changed
3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM golang:1.14.1 as builder
2
+ ENV NAME "pinghtml"
3
+ WORKDIR /opt
4
+ COPY . .
5
+ RUN GOOS=linux CGO_ENABLED=0 go build -o bin/$NAME main.go
6
+
7
+ FROM alpine:3.11.5
8
+ RUN apk --no-cache add ca-certificates
9
+ WORKDIR /opt
10
+ COPY --from=builder /opt/bin/$NAME .
11
+ CMD ["/opt/pinghtml" ]
Original file line number Diff line number Diff line change
1
+ module pinghtml
2
+
3
+ go 1.14
Original file line number Diff line number Diff line change
1
+ // Simple web server listening on port 8080
2
+ //
3
+ // Launch this program, open a new terminal, then type:
4
+ // `curl -L http://localhost:8080`
5
+ package main
6
+
7
+ import (
8
+ "fmt"
9
+ "log"
10
+ "net/http"
11
+ )
12
+
13
+ func handler (w http.ResponseWriter , r * http.Request ) {
14
+ fmt .Fprintf (w , "<html><body>pong</body></html>" )
15
+ }
16
+
17
+ func main () {
18
+ http .HandleFunc ("/" , handler )
19
+ log .Println ("Starting server..." )
20
+ log .Fatal (http .ListenAndServe (":8080" , nil ))
21
+ }
You can’t perform that action at this time.
0 commit comments