FROM ubuntu:noble AS builder

RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y build-essential gcc cmake ninja-build python3-pip python3-venv

RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip3 install conan==2.* && conan profile detect

ADD . /root/src
WORKDIR /root/src

RUN mkdir -p build && cd build && \
    conan install .. --build=missing -s:a build_type=Release -s:a compiler.cppstd=gnu20 -of . && \
    cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build . && cmake --install .

FROM ubuntu:noble

RUN apt update && apt install -y curl && apt clean

COPY --from=builder /root/src/build/bin/customer /bin/customer
COPY --from=builder /root/src/build/bin/config.json /bin/config.json

EXPOSE 8080

CMD ["/bin/customer"]

WORKDIR /bin
