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

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code