# Stage 1: Build
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /gitea-mobile ./cmd/server

# Stage 2: Runtime
# Templates and static assets are embedded in the binary via go:embed,
# so no COPY steps are needed for them.
FROM gcr.io/distroless/static:nonroot
COPY --from=builder /gitea-mobile /gitea-mobile
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/gitea-mobile"]
