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

Running in docker #850

Open
arifd opened this issue Sep 27, 2022 · 9 comments
Open

Running in docker #850

arifd opened this issue Sep 27, 2022 · 9 comments

Comments

@arifd
Copy link

arifd commented Sep 27, 2022

Hey Guillaume,

Would it not be possible to make this crate work in docker if you simply map the volumes
i.e. in your docker-compose you can map paths from your host to the container like so...

volumes:
  - /host/path:/container/path
@GuillaumeGomez
Copy link
Owner

You would need to map all paths used by sysinfo. But once done, I think it should just work. What is the issue with this approach?

@arifd
Copy link
Author

arifd commented Sep 30, 2022 via email

@GuillaumeGomez
Copy link
Owner

No they're not as it's very specific to linux. You can grep on / to see a few paths. But I'm not sure that it'll work well because I assume it would conflict with docker's.

@GuillaumeGomez
Copy link
Owner

Which reminds me: https://blog.guillaume-gomez.fr/articles/2021-09-06+sysinfo%3A+how+to+extract+systems%27+information

I explained how sysinfo extracted information so that might be simpler for you to see what paths are required.

@TehPers
Copy link

TehPers commented Nov 26, 2022

I managed to get sysinfo working in Docker, but needed to modify sysinfo to not read from /proc because I wasn't able to mount /proc:/proc (can't remember the error). I ended up mounting /proc:/host/proc and modifying sysinfo to read from the SYSINFO_PROC_PATH environment variable if it exists to get the path. The project is here if you're interested (sysinfo fork is in the backend directory), although the changes were pretty simple.

I wasn't really sure if it would be appropriate to make a feature request for something like this, but I'd love to be able to use the official sysinfo instead. Maybe a similar approach could work, using an env var during build/runtime to configure it? It doesn't make much sense to expose it in the public API I don't think since it's Linux-specific.

@GuillaumeGomez
Copy link
Owner

It won't work for any other platform than linux. I'm not sure it would make much sense to have such a feature. However if we can make some changes so it's easier for you to keep it in your branch, it's fine to me.

@TehPers
Copy link

TehPers commented Nov 26, 2022

It won't work for any other platform than linux. I'm not sure it would make much sense to have such a feature. However if we can make some changes so it's easier for you to keep it in your branch, it's fine to me.

The changes I made were only on the Linux versions of the files. This was my concern though, as it adds Linux-specific functionality. I'm not sure it's worth porting that into sysinfo and I don't mind using my own fork, but it might be worth keeping this issue to track if others also come across the same issue with Docker.

I'm not sure there are any small changes that can be made to significantly simplify maintaining my fork of sysinfo. It's already a pretty small set of changes anyway. I'm just updating all the places that "/proc" shows up in the source to instead pull from an env var if it's set, which is only a few places really.

@GuillaumeGomez
Copy link
Owner

GuillaumeGomez commented Nov 26, 2022

Sounds good to me in any case. Maybe add a link to your repository so others can use it directly? ;)

@TehPers
Copy link

TehPers commented Nov 26, 2022

Sounds good to me in any case. Maybe add a link to your repository so others can use it directly? ;)

I linked it a couple replies up, but I'll split it out into its own repo sometime today and post the link here for anyone interested in it. Currently it's vendored as a subdirectory in another project.

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

No branches or pull requests

3 participants