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

Slim variant of nektos/act-environments-ubuntu:18.04 #196

Closed
aidansteele opened this issue Apr 17, 2020 · 9 comments
Closed

Slim variant of nektos/act-environments-ubuntu:18.04 #196

aidansteele opened this issue Apr 17, 2020 · 9 comments
Labels
area/runner Relating to errors in the runner needs-work Extra attention is needed stale

Comments

@aidansteele
Copy link
Contributor

My feeling reading some of the issues in this repo is that a lot of folks get stuck on the fact that we default to not using the enormous image - which is a reasonable IMHO. I've been thinking about whether there's a compromise we can reach, where we get e.g. 90% of the benefit at 30% of the size.

There would be pros and cons to this approach. Pros would likely be fewer issues on this repo, an easier getting-started process for most people, etc. Cons would be that the environment would be so close to the Github-provided one, but crucially not identical - which would cause a lot of head-scratching. Disregarding this for now, I started to take a cursory look at how we might want to shrink the image size.

All these numbers are on the uncompressed (~18GB total) image size:

  • At least 4GB is used by the Boost C++ library. This is spread across two versions of the library. At the very least, we could consider deleting the older one. Maybe both?
  • 1.5GB is used by the NPM cache. Amusingly, quite a bit (most) of this is gzipped tars of the above Boost libraries. This seems like an ideal candidate for purging, given it would also remove 1.5GB from the image download size
  • ~1.5GB of Python distributions spread between /opt/hostedtoolcache and Miniconda in addition to the Python that comes with Ubuntu
  • 1.2GB on four different JVMs
  • ~1GB spread over multiple Azure CLIs
  • 1GB on Rust
  • ~700MB of older Golang versions

What are your thoughts on this selective purge? I'm thinking that we'd likely want to automate the creation of the image + purging as well. If you're happy with the idea in general, I'll start experimenting with some approaches.

@cplee
Copy link
Contributor

cplee commented Apr 17, 2020

@aidansteele I'm totally onboard with this idea 🚀

@cplee
Copy link
Contributor

cplee commented Apr 17, 2020

btw - here's the repo for the image i built: https://github.com/nektos/act-environments

@cplee cplee added area/runner Relating to errors in the runner needs-work Extra attention is needed labels Apr 17, 2020
@aidansteele
Copy link
Contributor Author

Great, good to hear you think it's a reasonable idea. I'll try report back with my findings / PR in the next few days - week.

@phaze9
Copy link

phaze9 commented Apr 17, 2020

I took the opposite approach by starting with act's default node:12.6-buster-slim image and adding what I need, which is currently docker.

If you're interested in creating a slim image tailored to your use-case, feel free to fork https://github.com/phaze9/action-runner
Or grab the slim image including docker-ce from https://hub.docker.com/repository/docker/phaze9/action-runner

@aidansteele
Copy link
Contributor Author

aidansteele commented Apr 27, 2020

