合并 dev_11.9_2 到 dev_11.13
This commit is contained in:
@@ -1,37 +1,12 @@
|
||||
# 快手轻量开发镜像:只保留 Node 运行时和基础工具。
|
||||
# 基础镜像源可整体替换(.env 的 BASE_REGISTRY),原因见 backend.Dockerfile 顶部注释。
|
||||
ARG BASE_REGISTRY=docker.m.daocloud.io
|
||||
FROM ${BASE_REGISTRY}/library/node:22-bookworm
|
||||
|
||||
# 阿里云公共源(全国可达);也可构建时覆盖:--build-arg DEBIAN_MIRROR=mirrors.cloud.aliyuncs.com
|
||||
ARG DEBIAN_MIRROR=mirrors.aliyun.com
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
# 本地 dev 不写死 registry,交给 Docker Desktop 的默认 Docker Hub 与 mirrors。
|
||||
FROM node:22-bookworm-slim
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Asia/Shanghai
|
||||
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# bookworm 基础镜像可能尚无 ca-certificates;国内源常跳 HTTPS,需先跳过校验装证书
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
sed -i "s|http://deb.debian.org/debian|http://${DEBIAN_MIRROR}/debian|g" /etc/apt/sources.list.d/debian.sources \
|
||||
&& sed -i "s|http://security.debian.org/debian-security|http://${DEBIAN_MIRROR}/debian-security|g" /etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get -o Acquire::https::Verify-Peer=false -o Acquire::https::Verify-Host=false update \
|
||||
&& apt-get -o Acquire::https::Verify-Peer=false -o Acquire::https::Verify-Host=false install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
curl tzdata \
|
||||
&& ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \
|
||||
&& echo ${TZ} > /etc/timezone
|
||||
|
||||
COPY apps/backend/package.json apps/backend/package-lock.json ./
|
||||
RUN --mount=type=cache,target=/root/.npm npm ci
|
||||
|
||||
COPY apps/backend/ ./
|
||||
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
+14
-4
@@ -322,10 +322,20 @@ wait_for_health() {
|
||||
print_applied_migrations() {
|
||||
log "已应用数据库迁移"
|
||||
|
||||
local sql migrations
|
||||
sql='SELECT COALESCE(filename, name) FROM schema_migrations ORDER BY COALESCE(filename, name);'
|
||||
|
||||
if migrations="$("${COMPOSE_CMD[@]}" exec -T postgres sh -lc 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Atc "$1"' sh "${sql}" 2>&1)"; then
|
||||
local migrations
|
||||
# 必须从后端真实 DATABASE_URL 读取,不能固定用 postgres 容器的 POSTGRES_DB:
|
||||
# 本地测试库可能通过 DATABASE_URL 指向独立数据库(例如 order_site_test)。
|
||||
if migrations="$("${COMPOSE_CMD[@]}" exec -T backend node --import tsx --input-type=module -e '
|
||||
const { query, closeDb } = await import("./src/db/client.ts");
|
||||
try {
|
||||
const result = await query(
|
||||
"SELECT COALESCE(filename, name) AS name FROM schema_migrations ORDER BY COALESCE(filename, name)"
|
||||
);
|
||||
console.log(result.rows.map((row) => row.name).join("\n"));
|
||||
} finally {
|
||||
await closeDb();
|
||||
}
|
||||
' 2>&1)"; then
|
||||
printf '%s\n' "${migrations:-"(无迁移记录)"}"
|
||||
return
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user