feat: 后台打包测试部署
All checks were successful
Backend Deploy (Go + Docker) / deploy (push) Successful in 1m29s
All checks were successful
Backend Deploy (Go + Docker) / deploy (push) Successful in 1m29s
This commit is contained in:
@@ -10,8 +10,7 @@ WORKDIR /app
|
||||
COPY server_bin .
|
||||
RUN chmod +x server_bin
|
||||
|
||||
# 拷贝数据库迁移文件 (服务启动时自动执行)
|
||||
COPY migrations ./migrations
|
||||
# 数据库迁移现已通过 MCP 手动管理,不再打包进镜像
|
||||
|
||||
EXPOSE 8009
|
||||
|
||||
|
||||
@@ -21,9 +21,6 @@ import (
|
||||
"github.com/zs/InsightReply/internal/service"
|
||||
"github.com/zs/InsightReply/internal/worker"
|
||||
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
_ "github.com/golang-migrate/migrate/v4/database/postgres"
|
||||
_ "github.com/golang-migrate/migrate/v4/source/file"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -58,19 +55,6 @@ func main() {
|
||||
}
|
||||
fmt.Println("Database connection established")
|
||||
|
||||
// 2.1 Run Database Migrations
|
||||
log.Println("Running database migrations...")
|
||||
m, err := migrate.New("file://migrations", dsn)
|
||||
if err != nil {
|
||||
log.Printf("Failed to initialize migrate, skipping: %v", err)
|
||||
} else {
|
||||
if err := m.Up(); err != nil && err != migrate.ErrNoChange {
|
||||
log.Printf("Failed to run migrate (maybe tables already exist), continuing: %v", err)
|
||||
} else {
|
||||
log.Println("Database migrations applied successfully")
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Initialize Layers
|
||||
userRepo := repository.NewUserRepository(db)
|
||||
userSvc := service.NewUserService(userRepo)
|
||||
|
||||
Reference in New Issue
Block a user