Skip to content

Commit

Permalink
fix: use multi-stage
Browse files Browse the repository at this point in the history
Final image is around ~250MB
+ use python from ubuntu sources (3.12)
+ don't mess with pip
+ fix typo that broke everything
  • Loading branch information
branylagaffe committed Oct 29, 2024
1 parent 45a68db commit 895affa
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,44 @@
# 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
# Pooria Poorsarvi Tehrani: TODO might not need all of this for installation
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 \
ninja-build \
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 \
Expand All @@ -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"]

0 comments on commit 895affa

Please sign in to comment.