Skip to content

feat: Docker distribution — agentree container + compose with opencode #4

@StatPan

Description

@StatPan

Problem or motivation

After #3 ships npx agentree, users who prefer containers (or want a one-command stack) should be able to run:

# With existing opencode:
docker run -e OPENCODE_API_URL=http://host.docker.internal:6543 -p 3001:3001 ghcr.io/statpan/agentree

# Full stack (opencode + agentree together):
docker compose up

Depends on: #3 (CLI entry point must exist for the container's CMD)

Proposed solution

Dockerfile (multi-stage)

FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build

FROM node:20-alpine AS runner
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./
RUN corepack enable && pnpm install --prod --frozen-lockfile
ENV PORT=3001
EXPOSE 3001
CMD ["node", "dist/server/cli.js"]

docker-compose.yml

Two profiles:

  • Default: agentree only (expects OPENCODE_API_URL pointing to existing opencode)
  • --profile with-opencode: brings up opencode alongside agentree
services:
  agentree:
    image: ghcr.io/statpan/agentree:latest
    ports: ["3001:3001"]
    environment:
      - OPENCODE_API_URL=${OPENCODE_API_URL:-http://opencode:6543}
      - DB_PATH=/data/agentree.db
    volumes:
      - agentree_data:/data

  opencode:
    profiles: [with-opencode]
    image: ghcr.io/anomalyco/opencode:latest
    # ... same config as docker-compose.opencode.yml

.dockerignore

Exclude node_modules/, dist/, .env*, *.db*, src/, docs/.

GitHub Actions: publish Docker image

Add .github/workflows/docker.yml to build and push to ghcr.io/statpan/agentree on tag push (v*).

README

Add Docker usage section.

Alternatives considered

  • Single monolithic compose file (no profiles) — rejected, adds mandatory opencode dependency even for users who already have it.
  • npm create agentree@latest interactive setup wizard — deferred to a later issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions