Initial commit: CarrotAssistant backend (Go + Gin + SQLite, OpenAI-compatible agent runtime)

This commit is contained in:
2026-07-06 16:10:55 +08:00
commit 5f84739b18
40 changed files with 4781 additions and 0 deletions

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
# Multi-stage build for the CarrotAssistant backend.
#
# The cgo SQLite driver requires gcc in the build image; the final image is
# Debian-based (slim) and ships only the compiled binary plus ca-certificates
# for outbound HTTPS to model providers and target sites.
FROM golang:1.26-bookworm AS builder
WORKDIR /src
# Cache deps first.
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# CGO_ENABLED=1 is required by go-sqlite3.
RUN CGO_ENABLED=1 GOOS=linux go build -trimpath -ldflags='-s -w' -o /out/carrot ./cmd/server
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /out/carrot /usr/local/bin/carrot
# Persistent state (sqlite db + skill markdown) lives under /data and is
# expected to be a mounted volume.
ENV DATA_DIR=/data
EXPOSE 8080
ENTRYPOINT ["carrot"]