-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1488de
commit 4e6650c
Showing
1 changed file
with
78 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,78 @@ | ||
ARG NAME=default | ||
ARG BASE_IMAGE="ubuntu:22.04" | ||
|
||
### BASE IMAGE | ||
FROM $BASE_IMAGE AS base | ||
ARG BASE_IMAGE | ||
ARG NAME | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV LLVM_DIR=/usr/lib/llvm-11 | ||
ENV PATH="/scripts:${PATH}" | ||
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python | ||
ENV USER=${NAME} | ||
|
||
# Copy dependencies lists into container. We copy them all and then do a mv because | ||
# we need to transform base_image into a windows compatible filename which we can't | ||
# do in a COPY command. | ||
COPY ./dependencies/* /tmp | ||
COPY ./requirements.txt /tmp | ||
COPY ./init-host.py / | ||
|
||
# Copy the rest of the files | ||
COPY ./target_bins /target_bins | ||
COPY ./target_configs /target_configs | ||
COPY ./scripts /scripts | ||
COPY ./tools/ /tools | ||
RUN mkdir -p /target_injections | ||
RUN bash download-qcow.sh | ||
|
||
RUN mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_build.txt /tmp/build_dep.txt && \ | ||
mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_base.txt /tmp/base_dep.txt | ||
|
||
# Base image just needs runtime dependencies | ||
RUN [ -e /tmp/base_dep.txt ] && \ | ||
apt-get -qq update && \ | ||
apt-get -qq install -y --no-install-recommends curl $(cat /tmp/base_dep.txt | grep -o '^[^#]*') && \ | ||
apt-get clean | ||
|
||
# Finally: Install panda debian package, you need a version that has the Dwarf2 Plugin | ||
RUN curl -LJO https://github.com/panda-re/panda/releases/download/v1.8.23/pandare_22.04.deb | ||
RUN mv ./pandare_22.04.deb /tmp | ||
RUN apt install -qq -y /tmp/pandare_22.04.deb | ||
RUN pip install -r /tmp/requirements.txt | ||
|
||
### BUILD IMAGE - STAGE 2 | ||
FROM base AS builder | ||
ARG BASE_IMAGE | ||
ARG NAME | ||
|
||
RUN [ -e /tmp/build_dep.txt ] && \ | ||
apt-get -qq update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*') && \ | ||
apt-get clean | ||
|
||
RUN python3 init-host.py | ||
|
||
#### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3 | ||
FROM builder AS developer | ||
ARG BASE_IMAGE | ||
ARG NAME | ||
|
||
# Essentially same as setup_container.sh | ||
RUN cd /tools/btrace && ./compile.sh | ||
|
||
RUN rm -rf /tools/build | ||
RUN mkdir -p /tools/build | ||
RUN mkdir -p /tools/install | ||
|
||
RUN cmake -B"/tools/build" -H"/tools" -DCMAKE_INSTALL_PREFIX="/tools/install" | ||
RUN make --no-print-directory -j4 install -C "/tools/build/lavaTool" | ||
RUN make --no-print-directory -j4 install -C "/tools/build/fbi" | ||
|
||
#RUN useradd ${NAME} | ||
#RUN chown -R ${NAME}:${NAME} /tools/ | ||
#RUN chown -R ${NAME}:${NAME} /scripts/ | ||
#RUN chown -R ${NAME}:${NAME} /target_bins/ | ||
#RUN chown -R ${NAME}:${NAME} /target_configs/ | ||
#RUN chown -R ${NAME}:${NAME} /target_injections/ | ||
#USER $NAME | ||
ARG NAME=default | ||
ARG BASE_IMAGE="ubuntu:22.04" | ||
|
||
### BASE IMAGE | ||
FROM $BASE_IMAGE AS base | ||
ARG BASE_IMAGE | ||
ARG NAME | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV LLVM_DIR=/usr/lib/llvm-11 | ||
ENV PATH="/scripts:${PATH}" | ||
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python | ||
ENV USER=${NAME} | ||
|
||
# Copy dependencies lists into container. We copy them all and then do a mv because | ||
# we need to transform base_image into a windows compatible filename which we can't | ||
# do in a COPY command. | ||
COPY ./dependencies/* /tmp | ||
COPY ./requirements.txt /tmp | ||
COPY ./init-host.py / | ||
|
||
# Copy the rest of the files | ||
COPY ./target_bins /target_bins | ||
COPY ./target_configs /target_configs | ||
COPY ./scripts /scripts | ||
COPY ./tools/ /tools | ||
RUN mkdir -p /target_injections | ||
|
||
RUN mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_build.txt /tmp/build_dep.txt && \ | ||
mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_base.txt /tmp/base_dep.txt | ||
|
||
# Base image just needs runtime dependencies | ||
RUN [ -e /tmp/base_dep.txt ] && \ | ||
apt-get -qq update && \ | ||
apt-get -qq install -y --no-install-recommends curl $(cat /tmp/base_dep.txt | grep -o '^[^#]*') && \ | ||
apt-get clean | ||
|
||
# Finally: Install panda debian package, you need a version that has the Dwarf2 Plugin | ||
RUN curl -LJO https://github.com/panda-re/panda/releases/download/v1.8.23/pandare_22.04.deb | ||
RUN mv ./pandare_22.04.deb /tmp | ||
RUN apt install -qq -y /tmp/pandare_22.04.deb | ||
RUN pip install -r /tmp/requirements.txt | ||
|
||
### BUILD IMAGE - STAGE 2 | ||
FROM base AS builder | ||
ARG BASE_IMAGE | ||
ARG NAME | ||
|
||
RUN [ -e /tmp/build_dep.txt ] && \ | ||
apt-get -qq update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*') && \ | ||
apt-get clean | ||
|
||
RUN python3 init-host.py | ||
|
||
#### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3 | ||
FROM builder AS developer | ||
ARG BASE_IMAGE | ||
ARG NAME | ||
|
||
# Essentially same as setup_container.sh | ||
RUN cd /tools/btrace && ./compile.sh | ||
|
||
RUN rm -rf /tools/build | ||
RUN mkdir -p /tools/build | ||
RUN mkdir -p /tools/install | ||
|
||
RUN cmake -B"/tools/build" -H"/tools" -DCMAKE_INSTALL_PREFIX="/tools/install" | ||
RUN make --no-print-directory -j4 install -C "/tools/build/lavaTool" | ||
RUN make --no-print-directory -j4 install -C "/tools/build/fbi" | ||
|
||
#RUN useradd ${NAME} | ||
#RUN chown -R ${NAME}:${NAME} /tools/ | ||
#RUN chown -R ${NAME}:${NAME} /scripts/ | ||
#RUN chown -R ${NAME}:${NAME} /target_bins/ | ||
#RUN chown -R ${NAME}:${NAME} /target_configs/ | ||
#RUN chown -R ${NAME}:${NAME} /target_injections/ | ||
#USER $NAME |