Merge pull request #25 from techops-services/fix/dockerfile-build-from-source
fix: build clawdbot from source instead of upstream image
This commit is contained in:
commit
70ed529c6f
@ -1,29 +1,61 @@
|
|||||||
# Stage 1: Build extension
|
# Stage 1: Build clawdbot from source
|
||||||
FROM node:22-slim AS builder
|
FROM node:22-bookworm AS clawdbot-builder
|
||||||
|
|
||||||
|
# Install Bun (required for build scripts)
|
||||||
|
RUN curl -fsSL https://bun.sh/install | bash
|
||||||
|
ENV PATH="/root/.bun/bin:${PATH}"
|
||||||
|
|
||||||
|
RUN corepack enable
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||||
|
COPY ui/package.json ./ui/package.json
|
||||||
|
COPY patches ./patches
|
||||||
|
COPY scripts ./scripts
|
||||||
|
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
# Force pnpm for UI build (Bun may fail on ARM/Synology architectures)
|
||||||
|
ENV CLAWDBOT_PREFER_PNPM=1
|
||||||
|
RUN pnpm ui:install
|
||||||
|
RUN pnpm ui:build
|
||||||
|
|
||||||
|
# Stage 2: Build checkins extension
|
||||||
|
FROM node:22-slim AS extension-builder
|
||||||
|
|
||||||
# Install git (needed by npm for some deps)
|
|
||||||
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY extensions/checkins ./
|
COPY extensions/checkins ./
|
||||||
|
|
||||||
# Install all deps (including devDependencies for tsc) and build
|
|
||||||
RUN npm install && npm run build
|
RUN npm install && npm run build
|
||||||
|
|
||||||
# Stage 2: Production image
|
# Stage 3: Production image
|
||||||
FROM ghcr.io/clawdbot/clawdbot:main
|
FROM node:22-bookworm-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy built clawdbot
|
||||||
|
COPY --from=clawdbot-builder /app/dist ./dist
|
||||||
|
COPY --from=clawdbot-builder /app/node_modules ./node_modules
|
||||||
|
COPY --from=clawdbot-builder /app/package.json ./package.json
|
||||||
|
COPY --from=clawdbot-builder /app/ui/dist ./ui/dist
|
||||||
|
|
||||||
# Copy the pre-built extension to staging (PVC will mount over /root/.clawdbot)
|
# Copy the pre-built extension to staging (PVC will mount over /root/.clawdbot)
|
||||||
COPY --from=builder /build /app/bundled-plugins/checkins
|
COPY --from=extension-builder /build /app/bundled-plugins/checkins
|
||||||
|
|
||||||
# Copy default config
|
# Copy default config
|
||||||
COPY deploy/prod/clawdbot.json /app/clawdbot.default.json
|
COPY deploy/prod/clawdbot.json /app/clawdbot.default.json
|
||||||
|
|
||||||
# Install production dependencies in staging
|
# Install production dependencies for extension
|
||||||
WORKDIR /app/bundled-plugins/checkins
|
WORKDIR /app/bundled-plugins/checkins
|
||||||
RUN rm -rf node_modules && npm install --omit=dev
|
RUN rm -rf node_modules && npm install --omit=dev
|
||||||
|
|
||||||
# Create entrypoint script - copies plugin from staging to plugins dir at runtime
|
# Create entrypoint script
|
||||||
RUN echo '#!/bin/sh\n\
|
RUN echo '#!/bin/sh\n\
|
||||||
if [ ! -f "/root/.clawdbot/clawdbot.json" ]; then\n\
|
if [ ! -f "/root/.clawdbot/clawdbot.json" ]; then\n\
|
||||||
echo "Creating default config..."\n\
|
echo "Creating default config..."\n\
|
||||||
@ -36,6 +68,7 @@ cp -r /app/bundled-plugins/checkins /root/.clawdbot/extensions/\n\
|
|||||||
exec node /app/dist/entry.js gateway run\n\
|
exec node /app/dist/entry.js gateway run\n\
|
||||||
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
|
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
WORKDIR /root/.clawdbot
|
WORKDIR /root/.clawdbot
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"]
|
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user