diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5d2f9eb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.18.3-alpine3.16 AS builder + +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOARCH="amd64" \ + GOOS=linux + +WORKDIR /build +COPY . . +RUN go mod tidy +RUN go build --ldflags "-extldflags -static" -o main . + +FROM alpine:3.16 + +WORKDIR /www + +COPY --from=builder /build/main /www/ +COPY --from=builder /build/database/ /www/database/ +COPY --from=builder /build/public/ /www/public/ +COPY --from=builder /build/storage/ /www/storage/ +COPY --from=builder /build/.env /www/.env + +ENTRYPOINT ["/www/main"] \ No newline at end of file diff --git a/README.md b/README.md index bea3caa..f351490 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Golang developers quickly build their own applications. - [ ] Orm relationships - [ ] Request validator - [ ] Custom .env path -- [ ] Config cors +- [ ] Authorization ## Documentation diff --git a/README_zh.md b/README_zh.md index caa2911..f20009e 100644 --- a/README_zh.md +++ b/README_zh.md @@ -32,7 +32,7 @@ Goravel 是一个功能完备、具有良好扩展能力的 Web 应用程序框 - [ ] Orm 关联关系 - [ ] Request 校验 - [ ] 自定义 .env 路径 -- [ ] Config cors +- [ ] 用户授权 ## 文档 diff --git a/config/cors.go b/config/cors.go new file mode 100644 index 0000000..cb7e2f1 --- /dev/null +++ b/config/cors.go @@ -0,0 +1,24 @@ +package config + +import ( + "github.com/goravel/framework/facades" +) + +func init() { + config := facades.Config + config.Add("cors", map[string]interface{}{ + //Cross-Origin Resource Sharing (CORS) Configuration + // + //Here you may configure your settings for cross-origin resource sharing + //or "CORS". This determines what cross-origin operations may execute + //in web browsers. You are free to adjust these settings as needed. + // + //To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS + "allowed_methods": []string{"*"}, + "allowed_origins": []string{"*"}, + "allowed_headers": []string{"*"}, + "exposed_headers": []string{"*"}, + "max_age": 0, + "supports_credentials": false, + }) +} diff --git a/go.mod b/go.mod index dd425c7..6c46cbd 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module goravel go 1.18 -require github.com/goravel/framework v1.2.3 +require github.com/goravel/framework v1.3.0 require ( cloud.google.com/go v0.100.2 // indirect