Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base images are HUGE. #19

Closed
thedodd opened this issue Feb 23, 2018 · 2 comments
Closed

Base images are HUGE. #19

thedodd opened this issue Feb 23, 2018 · 2 comments

Comments

@thedodd
Copy link

thedodd commented Feb 23, 2018

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?

@sfackler
Copy link
Member

sfackler commented Feb 23, 2018

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.

@sfackler
Copy link
Member

sfackler commented Feb 24, 2018

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/*;

sfackler added a commit that referenced this issue Apr 9, 2018
I'm only including stretch - I think we'll hopefully be removing the
jessie images entirely in 1.26 but there's no reason to create them for
these new images in the first place.

Closes #19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants