# Multi-stage build for Konduktor
FROM golang:1.23-alpine AS builder

RUN apk add --no-cache git make

WORKDIR /build

COPY go.mod go.sum* ./
RUN go mod download

COPY . .

RUN make build

FROM alpine:3.19

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

RUN adduser -D -g '' konduktor

WORKDIR /app

COPY --from=builder /build/bin/konduktor /usr/local/bin/
COPY --from=builder /build/bin/konduktorctl /usr/local/bin/

RUN mkdir -p /app/static /app/templates /app/logs && \
    chown -R konduktor:konduktor /app

USER konduktor

EXPOSE 8080

ENTRYPOINT ["konduktor"]
CMD ["-c", "/app/config.yaml"]
