11ARG BASE_IMAGE="ubuntu:20.04"
22ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,aarch64-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu,mips64el-softmmu"
3- ARG LIBOSI_VERSION="v0.1.7"
43
54# ## BASE IMAGE
6- FROM $BASE_IMAGE as base
5+ FROM $BASE_IMAGE AS base
76ARG BASE_IMAGE
87
98# Copy dependencies lists into container. We copy them all and then do a mv because
@@ -16,22 +15,19 @@ RUN mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_build.txt /tmp/build_dep.txt &
1615# Base image just needs runtime dependencies
1716RUN [ -e /tmp/base_dep.txt ] && \
1817 apt-get -qq update && \
19- DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends curl $(cat /tmp/base_dep.txt | grep -o '^[^#]*' ) && \
18+ DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends curl jq $(cat /tmp/base_dep.txt | grep -o '^[^#]*' ) && \
2019 apt-get clean
2120
2221# ## BUILD IMAGE - STAGE 2
2322FROM base AS builder
2423ARG BASE_IMAGE
2524ARG TARGET_LIST
26- ARG LIBOSI_VERSION
2725
2826RUN [ -e /tmp/build_dep.txt ] && \
2927 apt-get -qq update && \
3028 DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*' ) && \
3129 apt-get clean && \
3230 python3 -m pip install --upgrade --no-cache-dir pip && \
33- python3 -m pip install --upgrade --no-cache-dir "cffi>1.14.3" && \
34- python3 -m pip install --upgrade --no-cache-dir "capstone" && \
3531 curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
3632
3733# Then install capstone from source
@@ -43,13 +39,19 @@ RUN cd /tmp && \
4339ENV PATH="/root/.cargo/bin:${PATH}"
4440
4541# install libosi
46- RUN cd /tmp && curl -LJO https://github.com/panda-re/libosi/releases/download/${LIBOSI_VERSION}/libosi_$(echo "$BASE_IMAGE" | awk -F':' '{print $2}' ).deb && dpkg -i /tmp/libosi_$(echo "$BASE_IMAGE" | awk -F':' '{print $2}' ).deb
42+ RUN cd /tmp && \
43+ BASE_IMAGE_VERSION=$(echo "$BASE_IMAGE" | awk -F':' '{print $2}' ) && \
44+ LIBOSI_VERSION=$(curl -s https://api.github.com/repos/panda-re/libosi/releases/latest | jq -r .tag_name) && \
45+ curl -LJO https://github.com/panda-re/libosi/releases/download/${LIBOSI_VERSION}/libosi_${BASE_IMAGE_VERSION}.deb && \
46+ dpkg -i /tmp/libosi_${BASE_IMAGE_VERSION}.deb && \
47+ rm -rf /tmp/libosi_${BASE_IMAGE_VERSION}.deb
4748
4849# Build and install panda
4950# Copy repo root directory to /panda, note we explicitly copy in .git directory
5051# Note .dockerignore file keeps us from copying things we don't need
5152COPY . /panda/
5253COPY .git /panda/
54+ RUN python3 -m pip install -r /panda/panda/python/core/requirements.txt
5355
5456# Note we diable NUMA for docker builds because it causes make check to fail in docker
5557RUN git -C /panda submodule update --init dtc && \
@@ -64,14 +66,13 @@ RUN git -C /panda submodule update --init dtc && \
6466 --disable-numa \
6567 --enable-llvm && \
6668 rm -rf /panda/.git
67-
6869
6970RUN PRETEND_VERSION=$(cat /tmp/savedversion) make -C /panda/build -j "$(nproc)"
7071
7172# ### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
72- FROM builder as developer
73+ FROM builder AS developer
7374RUN cd /panda/panda/python/core && \
74- python3 create_panda_datatypes.py && \
75+ python3 create_panda_datatypes.py --compile && \
7576 PRETEND_VERSION=$(cat /tmp/savedversion) pip install -e . && \
7677 ldconfig && \
7778 update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
@@ -82,7 +83,7 @@ RUN cd /panda/panda/python/core && \
8283WORKDIR /panda/
8384
8485# ### Install PANDA + pypanda from builder - Stage 4
85- FROM builder as installer
86+ FROM builder AS installer
8687RUN make -C /panda/build install && \
8788 rm -r /usr/local/lib/panda/*/cosi \
8889 /usr/local/lib/panda/*/cosi_strace \
@@ -93,20 +94,16 @@ RUN make -C /panda/build install && \
9394# Install pypanda
9495RUN cd /panda/panda/python/core && \
9596 python3 create_panda_datatypes.py --install && \
97+ PRETEND_VERSION=$(cat /tmp/savedversion) python3 -m build --wheel . && \
9698 PRETEND_VERSION=$(cat /tmp/savedversion) pip install .
97- RUN python3 -m pip install --ignore-install pycparser && python3 -m pip install --force-reinstall --no-binary :all: cffi
98- # Build a whl too
99- RUN cd /panda/panda/python/core && \
100- python3 create_panda_datatypes.py --install && \
101- PRETEND_VERSION=$(cat /tmp/savedversion) python3 -m build --wheel .
10299
103100# BUG: PANDA sometimes fails to generate all the necessary files for PyPANDA. This is a temporary fix to detect and fail when this occurs
104101RUN ls -alt $(pip show pandare | grep Location: | awk '{print $2}' )/pandare/autogen/
105102RUN bash -c "ls $(pip show pandare | grep Location: | awk '{print $2}')/pandare/autogen/panda_{aarch64_64,arm_32,mips64_64,mips_32,mipsel_32,ppc_32,ppc_64,x86_64_64,i386_32}.py"
106103
107104# this layer is used to strip shared objects and change python data to be
108105# symlinks to the installed panda data directory
109- FROM installer as cleanup
106+ FROM installer AS cleanup
110107RUN find /usr/local/lib/panda -name "*.so" -exec strip {} \;
111108RUN PKG=`pip show pandare | grep Location: | awk '{print $2}' `/pandare/data; \
112109 rm -rf $PKG/pc-bios && ln -s /usr/local/share/panda $PKG/pc-bios; \
@@ -121,24 +118,23 @@ RUN PKG=`pip show pandare | grep Location: | awk '{print $2}'`/pandare/data; \
121118 done
122119
123120# ## Copy files for panda+pypanda from installer - Stage 5
124- FROM base as panda
121+ FROM base AS panda
125122
126123# Include dependency lists for packager
127124COPY --from=base /tmp/base_dep.txt /tmp
128125COPY --from=base /tmp/build_dep.txt /tmp
129126
130127# Copy panda + libcapstone.so* + libosi libraries
131128COPY --from=cleanup /usr/local /usr/local
132- COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/
133- COPY --from=cleanup /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/
129+ COPY --from=cleanup /usr/lib/libcapstone.so * /usr/lib/
130+ COPY --from=cleanup /usr/ lib/libosi.so /usr/ lib/libiohal.so /usr/ lib/liboffset.so /usr /lib/
134131
135132# Workaround issue #901 - ensure LD_LIBRARY_PATH contains the panda plugins directories
136133# ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu"
137134ENV LD_LIBRARY_PATH /usr/local/lib/python3.8/dist-packages/pandare/data/x86_64-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/i386-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/arm-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/ppc-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mips-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mipsel-softmmu/panda/plugins/
138135# PANDA_PATH is used by rust plugins
139136ENV PANDA_PATH /usr/local/lib/python3.8/dist-packages/pandare/data
140137
141-
142138# Ensure runtime dependencies are installed for our libpanda objects and panda plugins
143139RUN ldconfig && \
144140 update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
0 commit comments