feat(app): 添加 Dockerfile 和 .dockerignore 文件

- 在 app/facade 和 app/user 目录下新增 Dockerfile 文件,用于构建 Docker 镜像
- 在 app/facade 和 app/user目录下新增 .dockerignore 文件,用于指定不需要复制到容器中的文件和目录
- 更新 app/facade/conf/conf.go 和 app/user/conf/conf.go,使用 embed 包嵌入配置文件
- 移除不必要的库引用,简化代码结构
This commit is contained in:
2025-01-20 23:41:18 +08:00
parent 40a270c9d6
commit 1f3066be16
6 changed files with 229 additions and 22 deletions
+11 -11
View File
@@ -1,18 +1,15 @@
package conf
import (
_ "embed"
"github.com/spf13/viper"
"io/ioutil"
"os"
"path/filepath"
"sync"
"github.com/cloudwego/kitex/pkg/klog"
"github.com/kr/pretty"
_ "github.com/spf13/viper"
_ "github.com/spf13/viper/remote"
"gopkg.in/validator.v2"
"gopkg.in/yaml.v2"
)
var (
@@ -61,15 +58,18 @@ func GetConf() *Config {
return conf
}
//go:embed dev/conf.yaml
var configFile []byte
func initConf() {
prefix := "conf"
confFileRelPath := filepath.Join(prefix, filepath.Join(GetEnv(), "conf.yaml"))
content, err := ioutil.ReadFile(confFileRelPath)
if err != nil {
panic(err)
}
//prefix := "conf"
//confFileRelPath := filepath.Join(prefix, filepath.Join(GetEnv(), "conf.yaml"))
//content, err := ioutil.ReadFile(confFileRelPath)
//if err != nil {
// panic(err)
//}
conf = new(Config)
err = yaml.Unmarshal(content, conf)
err := yaml.Unmarshal(configFile, conf)
// viper 获取远程配置测试
err = viper.AddRemoteProvider("consul", conf.Registry.RegistryAddress[0], "USER")