forked from imbytecat/fullstack-starter
fix(deploy): 端到端跑通编译二进制 + docker compose
端到端验证时发现 4 处细节,一起补上:
1. bin.ts 漏了 default: 'serve'——CMD ["./server"] 会直接吐 help 而
不是起服务(在 compose 里 app 立刻 exit)。citty 原生支持 default
2. Dockerfile 在 bun install 之前就要 COPY patches/,否则 package.json
的 patchedDependencies 找不到补丁文件,install 失败
3. drizzle/ 目录在仓库里必须存在(带 .gitkeep),否则 Dockerfile 末尾
COPY drizzle/ 到运行镜像会失败
4. migrate.ts 之前只检查 ./drizzle 目录是否存在就跳过——空目录时仍会
进到 drizzle 的 readMigrationFiles,报 Can't find meta/_journal.json。
改成检查 meta/_journal.json 是否存在,更准确地区分"还没生成过迁移"
与"有迁移待应用"
验证路径:
- docker compose up -d --build → migrate 完成退出 → app 健康
- curl /api/spec.json → 200,OpenAPI 文档含 todo.{list,create,update,remove}
This commit is contained in:
+3
-2
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs'
|
||||
import { defineCommand } from 'citty'
|
||||
|
||||
const MIGRATIONS_FOLDER = './drizzle'
|
||||
const JOURNAL = `${MIGRATIONS_FOLDER}/meta/_journal.json`
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
@@ -9,8 +10,8 @@ export default defineCommand({
|
||||
description: 'Apply pending database migrations from ./drizzle',
|
||||
},
|
||||
async run() {
|
||||
if (!existsSync(MIGRATIONS_FOLDER)) {
|
||||
console.log(`No ${MIGRATIONS_FOLDER} directory; nothing to apply (use db:push in dev).`)
|
||||
if (!existsSync(JOURNAL)) {
|
||||
console.log(`No migrations found at ${MIGRATIONS_FOLDER} (run \`bun run db:generate\` to create some).`)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user