Skip to content

Instantly share code, notes, and snippets.

@henkman
Created August 5, 2021 11:25
Show Gist options
  • Save henkman/0b896c236e47b25575150995c541e1eb to your computer and use it in GitHub Desktop.
Save henkman/0b896c236e47b25575150995c541e1eb to your computer and use it in GitHub Desktop.
go+docker
FROM golang:1.16.6-alpine
WORKDIR /go/src/app
COPY main.go go.mod /go/src/app/
RUN go build
FROM alpine:latest
EXPOSE 8080
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/app/app ./
CMD ["./app"]
module app
go 1.16
package main
import (
"net/http"
"fmt"
)
func main() {
http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "hello world")
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment