Files
backend/Dockerfile

25 lines
892 B
Docker

# 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"]