I got a chance today to start looking into this. I created a tool to convert the upstream ubuntu1804.json into a Dockerfile (I'll release that later) and attempted to build it. A few things:

The total size is now just under 50 GB 🤯

It looks like some new things have been added to the environment since @cplee's image was built.

There are some steps I skipped as they failed and I didn't have time to look into why yet. The skipped steps were:

  • scripts/installers/docker-moby.sh (test failed due to dockerd not running inside container)
  • scripts/helpers/containercache.sh (same as above)
  • scripts/installers/homebrew.sh (refused to be installed as root)
  • scripts/installers/aws-sam-cli.sh (uses homebrew)
  • scripts/installers/mysql.sh (test failed to mysqld not running inside container)
  • scripts/installers/1804/android.sh
  • scripts/installers/vcpkg.sh
  • scripts/installers/1804/php.sh

These were all the steps that resulted in a layer on disk greater than 50 MB.

SIZE CREATED BY
20.4 GB scripts/installers/dotnetcore-sdk.sh
9.3 GB scripts/installers/haskell.sh
7.14 GB scripts/installers/hosted-tool-cache.sh
1.6 GB scripts/installers/swift.sh
1.37 GB scripts/installers/java-tools.sh
1.37 GB scripts/installers/clang.sh
921 MB scripts/installers/azpowershell.sh
527 MB scripts/installers/mono.sh
503 MB scripts/installers/rust.sh
500 MB scripts/installers/azure-cli.sh
382 MB scripts/installers/miniconda.sh
367 MB scripts/installers/nodejs.sh
366 MB scripts/installers/julia.sh
364 MB scripts/installers/google-cloud-sdk.sh
302 MB scripts/installers/mongodb.sh
287 MB scripts/installers/hhvm.sh
271 MB scripts/installers/bazel.sh
260 MB scripts/installers/google-chrome.sh
203 MB scripts/installers/1804/basic.sh
202 MB scripts/installers/1804/basic.sh
190 MB scripts/installers/1804/containers.sh
164 MB scripts/installers/powershellcore.sh
162 MB scripts/installers/powershellcore.sh
155 MB scripts/installers/packer.sh
155 MB scripts/installers/azcopy.sh
130 MB scripts/installers/python.sh
128 MB scripts/installers/ansible.sh
110 MB scripts/installers/cmake.sh
103 MB scripts/installers/heroku.sh
96 MB scripts/installers/phantomjs.sh
89 MB scripts/installers/1804/kubernetes-tools.sh
75.5 MB scripts/installers/aws.sh
68.4 MB apt-get -y install sudo lsb-core software-properties-common apt-utils
67.3 MB scripts/installers/ruby.sh
53.1 MB scripts/installers/git.sh
52.1 MB scripts/installers/terraform.sh

@github-actions
Copy link
Contributor

Issue is stale and will be closed in 7 days unless there is new activity

@github-actions
Copy link
Contributor

Issue is stale and will be closed in 7 days unless there is new activity

@kiptoomm
Copy link

I got a chance today to start looking into this. I created a tool to convert the upstream ubuntu1804.json into a Dockerfile (I'll release that later) and attempted to build it. A few things:

The total size is now just under 50 GB 🤯

It looks like some new things have been added to the environment since @cplee's image was built.

There are some steps I skipped as they failed and I didn't have time to look into why yet. The skipped steps were:

  • scripts/installers/docker-moby.sh (test failed due to dockerd not running inside container)
  • scripts/helpers/containercache.sh (same as above)
  • scripts/installers/homebrew.sh (refused to be installed as root)
  • scripts/installers/aws-sam-cli.sh (uses homebrew)
  • scripts/installers/mysql.sh (test failed to mysqld not running inside container)
  • scripts/installers/1804/android.sh
  • scripts/installers/vcpkg.sh
  • scripts/installers/1804/php.sh

These were all the steps that resulted in a layer on disk greater than 50 MB.

SIZE CREATED BY
20.4 GB scripts/installers/dotnetcore-sdk.sh
9.3 GB scripts/installers/haskell.sh
7.14 GB scripts/installers/hosted-tool-cache.sh
1.6 GB scripts/installers/swift.sh
1.37 GB scripts/installers/java-tools.sh
1.37 GB scripts/installers/clang.sh
921 MB scripts/installers/azpowershell.sh
527 MB scripts/installers/mono.sh
503 MB scripts/installers/rust.sh
500 MB scripts/installers/azure-cli.sh
382 MB scripts/installers/miniconda.sh
367 MB scripts/installers/nodejs.sh
366 MB scripts/installers/julia.sh
364 MB scripts/installers/google-cloud-sdk.sh
302 MB scripts/installers/mongodb.sh
287 MB scripts/installers/hhvm.sh
271 MB scripts/installers/bazel.sh
260 MB scripts/installers/google-chrome.sh
203 MB scripts/installers/1804/basic.sh
202 MB scripts/installers/1804/basic.sh
190 MB scripts/installers/1804/containers.sh
164 MB scripts/installers/powershellcore.sh
162 MB scripts/installers/powershellcore.sh
155 MB scripts/installers/packer.sh
155 MB scripts/installers/azcopy.sh
130 MB scripts/installers/python.sh
128 MB scripts/installers/ansible.sh
110 MB scripts/installers/cmake.sh
103 MB scripts/installers/heroku.sh
96 MB scripts/installers/phantomjs.sh
89 MB scripts/installers/1804/kubernetes-tools.sh
75.5 MB scripts/installers/aws.sh
68.4 MB apt-get -y install sudo lsb-core software-properties-common apt-utils
67.3 MB scripts/installers/ruby.sh
53.1 MB scripts/installers/git.sh
52.1 MB scripts/installers/terraform.sh

@aidansteele @cplee what happened to this? I am not so familiar with using Docker images so would love it if you can point me to any docs on how to use this slim variant. I tried using ubuntu-latest=nektos/act-environments-ubuntu:18.04 but it looks too large as it's taking forever to load. All I'm trying to do is to use act on paths-filter, a GH Action that requires git

@pimterry
Copy link

I've found an interesting alternative approach. I'm using this as my base image: https://github.com/httptoolkit/act-build-base/blob/main/Dockerfile

In effect, I'm sticking with a plain node base image, and just mixing in individual installers for the specific parts of the standard image I need, directly pulling individual scripts from act-environments.

Maybe there's a route through here? The installer scripts aren't quite as easy to use standalone right now as they could be (e.g. they don't work without document.sh preloaded into the right path) but with a few small tweaks there I can imagine an Act readme that said you can either:

  • Use the full-fat act-environments image
  • Use a base template, and pull in whichever of the below parts of the core build are relevant for your use case.

For people like me, that'd be pretty useful - doing this seems to work perfectly, it's very easy, and it saves me an enormous amount of disk space.

For GitHub themselves it makes sense to provide an actions base that includes the kitchen sink, but no individual devs need all of that locally for every build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runner Relating to errors in the runner needs-work Extra attention is needed stale
Projects
None yet
Development

No branches or pull requests

5 participants