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 13, 2024
1 parent cd181f2 commit df53dee
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,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
Expand All @@ -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" && \
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions userspace/base_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 \
Expand Down
3 changes: 0 additions & 3 deletions userspace/hardware_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit df53dee

Please sign in to comment.