diff --git a/Dockerfile b/Dockerfile index 9f1e450..2e6e482 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,8 @@ FROM golang:1.21.1 WORKDIR /app -COPY go.mod ./ -RUN go mod download -RUN go mod verify +COPY go.mod go.sum ./ +RUN go mod download && go mod verify COPY . . RUN go build -v -o ./bin/server . diff --git a/compose.yml b/compose.yml index 2436ffa..e9bd91e 100644 --- a/compose.yml +++ b/compose.yml @@ -1,9 +1,9 @@ -version: '3' services: app: build: context: . dockerfile: Dockerfile ports: + # generated with "hash2addr lab.phc.dm.unipi.it/portainer-example" - "127.14.115.95:1091:4000" restart: unless-stopped diff --git a/go.mod b/go.mod index 997c8f4..64db55f 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module git.phc.dm.unipi.it/phc/portainer-example go 1.21.1 + +require github.com/alecthomas/repr v0.2.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..41169e6 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= +github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= diff --git a/main.go b/main.go index 02c5883..672d65e 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "encoding/json" "log" - "mime" "net/http" ) @@ -15,8 +14,11 @@ func main() { return } - w.Header().Set("Content-Type", mime.TypeByExtension(".json")) - if err := json.NewEncoder(w).Encode("ok"); err != nil { + w.Header().Set("Content-Type", "application/json") + if err := json.NewEncoder(w).Encode(map[string]any{ + "question": "Whats the answer to life the universe and everything?", + "answer": 42, + }); err != nil { log.Fatal(err) return }