FROM ubuntu:jammy AS builder

RUN apt-get update && apt-get install -y \
    g++ \
    python3 \
    cmake \
    flex \
    bison \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /analyze
COPY . .

RUN mkdir build \
    && cd build \
    && cmake -G "Unix Makefiles" .. \
    && make \
    && make install


FROM ubuntu:jammy
RUN apt-get update && apt-get install --no-install-recommends -y \
    graphviz \
    && rm -rf /var/lib/apt/lists/*
COPY --from=builder /analyze/build/bin/analyze /usr/local/bin/
WORKDIR /analyze
ENTRYPOINT ["analyze"]
