From 3471ce25e13963430d4c7a7ae03ab32878af69eb Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 18 Dec 2018 00:03:59 +0100 Subject: [PATCH] gin. allow code reload in dev mode --- .gitignore | 1 + Dockerfile | 16 +++++++++------- cmd/userpanel/main.go | 6 +++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 4d7d64d..8853014 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor /panelcli /userpanel +gin-bin diff --git a/Dockerfile b/Dockerfile index 8e8b12a..f827d48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,13 @@ RUN apk --no-cache add git gcc musl-dev WORKDIR /go/src/git.lattuga.net/boyska/feedpanel/ COPY ./ /go/src/git.lattuga.net/boyska/feedpanel/ ENV GO111MODULE=on -RUN go get ./... && CGO_ENABLED=0 GOOS=linux go install ./... +RUN go get github.com/codegangsta/gin && go get ./... && CGO_ENABLED=0 GOOS=linux go install ./... +CMD /go/bin/gin --all -p 8000 -d ./cmd/userpanel run -FROM busybox -WORKDIR /usr/bin/ -COPY --from=builder /go/bin/panelcli /usr/bin/ -COPY --from=builder /go/bin/userpanel /usr/bin/ -COPY panelui/res/ /go/src/git.lattuga.net/boyska/feedpanel/panelui/res/ -ENTRYPOINT ["./userpanel"] +#FROM busybox +#WORKDIR /usr/bin/ +#COPY --from=builder /go/bin/panelcli /usr/bin/ +#COPY --from=builder /go/bin/userpanel /usr/bin/ +#COPY --from=builder /go/bin/gin /usr/bin/ +#COPY panelui/res/ /go/src/git.lattuga.net/boyska/feedpanel/panelui/res/ +#ENTRYPOINT ["/go/bin/gin", "./cmd/userpanel"] diff --git a/cmd/userpanel/main.go b/cmd/userpanel/main.go index 0ac07df..e29e117 100644 --- a/cmd/userpanel/main.go +++ b/cmd/userpanel/main.go @@ -12,9 +12,13 @@ import ( ) func main() { + port := os.Getenv("PORT") + if port == "" { + port = "8000" + } fs := flag.NewFlagSetWithEnvPrefix(os.Args[0], "PANEL", 0) allowedName := fs.String("allowed-name", "", "Name allowed to forward auth") - addr := fs.String("listen-addr", ":8000", "Address to listen on") + addr := fs.String("listen-addr", ":"+port, "Address to listen on") fs.Parse(os.Args[1:]) var allowedNames []string