FROM golang:1.25-alpine AS builder

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

WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /ultid ./cmd/ultid

FROM alpine:3.20

RUN apk add --no-cache ca-certificates tzdata wget \
    && addgroup -S ulti && adduser -S ulti -G ulti

COPY --from=builder /ultid /usr/local/bin/ultid

USER ulti
EXPOSE 8080

ENTRYPOINT ["ultid"]
