From af98e4af1ba599ed0ca30f4e9278c7c53e6d3134 Mon Sep 17 00:00:00 2001 From: fifsky Date: Sat, 21 Mar 2020 15:24:53 +0800 Subject: [PATCH] fix port --- api/Dockerfile | 4 ++-- api/main.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 91e8630..43ae3a3 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -9,6 +9,6 @@ COPY ./app ./ COPY .env ./ ENV TZ=Asia/Shanghai -EXPOSE 8989 +EXPOSE 80 -ENTRYPOINT ["./app"] \ No newline at end of file +ENTRYPOINT ["./app",":80"] \ No newline at end of file diff --git a/api/main.go b/api/main.go index 5d15e33..ea04fdf 100644 --- a/api/main.go +++ b/api/main.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "flag" "fmt" "io/ioutil" "log" @@ -16,6 +17,9 @@ import ( ) func main() { + port := flag.String("addr", ":8989", "addr ip:port") + flag.Parse() + m, err := dotenv.Read() if err != nil { @@ -93,7 +97,7 @@ func main() { http.Handle("/genapi/struct/gen", c.Handler(handler)) - err = http.ListenAndServe(":8989",nil) + err = http.ListenAndServe(*port, nil) if err != nil { log.Fatal("ListenAndServe", err)