FROM golang:1.25 AS builder

COPY . /src
WORKDIR /src

RUN GOPROXY=https://goproxy.cn make build

FROM debian:stable-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
		ca-certificates  \
        netbase \
	        && rm -rf /var/lib/apt/lists/ \
	        && apt-get autoremove -y && apt-get autoclean -y

RUN groupadd --system kra && useradd --system --gid kra --home-dir /app kra

COPY --from=builder --chown=kra:kra /src/bin /app

RUN mkdir -p /data/conf /app/uploads/file && chown -R kra:kra /data/conf /app/uploads

WORKDIR /app

USER kra

EXPOSE 8000
EXPOSE 9000
VOLUME /data/conf

CMD ["./kratos-admin", "-conf", "/data/conf"]
