From 113ac9561063658a02984a6c31c8feb264ea4016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20P=C3=A9rez?= Date: Thu, 29 May 2025 14:52:06 +0200 Subject: [PATCH] initial commit --- Dockerfile | 7 +++++++ Makefile | 6 ++++++ docker-compose.yml | 0 main.go | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml create mode 100644 main.go 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) +}