cross-rs/cross

apt-get not work in dockerfile

Closed this issue · 8 comments

Checklist

Describe your issue

I tried to build the docker image locally, I used apt to download g++-x86-64-linux-gnu and protobuf-compiler etc. But these don't seem to take effect. Can I only define them in pre-build or .sh?
cargo build image:
image
the content in Dockerfile
image
But apt cannot find it
image

What target(s) are you cross-compiling for?

x86_64-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5 (d8631fe 2024-08-17)

Example

No response

Additional information / notes

No response

I'm not sure what these screenshots are supposed to show. Where is the installation logs? Why is RUN /xargo.sh underlined?

Sorry, my picture is not particularly accurate. The underline is to show that RUN apt... is not executed under cargo.
pic1: I pulled the image from ghcr.io and ran apt list to find it. I couldn't find the corresponding package "https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.x86_64-unknown-linux-gnu#L15"
image
pic2: I re-run cargo build-docker-image x86_64-unknown-linux-gnu --tag latest --no -cache, the new screenshot is as follows
image

the image built with cargo build-docker-image is tagged with :local, not :main
There's also some confusion here about what Dockerfile cargo build-docker-image x86-64-unknown-linux-gnu uses, it actually uses Dockerfile.native when target=platform

Oh, it seems that he parsed Dockerfile.native instead of "Dockerfile.x86_64-unknown-linux-gnu"

When the target is "x86_64-unknown-linux-gnu", Dockerfile.native is loaded.
But when the target is "i686-unknown-linux-gnu", Dockerfile.i686-unknown-linux-gnu is loaded correctly.
image

And I tried to use another ubuntu to execute cargo build-docker-image i686-unknown-linux-gnu --tag local and cargo build-docker-image x86_64-unknown-linux-gnu --tag local, error still exists
image

Yes, that is not a problem, it's supposed to be that way.

I'm not sure what this issue is about anymore, can we close it?

Now I understand the usage, but loading Dockerfile.native is a little uncomfortable when I build image for "x86_64-unknown-linux-gnu" locally. Thanks, we can close it.

To explain a bit, the reason .native is used is because we want to support using the images for other platforms. On x86_64-unknown-linux-gnu we cant install libc6-dev-amd64-cross, we just install libc6, so to make it easy, when image platform=target, we switch to .native