docker-build

This commit is contained in:
notplants 2022-07-18 13:55:22 +02:00
parent 5c13e4eb2d
commit 4a0b3c4e7a
4 changed files with 38 additions and 0 deletions

13
Dockerfile Normal file
View File

@ -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"]

3
src/go.mod Normal file
View File

@ -0,0 +1,3 @@
module example/server
go 1.17

BIN
src/server Executable file

Binary file not shown.

22
src/server.go Normal file
View File

@ -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))
}