diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6f800e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# 前后端集成打包 +FROM golang:alpine as build + +RUN apk add upx +WORKDIR /build +COPY . . +# sqlite必须 +ENV GO111MODULE=on +ENV GOPROXY=https://goproxy.cn,direct + +RUN go build -ldflags="-s -w" -o wgui && upx -9 wgui + +RUN ls -lh && chmod +x ./wgui + +FROM alpine + +RUN addgroup -S wgui && \ + adduser -S -D -G wgui wgui + +ENV GIN_MODE=release +RUN apk --no-cache add ca-certificates wireguard-tools jq iptables + +WORKDIR /app +RUN mkdir -p db + +COPY --from=build --chown=wgui:wgui /build/wgui /app +COPY --from=build /build/template/* /app/template/ + +RUN chmod +x wgui + +ENTRYPOINT ["./wgui"] \ No newline at end of file diff --git a/http/router/root.go b/http/router/root.go index 0d2ece1..3a58b24 100644 --- a/http/router/root.go +++ b/http/router/root.go @@ -19,16 +19,6 @@ func InitRouter() *gin.Engine { r.ForwardedByClientIP = true // 将请求打印至控制台 r.Use(gin.Logger()) - //r.Use(cors.New(cors.Config{ - // AllowOrigins: []string{"http://localhost:3100"}, - // AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE"}, - // AllowHeaders: []string{"Origin"}, - // ExposeHeaders: []string{"Content-Length"}, - // AllowCredentials: true, - // AllowOriginFunc: func(origin string) bool { - // return true - // }, - //})) if config.Config.File.Type == "local" { r.Static("/assets", config.Config.File.Path)