From 6854210f267c9a815647f8597f11074d8f1ed4f3 Mon Sep 17 00:00:00 2001 From: Albert Zhang Date: Thu, 21 Nov 2024 20:40:50 +0000 Subject: [PATCH 1/2] Add configuration option for base python image for Docker files --- build_image.py | 7 ++++++- ofrak_core/Dockerstub | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build_image.py b/build_image.py index be7bed10d..f7dae5db5 100644 --- a/build_image.py +++ b/build_image.py @@ -9,6 +9,9 @@ import pkg_resources import yaml +DEFAULT_PYTHON_IMAGE = ( + "python:3.8-bullseye@sha256:e1cd369204123e89646f8c001db830eddfe3e381bd5c837df00141be3bd754cb" +) BASE_DOCKERFILE = "base.Dockerfile" FINISH_DOCKERFILE = "finish.Dockerfile" @@ -33,6 +36,7 @@ class OfrakImageConfig: install_target: InstallTarget cache_from: List[str] entrypoint: Optional[str] + python_image: str def validate_serial_txt_existence(self): """ @@ -171,6 +175,7 @@ def parse_args() -> OfrakImageConfig: InstallTarget(args.target), args.cache_from, config_dict.get("entrypoint"), + config_dict.get("python_image", DEFAULT_PYTHON_IMAGE), ) image_config.validate_serial_txt_existence() return image_config @@ -207,7 +212,7 @@ def create_dockerfile_base(config: OfrakImageConfig) -> str: dockerfile_base_parts += [f"### {dockerstage_path}", dockerstub] dockerfile_base_parts += [ - "FROM python:3.8-bullseye@sha256:e1cd369204123e89646f8c001db830eddfe3e381bd5c837df00141be3bd754cb", + f"FROM {config.python_image}", "", ] diff --git a/ofrak_core/Dockerstub b/ofrak_core/Dockerstub index b81261935..08b7d479c 100644 --- a/ofrak_core/Dockerstub +++ b/ofrak_core/Dockerstub @@ -61,8 +61,11 @@ RUN cd /tmp && \ # Install Jefferson WORKDIR /tmp -RUN wget https://bootstrap.pypa.io/pip/get-pip.py && python3.9 get-pip.py && python3.8 get-pip.py && rm get-pip.py -RUN python3.9 -m pip install jefferson +RUN wget https://bootstrap.pypa.io/pip/get-pip.py && \ + /usr/bin/python3 get-pip.py && \ + /usr/local/bin/python get-pip.py && \ + rm get-pip.py +RUN /usr/bin/python3 -m pip install jefferson WORKDIR / # Install UEFIExtract (build from source, pinned to releae A68) From 8e6dc64727c5766fb8a69b46f3b964166829dc12 Mon Sep 17 00:00:00 2001 From: Albert Zhang Date: Fri, 22 Nov 2024 00:49:48 +0000 Subject: [PATCH 2/2] Remove manual Jefferson install to Debian's Python in Docker --- ofrak_core/Dockerstub | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ofrak_core/Dockerstub b/ofrak_core/Dockerstub index 08b7d479c..50188bd3f 100644 --- a/ofrak_core/Dockerstub +++ b/ofrak_core/Dockerstub @@ -59,15 +59,6 @@ RUN cd /tmp && \ cd /tmp && \ rm -r squashfs-tools -# Install Jefferson -WORKDIR /tmp -RUN wget https://bootstrap.pypa.io/pip/get-pip.py && \ - /usr/bin/python3 get-pip.py && \ - /usr/local/bin/python get-pip.py && \ - rm get-pip.py -RUN /usr/bin/python3 -m pip install jefferson -WORKDIR / - # Install UEFIExtract (build from source, pinned to releae A68) RUN cd /tmp && \ wget https://github.com/LongSoft/UEFITool/archive/refs/tags/A68.zip && \