feat: Docker distribution — Dockerfile + compose with opencode#7
feat: Docker distribution — Dockerfile + compose with opencode#7
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces Docker support by adding a multi-stage Dockerfile, a docker-compose configuration, and updated documentation in the README. The review feedback highlights a critical bug where missing migration files in the runner stage would cause the application to fail at startup, and suggests improvements for container security and service orchestration reliability.
| WORKDIR /app | ||
| COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./ | ||
| RUN pnpm install --frozen-lockfile --prod | ||
| COPY --from=builder /app/dist ./dist |
There was a problem hiding this comment.
The application requires the drizzle folder to run database migrations at startup (as seen in src/server/cli.ts). Since the runner stage only copies the dist folder, the migrations will fail. You should copy the migrations folder from the builder stage.
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/drizzle ./drizzle
| COPY . . | ||
| RUN pnpm run build | ||
|
|
||
| FROM node:20-alpine AS runner |
There was a problem hiding this comment.
It is a security best practice to run Docker containers as a non-root user. The node image provides a built-in node user that can be used for this purpose. Ensure that the /app directory and any mounted volumes have the correct permissions for this user.
FROM node:20-alpine AS runner
RUN corepack enable
WORKDIR /app
USER node
| @@ -0,0 +1,47 @@ | |||
| services: | |||
| agentree: | |||
There was a problem hiding this comment.
When using the with-opencode profile, the agentree service should wait for the opencode service to be healthy before starting. This prevents agentree from exiting immediately if it cannot connect to opencode during the initial boot sequence.
agentree:
build: .
depends_on:
opencode:
condition: service_healthy
required: false
Closes #4
What
Dockerfile— multi-stage build (builder → runner). Produces a minimal image with onlydist/+ prod dependencies.docker-compose.yml— two modes:docker compose up agentree— agentree only (connect to existing opencode)docker compose --profile with-opencode up— full stack (opencode + agentree).dockerignore— excludes node_modules, dist, .env, .git, docs, assetsREADME.md— added Docker section under Quick startWhy
Users who prefer containers can run agentree without Node.js installed. The
with-opencodeprofile handles the "I don't have opencode yet" case.Test plan
pnpm testpassespnpm exec tsc --noEmitpassespnpm exec tsc --noEmit -p tsconfig.client.jsonpassesdocker compose build agentreebuilds successfullydocker compose --profile with-opencode upstarts both services