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 static linking in Dockerfile; add docker-compose.yml #61

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

Alistair1231
Copy link
Contributor

Hi!
Great project! While I do like nix, I have all my server stuff managed using docker at the moment and want to keep it consistent. I had some issues with the included Dockerfile, as it kept giving me glibc errors.
To circumvent that, I just made it compile statically linked, and it seems to work now.

I also added a very basic docker-compose.yml, so people can just clone the repo and use docker compose up -d to get everything up and running.

@w4
Copy link
Owner

w4 commented Oct 17, 2023

thanks!

@w4 w4 merged commit dc6f9b5 into w4:master Oct 17, 2023
@rothgar
Copy link

rothgar commented Oct 17, 2023

Is statically linking against x86_64-unknown-linux-musl but using debian (glibc based) a problem?

@Alistair1231
Copy link
Contributor Author

Alistair1231 commented Oct 18, 2023

Is statically linking against x86_64-unknown-linux-musl but using debian (glibc based) a problem?

Thanks for looking out, I will see that I will adjust the Dockerfile accordingly.

It seems to work fine, but better safe than sorry.
Since it only copies the executable, the base image should be able to be changed to anything else. I assume that the issue came, due to the glibc version in rust:1-slim and debian:bullseye-slim being different. i.e. the one used to compile being newer than the one it ran on.
Instead of having this 2 phase approach, the executable could probably also just be run in the rust:1-slim based container but to keep it simple I will just change the debian base to alpine.

@rothgar
Copy link

rothgar commented Oct 18, 2023

If it's statically compiled do you need a distro at all? I'm assuming FROM scratch would work, but I haven't tested it.

@Alistair1231
Copy link
Contributor Author

If it's statically compiled do you need a distro at all? I'm assuming FROM scratch would work, but I haven't tested it.

I've never used from scratch and wasn't even aware it's a thing. But alpine is pretty lightweight with 5 MiB, so not a lot is lost by using it.

@w4
Copy link
Owner

w4 commented Nov 27, 2023

Moved to FROM scratch in c267821

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

Successfully merging this pull request may close these issues.

None yet

3 participants