FROM node:20-alpine AS css
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install --no-audit --no-fund
COPY tailwind.config.js ./
COPY internal/web ./internal/web
RUN npx tailwindcss -i internal/web/static/css/input.css -o internal/web/static/css/output.css --minify

FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=css /app/internal/web/static/css/output.css ./internal/web/static/css/output.css
RUN CGO_ENABLED=0 go build -tags goolm -o pete .

FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /app/pete .
VOLUME /app/data
EXPOSE 8080
CMD ["./pete", "-config", "/app/config.toml"]
