Closed thedodd closed 6 years ago
An Alpine-based image is blocked on an official MUSL toolchain, which is tracked in #10.
The base image we use is buildpack-deps, which includes a bunch of common build tools and C libraries. This mirrors what other similar images to, like gcc and python.
It looks like the python image also publishes a slim variant based off of debian:stretch-slim
which seems reasonable to do here as well. Ours will be more heavyweight since we have to include gcc but it'll still avoid all of the libraries that buildpack-deps pulls in.
This should be a pretty minimal setup:
FROM debian:stretch-slim
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
libc6-dev \
wget \
; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='c9837990bce0faab4f6f52604311a19bb8d2cde989bea6a7b605c8e526db6f02' ;; \
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='297661e121048db3906f8c964999f765b4f6848632c0c2cfb6a1e93d99440732' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='a68ac2d400409f485cb22756f0b3217b95449884e1ea6fd9b70522b3c0a929b2' ;; \
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='27e6109c7b537b92a6c2d45ac941d959606ca26ec501d86085d651892a55d849' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
\
url="https://static.rust-lang.org/rustup/archive/1.11.0/${rustArch}/rustup-init"; \
wget "$url"; \
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --default-toolchain 1.24.0; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version; \
\
apt-get remove -y --auto-remove \
wget \
; \
rm -rf /var/lib/apt/lists/*;
It would be awesome to get an alpine (not sure if we are still blocked on musl) version of an image built, as that could drastically reduce base image size (currently around 477MiB compressed). The build pack base image is around 250MiB compressed, whereas alpine base image is about 2MiB compressed. Currently, the build here is nearly doubling the size of the image.
If that is not possible right now, it would be beneficial to strip out as much bloat from the base image as possible. I've only looked over the dockerfiles briefly, and I would have to investigate further to really see what could be stripped out, to find where the bloat may be coming from.
Thoughts?