diff --git a/examples/go_http_hello/Dockerfile b/examples/go_http_hello/Dockerfile new file mode 100644 index 0000000..dfec3ab --- /dev/null +++ b/examples/go_http_hello/Dockerfile @@ -0,0 +1,9 @@ +ARG GO_IMAGE=ocirep:go +FROM ${GO_IMAGE} as build +COPY . . +RUN cargo build main.go + +ARG CA_IMAGE=ocirep:ca-certificates +FROM scratch +COPY --from=${CA_IMAGE} / +COPY --from=build main . diff --git a/examples/go_http_hello/main.go b/examples/go_http_hello/main.go new file mode 100644 index 0000000..e2f0c6d --- /dev/null +++ b/examples/go_http_hello/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "net/http" +) + +func main() { + http.HandleFunc("/", HelloServer) + http.ListenAndServe(":8080", nil) +} + +func HelloServer(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:]) +}