Skip to content

Conversation

savil
Copy link
Collaborator

@savil savil commented Sep 15, 2022

Summary

Reduce image size by

  1. Replace gcc with glibc in the Runtime image.

    • gcc is needed in the DevPackages for the Build Stage. Replacing it with glibc doesn't work because glibc nix pkg is not available on mac OS (linux only). We want universal packages (defined as linux and mac, lol) since we share DevPackages with devbox shell.
  2. Copy just the specific built binary to the Runtime image.

How was it tested?

Using the basic testdata/rust/rust-stable-hello-world project:

  • before, size of image = 320MB
  • after, size of image = 64MB

Copy link
Collaborator Author

savil commented Sep 15, 2022

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@savil savil requested review from gcurtis and loreto September 15, 2022 04:40
@savil
Copy link
Collaborator Author

savil commented Sep 15, 2022

Tests are failing due to this getFileNames logic in devbox_test, which I don't quite understand the motivation for: https://github.com/jetpack-io/devbox/blame/26e7e8297aa5e4e31f9926328d98fbf62fc375a2/devbox_test.go#L58-L64

@savil savil changed the title [Rust Planner] Reduce image size by using binutils, and copying built binary [RFC][Rust Planner] Reduce image size by using binutils, and copying built binary Sep 15, 2022
@savil savil changed the title [RFC][Rust Planner] Reduce image size by using binutils, and copying built binary [RFC][Rust Planner] Reduce image size by using glibc, and copying built binary Sep 15, 2022
Copy link
Collaborator Author

@savil savil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loreto @gcurtis PTAL. Updated to use glibc, as per our discussion IRL.

Comment on lines +81 to +85
assert.ElementsMatch(
expected.StartStage.GetInputFiles(),
actual.StartStage.GetInputFiles(),
"StartStage.InputFiles should match",
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified with @LucilleH that it makes sense to drop getFileNames for StartStage.

Because:

  1. The motivation to introduce getFileNames was to normalize the filepaths used. The filepaths would differ based on which directory the go test command is invoked from.
  2. This doesn't apply to StartStage, since the InputFiles are relative to the BuildStage's container. And not relative to the local laptop/CICD invoking go test.

Copy link
Contributor

@loreto loreto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@savil savil merged commit a839e02 into main Sep 16, 2022
@savil savil deleted the savil/rust-reduce-image-size branch September 16, 2022 21:07
@Lagoja Lagoja added this to the 0.0.6 milestone Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants