diff --git a/Fedora-40/Dockerfile b/Fedora-40/Dockerfile index f635a4e..2584c3d 100644 --- a/Fedora-40/Dockerfile +++ b/Fedora-40/Dockerfile @@ -19,7 +19,8 @@ FROM registry.fedoraproject.org/fedora:40 AS build # Preinstall python + dependencies as virtual environment -RUN dnf \ +RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked \ + dnf \ --assumeyes \ --nodocs \ --setopt=install_weak_deps=0 \ @@ -29,7 +30,8 @@ RUN dnf \ RUN virtualenv /opt/venv ENV VIRTUAL_ENV /opt/venv ENV PATH /opt/venv/bin:$PATH -RUN pip install --upgrade pip \ +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --upgrade pip \ -r "https://raw.githubusercontent.com/tianocore/edk2/master/pip-requirements.txt" @@ -37,7 +39,8 @@ ARG CSPELL_VERSION=8.0.0 ARG MARKDOWNLINT_VERSION=0.37.0 ARG POWERSHELL_VERSION=7.4.1 ARG DOTNET_VERSION=8.0 -RUN dnf \ +RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked \ + dnf \ --assumeyes \ --nodocs \ --setopt=install_weak_deps=0 \ @@ -71,7 +74,8 @@ RUN dnf \ tar \ sudo RUN alternatives --install /usr/bin/python python /usr/bin/python3 1 -RUN pip install --upgrade pip lcov_cobertura setuptools +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --upgrade pip lcov_cobertura setuptools # Set toolchains prefix ENV GCC_AARCH64_PREFIX /usr/bin/aarch64-linux-gnu- @@ -85,7 +89,8 @@ ENV GCC5_RISCV64_PREFIX /usr/bin/riscv64-linux-gnu- ENV GCC5_LOONGARCH64_PREFIX /usr/bin/loongarch64-linux-gnu- # Tools used by build extensions. -RUN npm install -g npm \ +RUN --mount=type=cache,target=/root/.npm \ + npm install -g npm \ cspell@${CSPELL_VERSION} \ markdownlint-cli@${MARKDOWNLINT_VERSION} @@ -95,7 +100,8 @@ RUN npm install -g npm \ # architectures under test. FROM build AS test -RUN dnf \ +RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked \ + dnf \ --assumeyes \ --nodocs \ --setopt=install_weak_deps=0 \ @@ -112,7 +118,8 @@ RUN dnf \ # tools for local developers. FROM test AS dev ENV GCM_LINK=https://github.com/GitCredentialManager/git-credential-manager/releases/download/v2.0.785/gcm-linux_amd64.2.0.785.tar.gz -RUN dnf \ +RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked \ + dnf \ --assumeyes \ --nodocs \ --setopt=install_weak_deps=0 \ diff --git a/Ubuntu-22/Dockerfile b/Ubuntu-22/Dockerfile index 4ab9732..6d870db 100644 --- a/Ubuntu-22/Dockerfile +++ b/Ubuntu-22/Dockerfile @@ -27,19 +27,24 @@ ENV TZ=UTC ENV GCC_MAJOR_VERSION=12 # Preinstall python + dependencies as virtual environment -RUN apt-get update && \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ apt-get install --yes --no-install-recommends \ python3 \ virtualenv RUN virtualenv /opt/venv ENV VIRTUAL_ENV /opt/venv ENV PATH /opt/venv/bin:$PATH -RUN pip install --upgrade pip \ +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --upgrade pip \ -r "https://raw.githubusercontent.com/tianocore/edk2/master/pip-requirements.txt" # Install and update the package list -RUN apt-get update && \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ apt-get install --yes --no-install-recommends \ software-properties-common \ apt-utils \ @@ -66,9 +71,7 @@ RUN apt-get update && \ g++-${GCC_MAJOR_VERSION}-riscv64-linux-gnu gcc-${GCC_MAJOR_VERSION}-riscv64-linux-gnu \ g++-${GCC_MAJOR_VERSION}-arm-linux-gnueabi gcc-${GCC_MAJOR_VERSION}-arm-linux-gnueabi \ g++-${GCC_MAJOR_VERSION}-arm-linux-gnueabihf gcc-${GCC_MAJOR_VERSION}-arm-linux-gnueabihf && \ - apt-get upgrade -y && \ - apt-get clean &&\ - rm -rf /var/lib/apt/lists/* + apt-get upgrade -y RUN \ update-alternatives \ @@ -147,7 +150,9 @@ COPY init_edkrepo_conf.sh /usr/bin/init_edkrepo_conf #Building qemu from source: FROM build AS test ARG QEMU_URL="https://download.qemu.org/qemu-7.1.0.tar.xz" -RUN apt-get update && apt-get install --yes --no-install-recommends \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && apt-get install --yes --no-install-recommends \ autoconf \ automake \ autotools-dev \ @@ -166,7 +171,7 @@ RUN apt-get update && apt-get install --yes --no-install-recommends \ make install -j $(nproc) && \ cd .. && \ rm -rf qemu-build && \ - apt remove --yes \ + apt remove --yes --purge \ ninja-build ##################################################################### @@ -176,7 +181,9 @@ FROM test AS dev # Install convenience tools. Things we like having around, but aren't # required. -RUN apt-get update && \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ apt-get install --yes --no-install-recommends \ bear \ clang \ @@ -184,9 +191,7 @@ RUN apt-get update && \ lld \ llvm \ nano \ - vim \ - && \ - apt-get clean + vim # Setup the entry point COPY ubuntu22_dev_entrypoint.sh /usr/libexec/entrypoint diff --git a/Ubuntu-24/Dockerfile b/Ubuntu-24/Dockerfile index 9fe94b6..44469f8 100644 --- a/Ubuntu-24/Dockerfile +++ b/Ubuntu-24/Dockerfile @@ -30,19 +30,24 @@ ENV TZ=UTC ENV GCC_MAJOR_VERSION=13 # Preinstall python + dependencies as virtual environment -RUN apt-get update && \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ apt-get install --yes --no-install-recommends \ python3 python3-venv\ virtualenv RUN virtualenv /opt/venv ENV VIRTUAL_ENV /opt/venv ENV PATH /opt/venv/bin:$PATH -RUN pip install --upgrade pip \ +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --upgrade pip \ -r "https://raw.githubusercontent.com/tianocore/edk2/master/pip-requirements.txt" # Install and update the package list -RUN apt-get update && \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ apt-get install --yes --no-install-recommends \ software-properties-common \ apt-utils \ @@ -69,9 +74,7 @@ RUN apt-get update && \ g++-${GCC_MAJOR_VERSION}-riscv64-linux-gnu gcc-${GCC_MAJOR_VERSION}-riscv64-linux-gnu \ g++-${GCC_MAJOR_VERSION}-arm-linux-gnueabi gcc-${GCC_MAJOR_VERSION}-arm-linux-gnueabi \ g++-${GCC_MAJOR_VERSION}-arm-linux-gnueabihf gcc-${GCC_MAJOR_VERSION}-arm-linux-gnueabihf && \ - apt-get upgrade -y && \ - apt-get clean &&\ - rm -rf /var/lib/apt/lists/* + apt-get upgrade -y RUN \ update-alternatives \ @@ -151,7 +154,9 @@ COPY init_edkrepo_conf.sh /usr/bin/init_edkrepo_conf #Building qemu from source: FROM build AS test ARG QEMU_URL="https://download.qemu.org/qemu-9.1.1.tar.xz" -RUN apt-get update && apt-get install --yes --no-install-recommends \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && apt-get install --yes --no-install-recommends \ autoconf \ automake \ autotools-dev \ @@ -170,7 +175,7 @@ RUN apt-get update && apt-get install --yes --no-install-recommends \ make install -j $(nproc) && \ cd .. && \ rm -rf qemu-build && \ - apt remove --yes \ + apt remove --yes --purge \ ninja-build ##################################################################### @@ -180,7 +185,9 @@ FROM test AS dev # Install convenience tools. Things we like having around, but aren't # required. -RUN apt-get update && \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ apt-get install --yes --no-install-recommends \ bear \ clang \ @@ -189,9 +196,7 @@ RUN apt-get update && \ llvm \ nano \ vim \ - cmake \ - && \ - apt-get clean + cmake # Setup the entry point COPY ubuntu24_dev_entrypoint.sh /usr/libexec/entrypoint