forgejo-tickets/Dockerfile

30 lines
955 B
Docker

# Stage 1: Build Tailwind CSS
FROM node:22-alpine AS tailwind
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install
COPY web/static/css/input.css web/static/css/input.css
COPY web/templates/ web/templates/
COPY web/static/js/ web/static/js/
COPY internal/handlers/ internal/handlers/
RUN npx @tailwindcss/cli -i web/static/css/input.css -o web/static/css/output.css --minify
# Stage 2: Build Go binary
FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=tailwind /app/web/static/css/output.css web/static/css/output.css
RUN CGO_ENABLED=0 GOOS=linux go build -o forgejo-tickets ./cmd/server
# Stage 3: Minimal runtime
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /app/forgejo-tickets .
COPY --from=builder /app/web/templates web/templates
COPY --from=builder /app/web/static web/static
EXPOSE 8080 8081
CMD ["./forgejo-tickets"]