Dockerize everything!
This commit is contained in:
parent
58c8f54a9a
commit
4ec0091785
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
FROM golang:1.14-buster AS builder
|
||||
|
||||
WORKDIR ${GOPATH}/src/git.bjphoster.com/bryanpedini/go-totp
|
||||
COPY . .
|
||||
|
||||
RUN go get -d -v
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix gco -ldflags="-w -s" -o /go/bin/go-totp
|
||||
|
||||
FROM scratch
|
||||
LABEL maintainer="Bryan Joshua Pedini <b.pedini@bjphoster.com>"
|
||||
|
||||
COPY --from=builder /go/bin/go-totp /app/go-totp
|
||||
COPY ./static /app/static
|
||||
COPY ./templates /app/templates
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["/app/go-totp"]
|
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
||||
module git.bjphoster.com/bryanpedini/go-totp
|
||||
|
||||
go 1.14
|
||||
|
||||
require github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119
|
||||
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119 h1:YyPWX3jLOtYKulBR6AScGIs74lLrJcgeKRwcbAuQOG4=
|
||||
github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119/go.mod h1:/nuTSlK+okRfR/vnIPqR89fFKonnWPiZymN5ydRJkX8=
|
8
main.go
8
main.go
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"text/template"
|
||||
@ -11,6 +11,8 @@ import (
|
||||
"github.com/xlzd/gotp"
|
||||
)
|
||||
|
||||
var addr = "0.0.0.0:8080"
|
||||
|
||||
type secret struct {
|
||||
S string `json:"secret"`
|
||||
}
|
||||
@ -42,6 +44,6 @@ func main() {
|
||||
http.HandleFunc("/", index)
|
||||
http.HandleFunc("/calculate", calculate)
|
||||
http.Handle("/static/", http.StripPrefix(strings.TrimRight("/static/", "/"), staticFolder))
|
||||
fmt.Println("Listening on 127.0.0.1:8000")
|
||||
http.ListenAndServe("127.0.0.1:8000", nil)
|
||||
fmt.Println("Listening on ", addr)
|
||||
http.ListenAndServe(addr, nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user