diff --git a/Dockerfile.agnos b/Dockerfile.agnos index b9d758ed..14d22ad5 100644 --- a/Dockerfile.agnos +++ b/Dockerfile.agnos @@ -14,21 +14,29 @@ RUN set -xe ARG USERNAME=comma +RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache + # Base system setup RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections COPY ./userspace/base_setup.sh /tmp/agnos -RUN /tmp/agnos/base_setup.sh +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /tmp/agnos/base_setup.sh # ################## # # #### Compiler #### # # ################## # FROM agnos-base AS agnos-compiler -RUN apt-fast update && apt-fast install --no-install-recommends -yq checkinstall +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-fast update && apt-fast install --no-install-recommends -yq checkinstall # Install openpilot dependencies, probably needed for build, # but we don't want these in the base image COPY ./userspace/openpilot_dependencies.sh /tmp/agnos/ -RUN /tmp/agnos/openpilot_dependencies.sh +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /tmp/agnos/openpilot_dependencies.sh # Individual compiling images FROM agnos-compiler AS agnos-compiler-capnp @@ -53,26 +61,36 @@ FROM agnos-base RUN mkdir -p /tmp/agnos/debs COPY ./userspace/debs /tmp/agnos/debs COPY ./userspace/hardware_setup.sh /tmp/agnos -RUN /tmp/agnos/hardware_setup.sh +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /tmp/agnos/hardware_setup.sh RUN mv /data/persist /system/ && rm -rf /data/* # Build ModemManager COPY ./userspace/compile-modemmanager.sh /tmp/agnos/ -RUN /tmp/agnos/compile-modemmanager.sh +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /tmp/agnos/compile-modemmanager.sh # Pre-compiled capnp (must be before python install) COPY --from=agnos-compiler-capnp /tmp/capnproto.deb /tmp/capnproto.deb -RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./capnproto.deb +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./capnproto.deb # Install openpilot dependencies COPY ./userspace/openpilot_dependencies.sh /tmp/agnos/ -RUN /tmp/agnos/openpilot_dependencies.sh +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /tmp/agnos/openpilot_dependencies.sh COPY ./userspace/openpilot_python_dependencies.sh /tmp/agnos/ RUN /tmp/agnos/openpilot_python_dependencies.sh # Use other pre-compiled packages COPY --from=agnos-compiler-ffmpeg /tmp/ffmpeg.deb /tmp/ffmpeg.deb -RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./ffmpeg.deb +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./ffmpeg.deb RUN export PATH="/usr/local/pyenv/bin:/usr/local/pyenv/shims:$PATH" && \ export PYENV_ROOT="/usr/local/pyenv" && \ @@ -96,14 +114,18 @@ RUN export PATH="/usr/local/pyenv/bin:/usr/local/pyenv/shims:$PATH" && \ # Install nice to haves COPY ./userspace/install_extras.sh /tmp/agnos/ -RUN /tmp/agnos/install_extras.sh +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /tmp/agnos/install_extras.sh # 16.04 libwayland-client + libffi6 COPY ./userspace/qtwayland/libffi.so.6 /lib/aarch64-linux-gnu/ COPY ./userspace/qtwayland/libwayland-client.so.0 /lib/aarch64-linux-gnu/libwayland-client.so.0 COPY --from=agnos-compiler-qtwayland5 /tmp/qtwayland5.deb /tmp/qtwayland5.deb -RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq --allow-downgrades ./qtwayland5.deb +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq --allow-downgrades ./qtwayland5.deb # Patched libeglSubDriverWayland with fixed nullptr deref in CommitBuffer COPY ./userspace/files/libeglSubDriverWayland.so.patched /lib/aarch64-linux-gnu/libeglSubDriverWayland.so diff --git a/userspace/base_setup.sh b/userspace/base_setup.sh index 2b909ea4..23bc1499 100755 --- a/userspace/base_setup.sh +++ b/userspace/base_setup.sh @@ -106,8 +106,6 @@ apt-fast install --no-install-recommends -yq \ wireless-tools \ zlib1g-dev -rm -rf /var/lib/apt/lists/* - # Allow chrony to make a big adjustment to system time on boot echo "makestep 0.1 3" >> /etc/chrony/chrony.conf @@ -128,7 +126,6 @@ echo "comma ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ln -sf /bin/bash /bin/sh # Install necessary libs -apt-fast update -yq apt-fast install --no-install-recommends -yq \ libacl1:armhf \ libasan5-armhf-cross \ diff --git a/userspace/hardware_setup.sh b/userspace/hardware_setup.sh index 191665cd..cb23078f 100755 --- a/userspace/hardware_setup.sh +++ b/userspace/hardware_setup.sh @@ -12,8 +12,5 @@ cd /tmp wget http://ports.ubuntu.com/pool/main/j/json-c/libjson-c2_0.11-4ubuntu2.6_arm64.deb -O /tmp/libjson-c2_0.11-4ubuntu2.6_arm64.deb apt install -yq /tmp/libjson-c2_0.11-4ubuntu2.6_arm64.deb -# Remove apt cache -rm -rf /var/lib/apt/lists/* - USERNAME=comma adduser $USERNAME netdev