
hello.go
package main
import (
"fmt"
"net/http"
)
func index(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<h1>Hello World</h1>")
}
func check(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<h1>Health check</h1>")
}
func main() {
http.HandleFunc("/", index)
http.HandleFunc("/health_check", check)
fmt.Println("Server starting...")
http.ListenAndServe(":3000", nil)
}
Dockerfile
FROM golang:alpine
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]