# Stage 1: Build the UI bundle FROM oven/bun:1.3.9-alpine AS frontend-builder WORKDIR /app # Copy the lockfile so `bun ci` can accurately install COPY src/frontend/package.json src/frontend/bun.lock ./ RUN bun ci COPY src/frontend/ ./ RUN bun run build # Stage 2: Build the static Go binary FROM golang:1.26-alpine AS go-builder WORKDIR /app COPY src/go.mod src/go.sum ./ RUN go mod download # This dumps main.go and the frontend dir into /app COPY src/ . # Copy the built UI into the frontend folder so go:embed finds it COPY --from=frontend-builder /app/dist ./frontend/dist # Build a statically linked binary, stripping debug symbols (-s -w) for smaller size RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o server . RUN apk add --no-cache ca-certificates # Stage 3: The final minimal image FROM scratch # The binary is at /app/server, not src/app/server COPY --from=go-builder /app/server /server # Copy SSL certs COPY --from=go-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ EXPOSE 8080 ENTRYPOINT ["/server"]