feat: add Docker support and inbound webhooks (Tier 2)
- Dockerfile: multi-stage build (node:22-alpine), better-sqlite3 native deps handled
- .dockerignore + docker-compose.yml for deployment
- FLYNN_DATA_DIR env var support in daemon, CLI, and TUI
- WebhookHandler: ChannelAdapter for HTTP POST /webhooks/:name
- Per-webhook HMAC auth, template rendering ({{body}}, {{json.field}})
- Config schema: automation.webhooks array with name/secret/message/output
- Gateway routes webhook requests before static files (bypasses gateway auth)
- 23 new tests for webhook functionality, 874 total tests passing
This commit is contained in:
+72
@@ -0,0 +1,72 @@
|
||||
# ── Builder stage ──────────────────────────────────────────────
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
# Enable corepack for pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
# Install native build tools (needed for better-sqlite3)
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency manifests first (layer caching)
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
|
||||
# Install dependencies (frozen lockfile for reproducibility)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy source and config
|
||||
COPY tsconfig.json ./
|
||||
COPY src/ src/
|
||||
COPY config/ config/
|
||||
|
||||
# Build TypeScript
|
||||
RUN pnpm build
|
||||
|
||||
|
||||
# ── Runtime stage ─────────────────────────────────────────────
|
||||
FROM node:22-alpine
|
||||
|
||||
# Label
|
||||
LABEL org.opencontainers.image.title="Flynn" \
|
||||
org.opencontainers.image.description="Self-hosted personal AI agent" \
|
||||
org.opencontainers.image.source="https://github.com/will666/flynn"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy node_modules from builder (includes compiled native deps like better-sqlite3)
|
||||
COPY --from=builder /app/node_modules/ node_modules/
|
||||
|
||||
# Copy compiled output
|
||||
COPY --from=builder /app/dist/ dist/
|
||||
|
||||
# Copy gateway UI static files into dist/gateway/ui so import.meta.dirname
|
||||
# resolution from dist/daemon/index.js (../gateway/ui) resolves correctly
|
||||
COPY --from=builder /app/src/gateway/ui/ dist/gateway/ui/
|
||||
|
||||
# Copy default config
|
||||
COPY --from=builder /app/config/ config/
|
||||
|
||||
# Copy package.json (needed for bin resolution / metadata)
|
||||
COPY --from=builder /app/package.json ./
|
||||
|
||||
# Copy SOUL.md if it exists (prompt template loaded at runtime)
|
||||
COPY --from=builder /app/SOUL.md ./
|
||||
|
||||
# Create data directories
|
||||
RUN mkdir -p /data/memory /data/sessions /config
|
||||
|
||||
# Environment
|
||||
ENV NODE_ENV=production \
|
||||
FLYNN_CONFIG=/config/config.yaml \
|
||||
FLYNN_DATA_DIR=/data
|
||||
|
||||
# Gateway port
|
||||
EXPOSE 18800
|
||||
|
||||
# Health check — verify the gateway is responding
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
||||
CMD wget -qO- http://localhost:18800/ || exit 1
|
||||
|
||||
ENTRYPOINT ["node", "dist/cli/index.js"]
|
||||
CMD ["start"]
|
||||
Reference in New Issue
Block a user