fix: 移除重复用户创建,使用镜像预置的 bun 用户
Some checks failed
CI/CD Pipeline / Code Quality (push) Successful in 22s
CI/CD Pipeline / Unit Tests (push) Successful in 15s
CI/CD Pipeline / Build Test Image (push) Has been skipped
CI/CD Pipeline / Deploy to Test (push) Has been skipped
CI/CD Pipeline / Build Production Image (push) Failing after 10s
CI/CD Pipeline / Deploy to Production (push) Has been skipped

- oven/bun:1.3 已包含 bun 用户,无需重复创建
- chown 使用 bun:bun 而非 bun:nodejs
This commit is contained in:
Wang Zhuoxuan 2026-04-17 16:20:12 +08:00
parent f390e23ba7
commit 525c433937

View File

@ -23,21 +23,19 @@ RUN bun run build
FROM oven/bun:1.3 AS release FROM oven/bun:1.3 AS release
WORKDIR /app WORKDIR /app
# 创建非 root 用户Debian 兼容命令)
RUN groupadd --system --gid 1001 nodejs && \
useradd --system --uid 1001 --gid nodejs --no-create-home --shell /usr/sbin/nologin bun
# 安装 curl用于健康检查 # 安装 curl用于健康检查
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
# oven/bun 镜像已预置 bun 用户 (uid 1001),直接使用
# 复制生产依赖和构建产物 # 复制生产依赖和构建产物
COPY --from=install /app/node_modules ./node_modules COPY --from=install /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist COPY --from=build /app/dist ./dist
COPY --from=build /app/db ./db COPY --from=build /app/db ./db
COPY --from=build /app/package.json ./ COPY --from=build /app/package.json ./
# 设置权限 # 设置权限bun 用户已存在,使用其默认组)
RUN chown -R bun:nodejs /app RUN chown -R bun:bun /app
USER bun USER bun
# 暴露端口 # 暴露端口