Skip to content

Commit

Permalink
[WIP][Docker] I need target_config and target_bins in LAVA Docker con…
Browse files Browse the repository at this point in the history
…tainer and allow DockerFile to now take a USER argument so the container and host are in sync about database pre-fix
  • Loading branch information
AndrewQuijano committed Aug 29, 2024
1 parent f22dd70 commit 58a0e7d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
6 changes: 2 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
target_injections
target_bins
target_configs
target_injections
tests
docs
panda
docker
docs
33 changes: 20 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG BASE_IMAGE="ubuntu:22.04"

### BASE IMAGE
FROM $BASE_IMAGE as base
FROM $BASE_IMAGE AS base
ARG BASE_IMAGE

ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -14,6 +14,8 @@ ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
# do in a COPY command.
COPY ./dependencies/* /tmp
COPY ./requirements.txt /tmp
COPY ./tools/ /tools
COPY ./scripts/ /scripts

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
Expand All @@ -26,25 +28,23 @@ RUN [ -e /tmp/base_dep.txt ] && \

# 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 apt install -qq -y ./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

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 install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*') && \
apt-get clean

#### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
FROM builder as developer

COPY ./tools/ /tools
COPY ./scripts /scripts
RUN cd /tmp && \
git clone https://github.com/capstone-engine/capstone/ -b v4 && \
cd capstone/ && ./make.sh && make install && cd /tmp && \
rm -rf /tmp/capstone && ldconfig

# Essentially same as setup_container.sh
#### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
#### Essentially same as setup_container.sh
RUN cd /tools/btrace && ./compile.sh

RUN rm -rf /tools/build
Expand All @@ -53,5 +53,12 @@ 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"

# We need 32-bit support inside the container for now
RUN dpkg --add-architecture i386 && apt-get update && apt-get -y install zlib1g-dev:i386 gcc-multilib

# RUN useradd volcana
# RUN chown -R volcana:volcana /tools/
# RUN chown -R volcana:volcana /scripts/
# USER volcana
1 change: 1 addition & 0 deletions scripts/funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ if [ -z "$LAVA_FUNCS_INCLUDED" ]; then
-v /etc/shadow:/etc/shadow:ro \
-v /etc/gshadow:/etc/gshadow:ro \
-v /home:/home:ro \
-v $HOME/.panda:$HOME/.panda \
--add-host=database:$DOCKER_IP \
$docker_map_args \
$extradockerargs \
Expand Down

0 comments on commit 58a0e7d

Please sign in to comment.