refactor(docker): run as non-root bun user and add agent tools

This commit is contained in:
yiling
2026-06-06 10:43:19 +08:00
parent 075755b4ad
commit 823175d487
3 changed files with 33 additions and 16 deletions
+29 -10
View File
@@ -22,18 +22,37 @@ RUN bun run build.ts
# Stage 2: Runner
FROM oven/bun:1 AS runner
WORKDIR /app
# Install ffmpeg/ffprobe
COPY --from=mwader/static-ffmpeg:8.1 /ffmpeg /usr/local/bin/
COPY --from=mwader/static-ffmpeg:8.1 /ffprobe /usr/local/bin/
# Install system dependencies for sandbox runtime
RUN apt-get update && apt-get install -y ripgrep bubblewrap socat && rm -rf /var/lib/apt/lists/*
# Install system dependencies for sandbox runtime and agent
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
make \
man-db \
curl \
dnsutils \
less \
jq \
bc \
unzip \
rsync \
ripgrep \
procps \
lsof \
socat \
ca-certificates \
bubblewrap \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy sharp/img from builder (they are native and already installed)
# COPY --from=builder /app/packages/transcode/node_modules/sharp ./node_modules/sharp
# COPY --from=builder /app/packages/transcode/node_modules/@img ./node_modules/@img
# Set up working directory and make it owned by the bun user
RUN mkdir -p /app/data && chown -R bun:bun /app
# Switch to the non-root bun user
USER bun
WORKDIR /app
# Manually install temporalio packages and prisma
# These need native bindings or CLI access in the runner environment
@@ -41,9 +60,9 @@ RUN bun add @temporalio/activity @temporalio/client @temporalio/worker @temporal
bun add --dev --omit peer prisma sharp
# Copy build artifacts and prisma config
COPY --from=builder /app/dist ./
COPY --from=builder /app/packages/db/prisma ./packages/db/prisma
COPY --from=builder /app/prisma.config.ts.prod ./prisma.config.ts
COPY --chown=bun:bun --from=builder /app/dist ./
COPY --chown=bun:bun --from=builder /app/packages/db/prisma ./packages/db/prisma
COPY --chown=bun:bun --from=builder /app/prisma.config.ts.prod ./prisma.config.ts
# Expose port (Bun Hono defaults to 3000)
EXPOSE 3000