Just 4.08 MB compressed image.
docker run -p 8080:8080 reeganexe/small-http
arm64 - 3.81MBamd64 - 4.08MBpackage main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"time"
)
func main() {
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
resp, err := http.Get("https://go.dev/favicon.ico")
if err != nil {
w.WriteHeader(404)
return
}
defer resp.Body.Close()
w.Header().Add("Cache-Control", "max-age=604800")
io.Copy(w, resp.Body)
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
hostname, err := os.Hostname()
if err != nil {
panic(err)
}
fmt.Fprintf(w, "Hello from host: %q The current time is %q", hostname, time.Now().String())
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
FROM golang:1.20 as build
WORKDIR /app
COPY go.mod *.go ./
RUN CGO_ENABLED=0 go build -o small-http
FROM scratch
WORKDIR /app
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /app/small-http /app/
CMD ["./small-http"]
Content type
Image
Digest
sha256:a6ddb495d…
Size
3.8 MB
Last updated
over 3 years ago
docker pull reeganexe/small-http