Docker: cache deps layer for faster rebuilds (#605)

This commit is contained in:
Zach Knickerbocker
2026-01-09 15:23:06 -05:00
committed by GitHub
parent e8dbb350ae
commit c6fc7c2ea6
3 changed files with 47 additions and 2 deletions

View File

@@ -8,9 +8,14 @@ RUN corepack enable
WORKDIR /app WORKDIR /app
COPY . . 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 RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build RUN pnpm build
RUN pnpm ui:install RUN pnpm ui:install
RUN pnpm ui:build RUN pnpm ui:build

View File

@@ -61,6 +61,40 @@ docker compose run --rm clawdbot-cli onboard
docker compose up -d clawdbot-gateway docker compose up -d clawdbot-gateway
``` ```
### Faster rebuilds (recommended)
To speed up rebuilds, order your Dockerfile so dependency layers are cached.
This avoids re-running `pnpm install` unless lockfiles change:
```dockerfile
FROM node:22-bookworm
# 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
# Cache dependencies unless package metadata changes
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
RUN pnpm ui:install
RUN pnpm ui:build
ENV NODE_ENV=production
CMD ["node","dist/index.js"]
```
### Provider setup (optional) ### Provider setup (optional)
Use the CLI container to configure providers, then restart the gateway if needed. Use the CLI container to configure providers, then restart the gateway if needed.

View File

@@ -214,9 +214,15 @@ RUN curl -L https://github.com/steipete/wacli/releases/latest/download/wacli_Lin
# Add more binaries below using the same pattern # Add more binaries below using the same pattern
WORKDIR /app WORKDIR /app
COPY . . COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY ui/package.json ./ui/package.json
COPY patches ./patches
COPY scripts ./scripts
RUN corepack enable RUN corepack enable
RUN pnpm install --frozen-lockfile RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build RUN pnpm build
RUN pnpm ui:install RUN pnpm ui:install
RUN pnpm ui:build RUN pnpm ui:build