# syntax=docker/dockerfile:1

FROM node:20-alpine AS frontend-builder
WORKDIR /app/ui
COPY ui/package*.json ./
RUN npm ci
COPY ui/ ./
RUN npm run build

FROM golang:1.26-alpine AS backend-builder
WORKDIR /app
COPY server/go.mod server/go.sum ./
RUN go mod download
COPY server/ ./
COPY --from=frontend-builder /app/ui/build ./web/dist
RUN CGO_ENABLED=0 go build -o /wedding-server .

FROM alpine:3.20
RUN apk add --no-cache ca-certificates
COPY --from=backend-builder /wedding-server /usr/local/bin/wedding-server
WORKDIR /app
EXPOSE 8080
ENTRYPOINT ["wedding-server"]
