Files
trailofbits-buttercup/patcher/Dockerfile
T
Evan Downing b1a558da0f Update location and name of cscope (#246)
* Update location and name of cscope

* Update README and add quick test script

* Add architecture check and disable full test for now

* Remove test script. Enable libpng integration test

---------

Co-authored-by: Michael D Brown <michael.brown@trailofbits.com>
2025-08-14 21:44:22 -04:00

69 lines
2.3 KiB
Docker

ARG BASE_IMAGE=ubuntu:24.04
FROM $BASE_IMAGE AS python_base
ARG PYTHON_VERSION=3.12
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python$PYTHON_VERSION python$PYTHON_VERSION-dev
FROM python_base AS runtime-base
RUN DEBIAN_FRONTEND=noninteractive apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \
patch \
codequery \
rsync \
libncurses-dev \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://get.docker.com | sh
FROM python_base AS builder
COPY --from=ghcr.io/astral-sh/uv:0.5.20 /uv /uvx /bin/
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=never \
UV_PYTHON=python3.12
WORKDIR /app
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=common/uv.lock,target=common/uv.lock \
--mount=type=bind,source=common/pyproject.toml,target=common/pyproject.toml \
--mount=type=bind,source=program-model/uv.lock,target=program-model/uv.lock \
--mount=type=bind,source=program-model/pyproject.toml,target=program-model/pyproject.toml \
--mount=type=bind,source=program-model/README.md,target=program-model/README.md \
--mount=type=bind,source=patcher/uv.lock,target=patcher/uv.lock \
--mount=type=bind,source=patcher/pyproject.toml,target=patcher/pyproject.toml \
cd patcher && uv sync --frozen --no-install-project --no-editable
ADD common /app/common
ADD program-model /app/program-model
ADD patcher /app/patcher
RUN --mount=type=cache,target=/root/.cache/uv \
cd patcher && uv sync --frozen --no-editable
FROM runtime-base AS cscope-builder
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y autoconf gcc make bison flex libncurses-dev
COPY external/buttercup-cscope /cscope
RUN cd /cscope && autoreconf -i -s && ./configure && make && make install
FROM runtime-base AS runtime
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -y codequery rsync git && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder --chown=app:app /app/patcher/.venv /app/patcher/.venv
COPY --from=cscope-builder /usr/local/bin/cscope /usr/local/bin/cscope
COPY common/container-entrypoint.sh /container-entrypoint.sh
WORKDIR /app/patcher
ENV PATH=/app/patcher/.venv/bin:$PATH
ENTRYPOINT ["/container-entrypoint.sh"]