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)