Closed jlek closed 2 years ago
I have never tried this. :-) And it's not currently a supported configuration.
But it looks like you're missing your /etc/password
file. Even in a "from scratch" environment, you'll need to set up a few key files expected by various libraries.
I'll leave this issue open in case you figure it out and want to document it and/or provide a new example program. However, I am unlikely to have any time to work on this myself.
Here's a working example @jlek :)
FROM ekidd/rust-musl-builder:stable AS builder
WORKDIR /home/rust
RUN USER=rust cargo new --bin hello-world \
&& cd hello-world \
&& cargo build --release
FROM scratch
COPY --from=builder /home/rust/hello-world/target/x86_64-unknown-linux-musl/release/hello-world /usr/local/bin/
USER 1000
CMD ["hello-world"]
Let me know if it works for you as well
Cheers, Oliver
I build all the time non-Alpine. I'm using this image to do distroless using buildah. Works great!
Note scratch is actually garbage to use. For example, it won't support ssl. If you need something lighter than alpine, check out distroless static
.
@EvanCarroll - that link is broken
@EvanCarroll - that link is broken
Fixed!
Hello! I have been using this project to learn a bit more about Rust compilation, (static) linking, and Docker, so: thanks! :grin: I'm a bit stuck on one little thing, so I thought I'd create this issue.
How could this project be improved?
Is it possible to use rust-musl-builder to make Docker images from Scratch, rather than from Alpine? If so, would it be possible to add an example? (Or is there a good reason to use Alpine rather than Scratch?)
If you're interested in implementing this feature yourself, how could I help you?
Once I figure it out, I would be happy to submit a pull request with the example. Here is my Dockerfile so far:
However, I get an error: