From 895affa0d35e7b680c88619649988607541af03d Mon Sep 17 00:00:00 2001 From: Bryan Perdrizat Date: Wed, 30 Oct 2024 00:52:23 +0100 Subject: [PATCH] fix: use multi-stage Final image is around ~250MB + use python from ubuntu sources (3.12) + don't mess with pip + fix typo that broke everything --- Dockerfile | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index ccc95ceff8..e7558575ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ # syntax=docker/dockerfile:1.4 -# Pooria Poorsarvi Tehrani: TODO change the base to something way lighter -FROM ubuntu:24.04 +# First Stage - Build environement +FROM ubuntu:24.04 as build ENV DEBIAN_FRONTEND=noninteractive - ARG DEBUG_MODE=release # Update the package list and install prerequisites @@ -13,15 +12,12 @@ ARG DEBUG_MODE=release RUN apt update && apt upgrade -y && apt install -y software-properties-common build-essential # Pooria Poorsarvi Tehrani: TODO maybe move to even a newer version of python -# Add the deadsnakes PPA for Python 3.10 -RUN add-apt-repository ppa:deadsnakes/ppa -y RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y RUN apt update && apt install -y --no-install-recommends wget \ curl \ git \ - gdb - RUN \ + gdb \ libcapstone-dev \ libslirp-dev \ libglib2.0-dev \ @@ -29,28 +25,20 @@ RUN apt update && apt install -y --no-install-recommends wget \ cmake \ meson \ gcc-14 g++-14 \ - python3.10 python3.10-venv python3.10-dev python3.10-distutils python3-apt \ - && rm -rf /var/lib/apt/lists/* \ + python3 python3-venv python3-pip python3-setuptools python3-wheel \ + && rm -rf /var/lib/apt/lists/* \ && rm -rf /usr/lib/python3/dist-packages/distro* -RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 \ - && python3.10 -m pip install --upgrade pip \ - setuptools \ - wheel \ - conan \ - && python3.10 -m pip cache purge +RUN pip install --break-system-package conan && pip cache purge -# So weird that alternatives can mess up distro -RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 \ - && update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 +COPY --link . /qflex-src +WORKDIR /qflex-src ENV CC=/usr/bin/gcc-14 ENV CXX=/usr/bin/g++-14 -COPY . /qflex-src -WORKDIR /qflex-src - RUN conan profile detect \ + && mkdir /qflex \ && conan build flexus -pr flexus/target/_profile/${DEBUG_MODE} --name=keenkraken -of /qflex/out -b missing \ && conan build flexus -pr flexus/target/_profile/${DEBUG_MODE} --name=knottykraken -of /qflex/out -b missing \ && conan export-pkg flexus -pr flexus/target/_profile/${DEBUG_MODE} --name=keenkraken -of /qflex/out \ @@ -61,7 +49,15 @@ RUN conan profile detect \ && cp -v qemu/build/aarch64-softmmu/qemu-system-aarch64 /qflex/qemu-aarch64 WORKDIR /qflex -COPY /qflex-src/runq /qflex +RUN cp /qflex-src/runq /qflex/ RUN rm -rf /qflex/out/*kraken && rm -rf /qflex-src +# Second Stage - Run environement +FROM ubuntu:24.04 +ENV DEBIAN_FRONTEND=noninteractive + +COPY --from=build /qflex /qflex +RUN apt update && apt install -y --no-install-recommends libcapstone4 libslirp0 python3 + +WORKDIR /qflex CMD ["bash"]