mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 01:20:04 +00:00
Merge pull request #67 from shumaiOne/feat/docker-hardening
refactor(docker): run as non-root bun user and add agent tools
This commit is contained in:
+29
-10
@@ -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
|
||||
|
||||
@@ -3,7 +3,7 @@ import { temporalWorkflow } from './bun-temporal-plugin'
|
||||
import * as worker from '@temporalio/worker'
|
||||
|
||||
vi.mock('@temporalio/worker', () => ({
|
||||
bundleWorkflowCode: vi.fn().mockResolvedValue({ code: 'mock-code', sourceMap: '' })
|
||||
bundleWorkflowCode: vi.fn().mockResolvedValue({ code: 'mock-code', sourceMap: '' }),
|
||||
}))
|
||||
|
||||
describe('temporalWorkflow plugin', () => {
|
||||
@@ -13,14 +13,14 @@ describe('temporalWorkflow plugin', () => {
|
||||
|
||||
it('should register onLoad and configure webpackConfigHook with @temporalio/workflow alias', async () => {
|
||||
const plugin = temporalWorkflow()
|
||||
|
||||
|
||||
let onLoadCallback: ((...args: unknown[]) => unknown) | null = null
|
||||
|
||||
const mockBuild = {
|
||||
onResolve: vi.fn(),
|
||||
onLoad: vi.fn((opts, callback) => {
|
||||
onLoadCallback = callback
|
||||
})
|
||||
}),
|
||||
}
|
||||
|
||||
// Run setup
|
||||
|
||||
@@ -47,9 +47,7 @@ export function temporalWorkflow(options: TemporalWorkflowPluginOptions = {}): B
|
||||
...config.resolve.alias,
|
||||
'@shumai/workflow-core':
|
||||
require.resolve('@shumai/workflow-core/src/workflow-utils.ts'),
|
||||
'@temporalio/workflow': dirname(
|
||||
require.resolve('@temporalio/workflow/package.json'),
|
||||
),
|
||||
'@temporalio/workflow': dirname(require.resolve('@temporalio/workflow/package.json')),
|
||||
}
|
||||
console.log('Webpack config aliases:', config.resolve.alias)
|
||||
if (originalHook) {
|
||||
|
||||
Reference in New Issue
Block a user