Skip to content

Commit

Permalink
Use separate cache for apt
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-reckmann committed Aug 14, 2024
1 parent 4a924da commit f4457dd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
42 changes: 32 additions & 10 deletions Dockerfile.agnos
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ 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

# 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

# Install old Qt 5.12.8, libwayland 1.9.0-1 and deps
COPY ./userspace/qtwayland/*.deb /tmp/agnos/
RUN apt-get -o Dpkg::Options::="--force-overwrite" install -yq \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get -o Dpkg::Options::="--force-overwrite" install -yq \
/tmp/agnos/qt-5.12.8.deb \
/tmp/agnos/libwayland-1.9.0-1.deb \
/tmp/agnos/libicu66_66.1-2ubuntu2.1_arm64.deb \
Expand All @@ -37,7 +45,9 @@ RUN apt-get -o Dpkg::Options::="--force-overwrite" install -yq \
# ################## #
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

# Individual compiling images
FROM agnos-compiler AS agnos-compiler-capnp
Expand All @@ -62,23 +72,31 @@ 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

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" && \
Expand All @@ -102,10 +120,14 @@ 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

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
Expand Down
3 changes: 0 additions & 3 deletions userspace/base_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,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

Expand All @@ -126,7 +124,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 \
libasan6-armhf-cross \
Expand Down
3 changes: 0 additions & 3 deletions userspace/hardware_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,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

0 comments on commit f4457dd

Please sign in to comment.