From 1e002140411689ee4871d79c10486abd889c7fca Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Sun, 28 Apr 2024 00:04:48 +0200 Subject: [PATCH] Use Cargo Sparse protocol in Docker build Cargo 1.68 and newer introduced "sparse" protocol which significantly reduces memory usage (and improves build time!) - see https://blog.rust-lang.org/inside-rust/2023/01/30/cargo-sparse-protocol.html Had to bump Alpine to 3.18 to pick up a more recent Cargo release (1.76.0) hexpm/elixir do not sure Alpine 3.19 with current erlang+elixir combination --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 34bdd60c2..6296f6c40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG ALPINE_VERSION=3.17.0 +ARG ALPINE_VERSION=3.18.0 ARG ERLANG_OTP_VERSION=25.2.2 ARG ELIXIR_VERSION=1.14.3 @@ -9,6 +9,9 @@ FROM docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_OTP_VERSION}-alpin ARG MIX_ENV=prod ENV ERL_FLAGS="+JPperf true" +# Avoid "error 137" (out of memory) while building images +# See https://github.com/rust-lang/cargo/issues/10781 +ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse" WORKDIR /opt/app