FROM rust:1-bookworm AS build
WORKDIR /app/src/components/backend-core
COPY src/components/backend-core/Cargo.toml ./Cargo.toml
COPY src/components/backend-core/Cargo.lock ./Cargo.lock
COPY src/components/backend-core/src ./src
RUN CARGO_BUILD_JOBS=1 cargo build --release

FROM postgres:16-bookworm
RUN apt-get update \
  && apt-get install -y --no-install-recommends ca-certificates tar gzip \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*
COPY --from=build /app/src/components/backend-core/target/release/backend-core /usr/local/bin/backend-core
ENTRYPOINT []
CMD ["backend-core"]
