chore: add local config dir

This commit is contained in:
qloog
2022-01-07 23:14:45 +08:00
parent 2ae1df377b
commit d55b9420dc
12 changed files with 31 additions and 37 deletions

2
.gitignore vendored
View File

@@ -44,4 +44,4 @@ vendor
# custom
eagle
config/config.yaml
config/local/config.yaml

View File

@@ -13,7 +13,8 @@ ENV GO111MODULE=on \
GOOS=linux \
GOARCH=amd64 \
GOPROXY="https://goproxy.cn,direct" \
TZ=Asia/Shanghai
TZ=Asia/Shanghai \
APP_ENV=docer
# 移动到工作目录
WORKDIR /go/src/github.com/go-eagle/eagle

View File

@@ -1,35 +0,0 @@
# conf
默认从 config.local.yaml 加载配置, 可以通过下面命令生成:
```bash
cp config.sample.yaml config.local.yaml
```
如果是多环境可以设定不同的配置文件,比如:
- config.local.yaml 本地开发环境
- config.dev.yaml 开发环境
- config.test.yaml 测试环境
- config.pre.yaml 预发布环境
- config.prod.yaml 线上环境
生成开发环境配置文件:
```bash
cp config.sample.yaml config.dev.yaml
```
以上配置是可以提交到Git等代码仓库的`config.local.yaml` 配置文件默认不会被提交。
使用本地配置文件来运行程序,命令如下:
```bash
# 本地启动
# 也可以直接 ./eagle
./eagle -c config/config.local.yaml
# 开发环境启动
./eagle -c config/config.dev.yaml
# 线上环境启动
./eagle -c config/config.prod.yaml
```

27
config/local/README.md Normal file
View File

@@ -0,0 +1,27 @@
# conf
默认从 config/{ENV} 加载配置, 可以通过下面命令生成:
如果是多环境可以设定不同的配置目录,比如:
- config/local 本地开发环境
- config/test 测试环境
- config/staging 预发布环境
- config/prod 线上环境
> 环境命名参考自https://cloud.google.com/apis/design/directory_structure
生成测试环境配置文件:
```bash
cp -r config/localhost config/test
```
使用本地配置文件来运行程序,命令如下:
```bash
# 本地启动
# 也可以直接 APP_ENV={env} ./eagle
APP_ENV=local ./eagle -c config
./eagle -e local -c config
```

1
go.mod
View File

@@ -34,6 +34,7 @@ require (
github.com/go-redis/redis/v8 v8.11.0
github.com/go-sql-driver/mysql v1.5.0
github.com/go-test/deep v1.0.6
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.2
github.com/google/uuid v1.1.2
github.com/gorilla/sessions v1.2.1