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

Create smaller devcontainer #89

Closed
3 tasks
inf17101 opened this issue Nov 15, 2023 · 8 comments
Closed
3 tasks

Create smaller devcontainer #89

inf17101 opened this issue Nov 15, 2023 · 8 comments
Labels
CI/CD enhancement New feature or request. Issue will appear in the change log "Features"
Milestone

Comments

@inf17101
Copy link
Contributor

Description

The devcontainer has been grown a lot:
image

This devcontainer is pulled in CI/CD pipeline and also local builds are running very long.

The most dependencies are installed in the Dockerfile.base (the devcontainer base image https://github.com/eclipse-ankaios/ankaios/blob/main/.devcontainer/Dockerfile.base). This is getting to big.

Goals

Having a slim devcontainer image.

Final result

Summary

To be filled when the final solution is sketched.

Tasks

  • Task 1
  • Task 2
  • ...
@inf17101 inf17101 added the enhancement New feature or request. Issue will appear in the change log "Features" label Nov 15, 2023
@inf17101
Copy link
Contributor Author

inf17101 commented Nov 15, 2023

I have already started to try to fetch the dependencies to an Alpine image (just to see if it has a big effect when using one of the smallest available images). In general, it works to install the most stuff in alpine (But, I am not 100% finished). It does not mean that the final image must built on top of alpine base image.

The microsoft devcontainer base image just with Rust installed takes 2.97GB (that is too much for a base image).

@inf17101
Copy link
Contributor Author

The debian 11-slim is also a very slim base image (and is not alpine). It has only 80MB.

docker pull docker.io/debian:11-slim

image

@windsource
Copy link
Contributor

windsource commented Nov 16, 2023

I think first we need to analyze the disk usage of the dev container to find out the biggest chunks. ncdu is very suited for that.

ncdu -x /

There we can see for ghcr.io/eclipse-ankaios/devcontainer-base:0.6.4:

--- / -------------------------------------------------------------------------------------------------------------------------------------------------------
    4.0 GiB [######################] /usr
  634.0 MiB [###                   ] /home
   44.6 MiB [                      ] /root

and

--- /usr ----------------------------------------------------------------------------------------------------------------------------------------------------
                                     /..
    1.7 GiB [######################] /lib
    1.5 GiB [###################   ] /local
  444.3 MiB [#####                 ] /share
  228.2 MiB [##                    ] /bin

and

--- /usr/lib ------------------------------------------------------------------------------------------------------------------------------------------------
                                     /..
  711.2 MiB [######################] /x86_64-linux-gnu
  360.3 MiB [###########           ] /llvm-14
  183.4 MiB [#####                 ] /jvm
  169.0 MiB [#####                 ] /python3.11
  119.3 MiB [###                   ] /gcc
   67.6 MiB [##                    ] /gcc-cross

and

--- /usr/local ----------------------------------------------------------------------------------------------------------------------------------------------
                                     /..
  954.3 MiB [######################] /rustup
  275.1 MiB [######                ] /cargo
  148.5 MiB [###                   ] /lib
  108.5 MiB [##                    ] /libexec

We can try to install all the things we need based on debian:slim but I fear that we need nearly as much when installing all tools and toolchains we need. But let's try.

@krucod3 krucod3 added the CI/CD label Nov 28, 2023
@krucod3 krucod3 added this to the backlog milestone Nov 29, 2023
@krucod3
Copy link
Contributor

krucod3 commented Jan 8, 2024

The base and the dev containers can also be build within the CI/CD pipeline. Take a look here for some inspiration: #116

@inf17101
Copy link
Contributor Author

inf17101 commented May 16, 2024

The cargo install overhead can be reduced when using https://crates.io/crates/cargo-binstall/1.4.3. But it searches the crate repositories for release artifacts and downloads it. If they do not exist, then a fallback to the slow cargo install is done. And maintainers must include configuration to support the search of the bininstall tool. I think it is an alternative to avoid the compilation overhead, but the two points I have mentioned are disadvantages...

@inf17101
Copy link
Contributor Author

inf17101 commented Jul 8, 2024

I have tested quickly with a different and smaller base image ubuntu:24.04 (only 80 Mb size) for the Ankaios base devcontainer and with installing the Rust (x86 and aarch64 linux musl) targets directly by adding the targets as arguments when calling the Rust install script (then no extra layer with 'rustup add' is needed afterwards). But it saves only ~900Mb total size. If this ticket is taken, I think we will need a different devcontainer setup to save more size and to be more efficient in the CI/CD pipeline.

@windsource
Copy link
Contributor

I addition to the size, our devcontainer also lacks flexibility to install different Rust versions. Currently we use mcr.microsoft.com/devcontainers/rustas base image but it does not support patch version updates e.g. for Rust 18.80.1.

windsource added a commit that referenced this issue Aug 20, 2024
windsource added a commit that referenced this issue Aug 21, 2024
windsource added a commit that referenced this issue Aug 21, 2024
windsource added a commit that referenced this issue Aug 22, 2024
inf17101 pushed a commit that referenced this issue Aug 22, 2024
* Update devcontainer to Rust 1.80.1

Issue-Id: #89

* Move dev container from debian to ubuntu

* Use own shell config

Issue-Id: #89

* Use new container in GHA

Issue-Id: #89

* Improve shell prompt config

Issue-Id: #89

* Add default linker for x86_64

* Use new dev container in CI
@windsource
Copy link
Contributor

Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD enhancement New feature or request. Issue will appear in the change log "Features"
Projects
None yet
Development

No branches or pull requests

3 participants