FROM golang:1.22-alpine AS build

WORKDIR /app

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

COPY src ./src
COPY static ./static

RUN CGO_ENABLED=0 GOOS=linux go build -o /out/scrum-solitare ./src

FROM alpine:3.21

WORKDIR /app

RUN addgroup -S app && adduser -S app -G app

COPY --from=build /out/scrum-solitare /app/scrum-solitare
COPY --from=build /app/src/templates /app/src/templates
COPY --from=build /app/static /app/static

RUN mkdir -p /app/data && chown -R app:app /app

EXPOSE 8002
ENV HOST=0.0.0.0
ENV PORT=8002
ENV MAX_ACTIVITY_LOG_ENTRIES=400
ENV ADMIN_LOG_BROADCAST_LIMIT=200
ENV STALE_ROOM_CLEANUP_INTERVAL=5m
ENV STALE_ROOM_TTL=30m

USER app

ENTRYPOINT ["/app/scrum-solitare"]
