fix: Dockerfile 复制 src/lib + 部署脚本移除冗余 build
This commit is contained in:
parent
befefb91ac
commit
13e5bfdbbf
|
|
@ -20,6 +20,7 @@ ENV NODE_ENV=production
|
||||||
COPY --from=base /app/.next/standalone ./
|
COPY --from=base /app/.next/standalone ./
|
||||||
COPY --from=base /app/.next/static ./.next/static
|
COPY --from=base /app/.next/static ./.next/static
|
||||||
COPY --from=base /app/scripts ./scripts
|
COPY --from=base /app/scripts ./scripts
|
||||||
|
COPY --from=base /app/src/lib ./src/lib
|
||||||
COPY --from=base /app/shared ./shared
|
COPY --from=base /app/shared ./shared
|
||||||
COPY entrypoint.sh ./
|
COPY entrypoint.sh ./
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -244,25 +244,9 @@ build_on_server() {
|
||||||
# 7. 清理可能被上传的本地环境变量文件
|
# 7. 清理可能被上传的本地环境变量文件
|
||||||
ssh txjp "rm -f $REMOTE_DIR/.env.local $REMOTE_DIR/.env.development $REMOTE_DIR/.env.production 2>/dev/null; echo '已清理本地环境文件'"
|
ssh txjp "rm -f $REMOTE_DIR/.env.local $REMOTE_DIR/.env.development $REMOTE_DIR/.env.production 2>/dev/null; echo '已清理本地环境文件'"
|
||||||
|
|
||||||
# 8. 服务器上执行 npm run build
|
# 8. 重建容器(Dockerfile 内完成构建)
|
||||||
log "服务器上执行 npm run build..."
|
|
||||||
local build_start build_end build_dur
|
|
||||||
build_start=$(date +%s)
|
|
||||||
ssh txjp "cd ${REMOTE_DIR} && npm run build 2>&1" | \
|
|
||||||
grep -vE "^(info|warn|npm warn|audited|packages|funding|vulnerability|npm notice|New major)" | \
|
|
||||||
tail -15
|
|
||||||
local build_exit_code=${PIPESTATUS[0]}
|
|
||||||
build_end=$(date +%s)
|
|
||||||
build_dur=$((build_end - build_start))
|
|
||||||
timing "构建耗时: ${build_dur}s"
|
|
||||||
|
|
||||||
if [[ "$build_exit_code" -ne 0 ]]; then
|
|
||||||
warn "构建可能有警告,请检查上面的输出"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 9. 重建容器
|
|
||||||
log "重建容器..."
|
log "重建容器..."
|
||||||
ssh txjp "cd $REMOTE_DIR && docker compose up -d && docker compose restart"
|
ssh txjp "cd $REMOTE_DIR && docker compose up -d --build && docker compose restart"
|
||||||
|
|
||||||
# 10. 清理构建缓存
|
# 10. 清理构建缓存
|
||||||
log "清理构建缓存..."
|
log "清理构建缓存..."
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue