FROM golang:1.24.5-alpine AS build

WORKDIR /src

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

COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/status .

FROM alpine:3.22

WORKDIR /app

RUN adduser -D -H -u 10001 appuser

COPY --from=build /out/status /app/status
COPY config.yaml /app/config.yaml
COPY templates /app/templates
COPY static /app/static

ENV ADDR=:8080
ENV CONFIG_PATH=/app/config.yaml

EXPOSE 8080

USER appuser

CMD ["/app/status"]
