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

Use linux-micro sandbox image for local development #1360

Merged
merged 2 commits into from
Apr 29, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Apr 17, 2021

  • Add support for overriding remote docker images

    Previously, only local images could be overridden.

    This adds a new env variable DOCSRS_DOCKER_IMAGE, and makes the existing
    variable DOCS_RS_LOCAL_DOCKER_IMAGE a synonym for it. At some point I
    want to remove the old name, but that requires updating forge first.

  • Use the linux-micro image for tests

    I tested that this can build hexponent 0.3.0 successfully. This cuts
    the download size down from over 1 GB to about 150 MB.

Thank you pietro for your hard work on rust-lang/crates-build-env#78!

r? @pietroalbini
cc @rust-lang/docs-rs - you'll want to update your .env files so it's easier to run builds.

Previously, only local images could be overridden.

This adds a new env variable DOCSRS_DOCKER_IMAGE, and makes the existing
variable DOCS_RS_LOCAL_DOCKER_IMAGE a synonym for it. At some point I
want to remove the old name, but that requires updating forge first.
@jyn514 jyn514 added A-newcomer-roadblock Area: A problem that isn't a bug, but makes it harder for people to contribute A-builds Area: Building the documentation for a crate labels Apr 17, 2021
Comment on lines +57 to +61
let image = match SandboxImage::local(&custom_image) {
Ok(i) => i,
Err(CommandError::SandboxImageMissing(_)) => SandboxImage::remote(custom_image)?,
Err(err) => return Err(err.into()),
};
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is what we want: this would result in the image never being updated, as once the image is downloaded it's available locally. A good heuristic could be to treat an image as remote if it contains /.

Copy link
Member Author

Choose a reason for hiding this comment

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

A good heuristic could be to treat an image as remote if it contains /.

Hmm, there are plenty of remote images that don't have / though, like ubuntu or alpine. Personally I would be ok with it being cached indefinitely; you can always remove the image if it gets out of date. Is there a way to tell if a local image was built locally or downloaded?

Copy link
Member

Choose a reason for hiding this comment

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

The full name for ubuntu is docker.io/ubuntu, docker just has a hardcoded "try docker.io if no registry specified". That said, just using a locally cached image without checking that it's up to date is pretty standard behaviour of docker tooling, you either need to explicitly docker pull ... to update it, or pass --pull to commands like docker build to have them attempt pulling updates.

Copy link
Member Author

Choose a reason for hiding this comment

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

The full name for ubuntu is docker.io/ubuntu, docker just has a hardcoded "try docker.io if no registry specified".

Well yes, but if someone overrides the image, they'll be using the shorthand.

Copy link
Member

Choose a reason for hiding this comment

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

Honestly I'm not sure: I don't want us accidentally use an older image in production because we end up changing the environment variable without realizing it.

Hmm, there are plenty of remote images that don't have / though, like ubuntu or alpine.

I don't think that's a problem, you can't realistically build any Rust crate using those images.

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly I'm not sure: I don't want us accidentally use an older image in production because we end up changing the environment variable without realizing it.

Oh I see - I don't think this will have any impact on prod, we don't override the image there.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we do want to change the image in prod, I think we should do that by changing the default, not through environment variables.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, ok.

Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

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

We probably could also directly use it in CI instead of the custom docker-file.

( I can also do it after this is merged )

@jyn514
Copy link
Member Author

jyn514 commented Apr 18, 2021

Ooh good idea, let me update that.

I tested that this can build `hexponent 0.3.0` successfully. This cuts
the download size down from over 1 GB to about 150 MB.
@jyn514 jyn514 added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Apr 18, 2021
@syphar
Copy link
Member

syphar commented Apr 27, 2021

@jyn514 are still design-questions unanswered here?

For the local/test setup it works fine as it should, with default rustwide image, local image and remote image.

@syphar
Copy link
Member

syphar commented Apr 27, 2021

( without the new env set it still uses the old image path, but that's due to rustwide being not updated on this branch. Which will be fine once merged)

@jyn514 jyn514 merged commit 36ba3a3 into rust-lang:master Apr 29, 2021
@jyn514 jyn514 deleted the test-image branch April 29, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builds Area: Building the documentation for a crate A-newcomer-roadblock Area: A problem that isn't a bug, but makes it harder for people to contribute S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants