@@ -292,6 +292,7 @@ RUN --mount=type=secret,id=oban_license_key --mount=type=secret,id=oban_key_fing
292292
293293# Run deps.get with optional authentication to access private repos
294294RUN --mount=type=ssh --mount=type=secret,id=access_token \
295+ --mount=type=cache,id=hex-cache,target=/app/.hex,sharing=locked \
295296 # Access private repos using ssh identity
296297 # https://docs.docker.com/engine/reference/commandline/buildx_build/#ssh
297298 # https://stackoverflow.com/questions/73263731/dockerfile-run-mount-type-ssh-doesnt-seem-to-work
@@ -380,6 +381,94 @@ RUN if ! grep -q nonroot /etc/passwd; then \
380381 useradd -l -u 65532 -g nonroot -d /app -s /usr/sbin/nologin nonroot ; \
381382 rm -f /var/log/lastlog ; rm -f /var/log/faillog ; fi
382383
384+ RUN set -exu ; \
385+ rm -f /etc/apt/apt.conf.d/docker-clean ; \
386+ echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache ; \
387+ echo 'Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/99use-gzip-compression
388+
389+ ARG SNAPSHOT_VER
390+ ARG SNAPSHOT_NAME
391+ RUN --mount=type=cache,id=apt-cache,target=/var/cache/apt,sharing=locked \
392+ --mount=type=cache,id=apt-lib,target=/var/lib/apt,sharing=locked \
393+ --mount=type=cache,id=debconf,target=/var/cache/debconf,sharing=locked \
394+ if test -n "$SNAPSHOT_VER" ; then \
395+ set -exu ; \
396+ apt-get update -qq ; \
397+ DEBIAN_FRONTEND=noninteractive \
398+ apt-get -y install -y -qq --no-install-recommends \
399+ ca-certificates \
400+ ; \
401+ echo "deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/${SNAPSHOT_VER} ${SNAPSHOT_NAME} main" > /etc/apt/sources.list ; \
402+ echo "deb [check-valid-until=no] https://snapshot.debian.org/archive/debian-security/${SNAPSHOT_VER} ${SNAPSHOT_NAME}-security main" >> /etc/apt/sources.list ; \
403+ echo "deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/${SNAPSHOT_VER} ${SNAPSHOT_NAME}-updates main" >> /etc/apt/sources.list ; \
404+ fi ; \
405+ truncate -s 0 /var/log/apt/* ; \
406+ truncate -s 0 /var/log/dpkg.log
407+
408+ ARG RUNTIME_PACKAGES
409+
410+ RUN --mount=type=cache,id=apt-cache,target=/var/cache/apt,sharing=locked \
411+ --mount=type=cache,id=apt-lib,target=/var/lib/apt,sharing=locked \
412+ --mount=type=cache,id=debconf,target=/var/cache/debconf,sharing=locked \
413+ set -exu ; \
414+ apt-get update -qq ; \
415+ DEBIAN_FRONTEND=noninteractive \
416+ # Tools needed to run tests
417+ apt-get -y install -y -qq --no-install-recommends \
418+ git \
419+ ; \
420+ # Runtime dependencies for the app
421+ apt-get -y install -y -qq --no-install-recommends \
422+ # Enable installation of packages over https
423+ # apt-transport-https \
424+ # Libraries used by hexpm
425+ # Enable the app to make outbound SSL calls.
426+ ca-certificates \
427+ # libodbc1 \
428+ # libsctp1 \
429+ netbase \
430+ # wget and jq are used to get ECS metadata
431+ # We prefer wget over curl, as it is part of busybox
432+ # curl is used to upload packages to GitHub, and is generally useful
433+ # curl \
434+ # jq \
435+ # wget \
436+ # tini is a minimal init which will reap zombie processes
437+ # https://github.com/krallin/tini
438+ # tini \
439+ # bind-utils \
440+ # Minimal libs needed by Erlang VM
441+ # libncursesw6 \
442+ libtinfo6 \
443+ # Additional libs
444+ libssl3 \
445+ libstdc++6 \
446+ libgcc-s1 \
447+ $RUNTIME_PACKAGES \
448+ ; \
449+ # Remove packages installed temporarily. Removes everything related to
450+ # packages, including the configuration files, and packages
451+ # automatically installed because a package required them but, with the
452+ # other packages removed, are no longer needed.
453+ # apt-get purge -y --auto-remove curl ; \
454+ # https://www.networkworld.com/article/3453032/cleaning-up-with-apt-get.html
455+ # https://manpages.ubuntu.com/manpages/jammy/man8/apt-get.8.html
456+ # Delete local repository of retrieved package files in /var/cache/apt/archives
457+ # This is handled automatically by /etc/apt/apt.conf.d/docker-clean
458+ # Use this if not running --mount=type=cache.
459+ # apt-get clean ; \
460+ # Delete info on installed packages. This saves some space, but it can
461+ # be useful to have them as a record of what was installed, e.g., for auditing.
462+ # rm -rf /var/lib/dpkg ; \
463+ # Delete debconf data files to save some space
464+ # rm -rf /var/cache/debconf ; \
465+ # Delete index of available files from apt-get update
466+ # Use this if not running --mount=type=cache.
467+ # rm -rf /var/lib/apt/lists/*
468+ # Clear logs of installed packages
469+ truncate -s 0 /var/log/apt/* ; \
470+ truncate -s 0 /var/log/dpkg.log
471+
383472COPY --link --from=build-os-deps /usr/lib/locale/locale-archive /usr/lib/locale/
384473
385474ARG LANG
0 commit comments