Browse Source

gin. allow code reload in dev mode

boyska 5 years ago
parent
commit
3471ce25e1
3 changed files with 15 additions and 8 deletions
  1. 1 0
      .gitignore
  2. 9 7
      Dockerfile
  3. 5 1
      cmd/userpanel/main.go

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 /vendor
 /panelcli
 /userpanel
+gin-bin

+ 9 - 7
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"]

+ 5 - 1
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