FROM oven/bun:1 AS frontend
WORKDIR /app/frontend
COPY frontend/ .
RUN bun install && bun run build

FROM golang:1.24-alpine AS backend
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /paliad ./cmd/server

FROM alpine:3.21
RUN apk add --no-cache ca-certificates openssh-client
WORKDIR /app
COPY --from=backend /paliad /app/paliad
COPY --from=frontend /app/frontend/dist /app/dist
EXPOSE 8080
CMD ["/app/paliad"]
