Created
August 5, 2021 11:25
-
-
Save henkman/0b896c236e47b25575150995c541e1eb to your computer and use it in GitHub Desktop.
go+docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module app | |
go 1.16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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