Skip to content

Alpine missing libc-dev #94

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
misalcedo opened this issue Dec 24, 2021 · 5 comments
Open

Alpine missing libc-dev #94

misalcedo opened this issue Dec 24, 2021 · 5 comments

Comments

@misalcedo
Copy link

I tried building executables using the alpine latest and the build failed unless I added RUN apk add libc-dev to my builder image. See https://github.com/misalcedo/kv-store for a sample repo that fails to build. Another one of my repos also failed.

The basic hello-world crate does build in this base image.

Looking at the debian-based images we do install libc-dev there. Is there any reason not to include it for Alpine?

I am new to compiling Rust with MUSL, so there may very well be a better way to do this.

@sfackler
Copy link
Member

The Alpine images are significantly more minimal than the standard Debian images - the slim Debian images are a better reference. libc-dev is only required when building C code as part of the compilation process.

@misalcedo
Copy link
Author

It's good to know that it's a conscious choice to keep the alpine image size down. Would be good to document that somewhere though. Took me a long time to figure out why the builds were broken as most rust alpine examples don't seem to compile c code so I didn't have much reference material to borrow from.

Granted this is my first time trying to create a scratch image from Rust, but if it's a common use case others may have the same problem.

@danielecr
Copy link

The Alpine images are significantly more minimal than the standard Debian images - the slim Debian images are a better reference. libc-dev is only required when building C code as part of the compilation process.

Why? I mean, I want to discuss real foundation of this choice. I bring two use cases as examples.

I use rust:1.75-alpine3.19 to build an executable:

FROM rust:1.75-alpine3.19

RUN cargo build --release

RUN mv target/release/myapp /myapp

FROM scratch as distro

COPY --from=builder /myapp /myapp

build and tag it with myapp:v0.1-alpine

From another image define

FROM myapp:v0.1-alpine as builder
## just be sure is there
RUN ls /myapp

FROM alpine:latest

COPY --from=builder /myapp /usr/local/bin/myapp
## etc

A second use case is to build inside the first of 2-stage Dockerfile directly. Ending with a slim image anyway.

What I am asking is: there are other real scenario in use? Who is using the rust image for something else than "compile-then-move-away"?

An image supposed to be useful for building rust code currently misses also the musl-dev package, and it is building for a musl architecture.

How much minimal should be? (or should it be really minimal at all?)

@randomairborne
Copy link

just want to drop my opinion here- yeah, i don't think it being minimal makes sense. rustc is huge.

@danielecr
Copy link

just want to drop my opinion here- yeah, i don't think it being minimal makes sense. rustc is huge.

yep, I see your point. My comments was meaningless. Sorry.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants