- 修复YAML配置文件字段格式错误(大写->小写) - 修复JWT密钥未正确识别的问题 - 修复容器内配置文件路径问题,使用绝对路径/etc/photography-api.yaml - 修复迁移工具配置文件路径 - 修复Dockerfile工作目录设置 解决了'field auth.access_secret is not set'的配置错误
This commit is contained in:
@ -58,6 +58,9 @@ COPY --from=builder /app/etc /etc
|
|||||||
# 设置时区
|
# 设置时区
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
|
|
||||||
|
# 创建工作目录
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
# 创建非root用户 (在scratch镜像中需要手动创建)
|
# 创建非root用户 (在scratch镜像中需要手动创建)
|
||||||
USER 65534:65534
|
USER 65534:65534
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configFile = flag.String("f", "etc/photography-api.yaml", "the config file")
|
var configFile = flag.String("f", "/etc/photography-api.yaml", "the config file")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
// 命令行参数
|
// 命令行参数
|
||||||
var (
|
var (
|
||||||
configFile = flag.String("f", "etc/photographyapi-api.yaml", "配置文件路径")
|
configFile = flag.String("f", "/etc/photography-api.yaml", "配置文件路径")
|
||||||
command = flag.String("c", "status", "迁移命令: up, down, status, reset, migrate")
|
command = flag.String("c", "status", "迁移命令: up, down, status, reset, migrate")
|
||||||
steps = flag.Int("s", 0, "步数(用于 down 和 migrate 命令)")
|
steps = flag.Int("s", 0, "步数(用于 down 和 migrate 命令)")
|
||||||
version = flag.String("v", "", "迁移版本(用于特定版本操作)")
|
version = flag.String("v", "", "迁移版本(用于特定版本操作)")
|
||||||
@ -142,7 +142,7 @@ func showHelp() {
|
|||||||
fmt.Println(" go run cmd/migrate/main.go [选项] [参数]")
|
fmt.Println(" go run cmd/migrate/main.go [选项] [参数]")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("选项:")
|
fmt.Println("选项:")
|
||||||
fmt.Println(" -f string 配置文件路径 (默认: etc/photographyapi-api.yaml)")
|
fmt.Println(" -f string 配置文件路径 (默认: /etc/photography-api.yaml)")
|
||||||
fmt.Println(" -c string 迁移命令 (默认: status)")
|
fmt.Println(" -c string 迁移命令 (默认: status)")
|
||||||
fmt.Println(" -s int 步数,用于 down 和 migrate 命令")
|
fmt.Println(" -s int 步数,用于 down 和 migrate 命令")
|
||||||
fmt.Println(" -v string 迁移版本,用于特定版本操作")
|
fmt.Println(" -v string 迁移版本,用于特定版本操作")
|
||||||
|
|||||||
@ -3,41 +3,41 @@ Host: 0.0.0.0
|
|||||||
Port: 8080
|
Port: 8080
|
||||||
|
|
||||||
# 数据库配置
|
# 数据库配置
|
||||||
Database:
|
database:
|
||||||
Driver: sqlite
|
driver: sqlite
|
||||||
FilePath: data/photography.db
|
file_path: data/photography.db
|
||||||
Host: localhost
|
host: localhost
|
||||||
Port: 5432
|
port: 5432
|
||||||
Database: photography
|
database: photography
|
||||||
Username: postgres
|
username: postgres
|
||||||
Password: ""
|
password: ""
|
||||||
Charset: utf8mb4
|
charset: utf8mb4
|
||||||
SSLMode: disable
|
ssl_mode: disable
|
||||||
MaxOpenConns: 100
|
max_open_conns: 100
|
||||||
MaxIdleConns: 10
|
max_idle_conns: 10
|
||||||
|
|
||||||
# 认证配置
|
# 认证配置
|
||||||
Auth:
|
auth:
|
||||||
AccessSecret: photography-secret-key-2024
|
access_secret: photography-secret-key-2024
|
||||||
AccessExpire: 86400
|
access_expire: 86400
|
||||||
|
|
||||||
# 文件上传配置
|
# 文件上传配置
|
||||||
FileUpload:
|
file_upload:
|
||||||
MaxSize: 10485760 # 10MB
|
max_size: 10485760 # 10MB
|
||||||
UploadDir: uploads
|
upload_dir: uploads
|
||||||
AllowedTypes:
|
allowed_types:
|
||||||
- image/jpeg
|
- image/jpeg
|
||||||
- image/png
|
- image/png
|
||||||
- image/gif
|
- image/gif
|
||||||
- image/webp
|
- image/webp
|
||||||
|
|
||||||
# 中间件配置
|
# 中间件配置
|
||||||
Middleware:
|
middleware:
|
||||||
EnableCORS: true
|
enable_cors: true
|
||||||
EnableLogger: true
|
enable_logger: true
|
||||||
EnableErrorHandle: true
|
enable_error_handle: true
|
||||||
CORSOrigins:
|
cors_origins:
|
||||||
- http://localhost:3000
|
- http://localhost:3000
|
||||||
- http://localhost:3001
|
- http://localhost:3001
|
||||||
- http://localhost:5173
|
- http://localhost:5173
|
||||||
LogLevel: info
|
log_level: info
|
||||||
|
|||||||
Reference in New Issue
Block a user