commit 113ac9561063658a02984a6c31c8feb264ea4016 Author: Pedro Pérez Date: Thu May 29 14:52:06 2025 +0200 initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..45e1d3b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.21 + +WORKDIR /app + +COPY ./tmp/learndrone /app/learndrone + +CMD ["/app/learndrone"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..159ba18 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +build-linux: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./tmp/learndrone ./main.go + +pack-docker: + make build-linux + docker build -t learndrone:${version} -t learndrone:latest . \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e69de29 diff --git a/main.go b/main.go new file mode 100644 index 0000000..95b8f10 --- /dev/null +++ b/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "encoding/json" + "net/http" +) + +func main() { + mux := http.NewServeMux() + + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("Hello, World!")) + }) + mux.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) { + json.NewEncoder(w).Encode(map[string]string{"message": "Hello, World!"}) + }) + + http.ListenAndServe(":8080", mux) +}