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

If I want to compile something to run on flatcar, what is the most appropriate linux environment to do so? #1063

Closed
timprepscius opened this issue Jun 6, 2023 · 8 comments
Labels
kind/bug Something isn't working

Comments

@timprepscius
Copy link

Greetings, this is neither a bug, issue, enhancement, etc. I'm not exactly sure where to ask actually.

I would like to compile a program to run on a flatcar instance, but not inside a docker.

I've been looking if there is some sort of

docker run --rm -it flatcar/dev-env /bin/bash

Out there, but can't find it.
What is the nearest/best environment to use to compile for flatcar?
What do you use?

Thanks!

-tim

@jepio
Copy link
Member

jepio commented Jun 7, 2023

It's kind of concealed in the documentation, but the relevant section is here: https://www.flatcar.org/docs/latest/reference/developer-guides/kernel-modules/#prepare-a-flatcar-container-linux-development-container.
You can also use the docker containers from here directly: https://github.com/mediadepot/docker-flatcar-developer#docker-images

May I ask what you're looking to compile? Keep in mind that you need to package up all deps, and will have to rebuilt your programs with every flatcar release.

@timprepscius
Copy link
Author

Sure.

I have to warn you, what I'm doing is "wrong." And I know it. It is not your intended use. I haven't decided whether or not I'm super dumb, or just sort of dumb.

So I have a self-project I've been working on for a few years.
I'm using Vultr to host it.
I'm starting to figure out how I want to scale it, but in a small way. Like max 10 computers or something, nothing I need automation for.

Each computer will run just one process.

I could have one more expensive computer, with a bunch of dockers, I suppose. But for now, I'm choosing to use the super cheap $2.50 computers, that way I can easily adjust without worrying about one docker taking cpu/mem resources from another, etc. I figure Vultr will be much better at doing this than I would.

Each super cheap $2.50 computer (512mb), with flatcar, no docker, has about 100mb spare.
(With docker, 30mb). (Isn't it crazy that linux takes 400mb?!?, if it is mostly buff/cache)

Vultr does not have Alpine, nor does it have Almalinux-minimal.

So, that's my use case.
I have full control of the build.
I don't need docker. I need a secure minimal performant linux, that Vultr gives as an option. (or linux-flavor ISO's do not install on 512mb - or at least I couldn't get them to). Flatcar's super simple installation allows Vultr to host it easily I think.

My use case is sort of opposite of what you're doing I suppose.

@timprepscius
Copy link
Author

BTW, if you see a much more obvious and clear option for me to try, feel free to suggest. I'm not a sys-admin, and will take any advice!!

@pothos
Copy link
Member

pothos commented Jun 7, 2023

Using containers makes it simple to, well, contain the dependencies and build and run independently on every environment.
If you are willing to invest into building binaries and manage how to deploy them without containers, I recommend you to build static binaries and then you don't have to worry about dynamic linking and whether things break on updates.

We also plan to make it easier to build systemd-sysext images that can extend /usr or /opt (first case would be dynamic linking and dependend on the OS version, second would be self-contained and independent from the OS version).

@timprepscius
Copy link
Author

Yeah, maybe I can use Alpine inside or something. Unfortunately it is not a trivial replacement between Alpine and redhat-based/ubuntu-based. Flatcar linux is closer to my normal build environment than Alpine.

I have a couple questions, but maybe they are too off-topic.

  1. Would a dockered flatcar inside a flatcar take near zero resources? So, could I build for a flat dev image version 1234.56.78, then run docker flatcar:1234.56.78 /myprogram/blah

So that if the hosting flatcar updated, and changed something I'm not aware even exists, the dockered-flatcar would remain viable? (but the memory use by docker would stay ultra low)

  1. Why does linux take so much memory? Lol, what a stupid question, but still, what's going on? (I think I have just proved I know nothing). You can ignore this one.

@timprepscius
Copy link
Author

Hey @jepio thank you very much for the link to the dev.
It would be great if that page had a little bit more information regarding using emerge.

I'll paste into here what I'm doing for a dockerfile (for anybody searching).

# this number comes from this page: https://www.flatcar.org/releases
# if you pick a release number too early, emerge will not work
# I think because emerge-gitclone is pulling head?
FROM mediadepot/flatcar-developer:3510.2.2

# I'm trying to create a "superuser" account so I can use emerge within the container
# but I haven't figured out how to do it.
# If I don't do this, docker doesn't let me log in as that user....
#RUN echo 'root:x:0:0:root:/root:/bin/bash' >> /etc/passwd
#RUN echo 'core:x:500:500:Flatcar Admin:/home/core:/bin/bash' >> /etc/passwd

# very important
RUN emerge-gitclone
RUN emerge --sync

# then you can install software 
RUN emerge autoconf
RUN emerge libtool
RUN emerge cmake

Also, as with every different linux installation, there was a new compile issue.

With flatcar, somehow minizip doesn't compile without a patch of essentially
xroche/httrack@37c0c19

@pothos pothos moved this from 📝 Needs Triage to 🪵Backlog in Flatcar tactical, release planning, and roadmap Jun 19, 2023
@krishjainx
Copy link

We also plan to make it easier to build systemd-sysext images that can extend /usr or /opt (first case would be dynamic linking and dependend on the OS version, second would be self-contained and independent from the OS version).

@timprepscius We've made progress on generating systemd-sysext images. If you're interested please have a look at this commit in the scripts repo: flatcar/scripts@eb2f3d5 and the associated PR.

@dongsupark
Copy link
Member

Thanks for the question.
Let's close it for now.
If you have more questions, feel free to create a new discussion on https://github.com/flatcar/Flatcar/discussions/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants