FROM golang:1.25-bookworm AS builder

RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc g++ libsqlite3-dev pkg-config ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /build
COPY . .

WORKDIR /build/apps/kanban/backend
RUN CGO_ENABLED=1 go build -ldflags='-s -w' -o /kanban .

# --- Runtime ---
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
    libsqlite3-0 libstdc++6 ca-certificates tzdata \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /kanban /usr/local/bin/kanban

WORKDIR /data
VOLUME /data

EXPOSE 8095

ENTRYPOINT ["/usr/local/bin/kanban"]
CMD ["--port", "8095", "--db", "/data/operations.db"]
