FROM golang:1.22-bookworm AS builder

WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 go build -o /odoo-server ./cmd/odoo-server

FROM debian:bookworm-slim
RUN useradd -m -s /bin/bash odoo
COPY --from=builder /odoo-server /usr/local/bin/odoo-server
COPY --from=builder /build/frontend /app/frontend
COPY --from=builder /build/build /app/build

USER odoo
EXPOSE 8069

ENTRYPOINT ["odoo-server"]
