FROM golang:1.25-alpine AS builder
RUN apk add --no-cache git make gcc musl-dev sqlite-dev python3 py3-pip npm \
autoconf automake libtool python3-dev jq-dev
RUN pip3 install --break-system-packages uv
WORKDIR /build
COPY agfs-sdk /agfs-sdk
COPY agfs-server/go.mod agfs-server/go.sum ./
RUN go mod download
COPY agfs-server .
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-w -s" -o agfs-server cmd/server/main.go
WORKDIR /build-shell
COPY agfs-shell .
RUN python3 build.py
FROM alpine:latest
RUN apk add --no-cache ca-certificates sqlite-libs python3 jq oniguruma
WORKDIR /app
COPY --from=builder /build/agfs-server .
COPY --from=builder /build/config.example.yaml /config.example.yaml
COPY --from=builder /build/config.example.yaml /config.yaml
COPY --from=builder /build-shell/dist/agfs-shell-portable /usr/local/agfs-shell
RUN ln -s /usr/local/agfs-shell/agfs-shell /usr/local/bin/agfs-shell
RUN mkdir -p /data
EXPOSE 8080
ENTRYPOINT ["./agfs-server"]
CMD ["-c", "/config.yaml"]