# syntax=docker/dockerfile:1

FROM golang:1.23-alpine AS builder
WORKDIR /src

# Pull modules first for better layer cache.
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/laodingbot ./cmd/bot

FROM alpine:3.20
WORKDIR /app

RUN apk add --no-cache ca-certificates tzdata

COPY --from=builder /out/laodingbot /app/laodingbot

# Keep default runtime assets in image; can be overridden by bind mounts.
COPY bot_context /app/bot_context
COPY skills /app/skills
COPY workspace/agent_runtime /app/workspace/agent_runtime

ENV MESSAGE_CHANNEL=webui
ENV WEBUI_LISTEN_ADDR=:8090
ENV AGENT_WORKSPACE_DIR=/app/workspace/agent_runtime

# Host can bind mount these directories for persistent/external runtime data.
VOLUME ["/app/workspace/agent_runtime"]

EXPOSE 8090

CMD ["/app/laodingbot"]
