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

Fix image build errors with podman and nerdctl. #1033

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

Alexhuszagh
Copy link
Contributor

@Alexhuszagh Alexhuszagh commented Sep 27, 2022

Ensures that docker and nerdctl, which support the custom --output and --cache-from flags use them, while podman and unknown container engines use the strict, minimal subset podman supports. This is because podman only supports a registry/repository, without a tag, for --cache-from, which means it synchronizes poorly with our target subs, like centos. Therefore, unless unsupported, we should always use the features available for our container engine.

This also fixes the --pull flag on nerdctl, which is unsupported. Engines without BuildKit extensions by default, such as nerdctl, now do not use buildx unless explicitly enabled with CROSS_CONTAINER_ENGINE_NO_BUILDKIT=0.

Closes #1031.

@Alexhuszagh Alexhuszagh requested a review from a team as a code owner September 27, 2022 19:34
@Alexhuszagh

This comment was marked as outdated.

bors bot added a commit that referenced this pull request Sep 27, 2022
@Alexhuszagh

This comment was marked as outdated.

@Alexhuszagh

This comment was marked as outdated.

bors bot added a commit that referenced this pull request Sep 27, 2022
@Alexhuszagh

This comment was marked as outdated.

bors bot added a commit that referenced this pull request Sep 27, 2022
@Alexhuszagh Alexhuszagh marked this pull request as draft September 27, 2022 19:42
@bors

This comment was marked as outdated.

@Alexhuszagh

This comment was marked as outdated.

1 similar comment
@Alexhuszagh

This comment was marked as outdated.

bors bot added a commit that referenced this pull request Sep 29, 2022
@bors

This comment was marked as outdated.

@Alexhuszagh
Copy link
Contributor Author

bors try --target x86_64-unknown-linux-gnu

I've added a custom image build to the Podman test (it's a trivial pre-build step, so it just tests the image build steps work), so we can ensure building and testing images work.

bors bot added a commit that referenced this pull request Sep 29, 2022
@bors
Copy link
Contributor

bors bot commented Sep 29, 2022

try

Build succeeded:

@Alexhuszagh Alexhuszagh force-pushed the podman_cache branch 2 times, most recently from 32c3970 to 3865429 Compare September 29, 2022 21:06
@Alexhuszagh Alexhuszagh marked this pull request as ready for review September 29, 2022 21:06
@Alexhuszagh
Copy link
Contributor Author

I haven't added tests for Lima (nerdctl), since it requires a Homebrew installation which takes a long, long time and sometimes errors due to too many file descriptors being open. I have, however, tested this locally and confirmed the above flags work. We're currently waiting on lima-vm/lima#1075 to see if we can get BuildKit working with Lima.

@Alexhuszagh
Copy link
Contributor Author

We might also want to default to no buildx with Lima, since it doesn't support it.

@Alexhuszagh Alexhuszagh changed the title Fix --cache-from for podman and test podman in CI. Fix image build errors with Podman and NerdCTL. Sep 30, 2022
@Alexhuszagh Alexhuszagh changed the title Fix image build errors with Podman and NerdCTL. Fix image build errors with podman and nerdctl. Sep 30, 2022
@@ -187,7 +187,7 @@ pub fn build_docker_image(

if push {
docker_build.arg("--push");
} else if engine.kind.is_docker() && no_output {
} else if engine.kind.supports_output_flag() && no_output {
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this should be an error, i.e it should not be possible to specify no output and then not have it happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed it so we error if it doesn't support the output flag, with another branch:

if push {
    docker_build.arg("--push");
} else if engine.kind.supports_output_flag() && no_output {
    docker_build.args(["--output", "type=tar,dest=/dev/null"]);
} else if no_output {
    msg_info.fatal("cannot specify `--no-output` with engine that does not support the `--output` flag", 1);
} else if has_buildkit {
    docker_build.arg("--load");
}

Ensures that Docker and NerdCTL, which support the custom `--output` and `--cache-from` flags use them, while Podman and unknown container engines use the strict, minimal subset Podman supports. This is because Podman only supports a registry/repository, without a tag, for `--cache-from`, which means it synchronizes poorly with our target subs, like `centos`. Therefore, unless unsupported, we should always use the features available for our container engine.

This also fixes the `--pull` flag on NerdCTL, which is unsupported.
Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

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

lgtm!

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 30, 2022

Build succeeded:

@bors bors bot merged commit ab01c6e into cross-rs:main Sep 30, 2022
@Alexhuszagh Alexhuszagh deleted the podman_cache branch September 30, 2022 16:51
This was referenced Sep 30, 2022
@Alexhuszagh Alexhuszagh added the bug label Nov 6, 2022
@Emilgardis Emilgardis added this to the v0.3.0 milestone Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image Build Fails on Podman
2 participants