LibertyOS-Development / kernel

The kernel for LibertyOS.
Apache License 2.0
277 stars 12 forks source link

add ability to build LibertyOS from docker. #5

Open ghost opened 2 years ago

ghost commented 2 years ago

Add a dockerfile so that LibertyOS can be built from a docker image. This will allow LIbertyOS to be built in a "container" so that all dependencies, etc will be built in the docker container and will not contaminate the host operating system. I will try to create a sample Dockerfile and post it here when I am done. I'm a beginner in dockerfiles, so maybe someone with more experience in docker can take a look at the file I post and suggest improvements.

danielteberian commented 2 years ago

Hey there! The idea of having a Dockerfile had never occurred to me, so I am really happy that you brought it up. I went ahead and created a blank Dockerfile, as well as a .dockerignore file. I don't know that much about working with Docker (I know what it is), but I can read up on it and try to get a working Docker image set up.

If you haven't already, I would suggest joining the Discord server. We can discuss this in more detail there. I will keep this issue open until we get a Docker image ready.

Thanks!

ghost commented 2 years ago

Here's the dockerfile. Not sure this is the best way to do this, but this is a start. This dockerfile installs all the dependencies and then does a cargo build to build the kernel. My last few lines tries to copy the compiled kernel back to the host file system. (this is not working). Maybe someone will know how to fix this.

`FROM rust:1.55-alpine as builder

WORKDIR /usr/src/LibertyOS COPY . .

run apk add --no-cache musl-dev bash

RUN rustup target add x86_64-unknown-linux-gnu RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-musl RUN rustup component add llvm-tools-preview RUN cargo install bootimage RUN rustup default nightly

RUN cargo build

FROM scratch as hostFS COPY --from=builder /usr/src/LibertyOS/target/ ./ `

danielteberian commented 2 years ago

I can check this in the morning. If you are able to, could you try to submit a pull request?

davethiede commented 2 years ago

I'm looking at this docker file. the order of commands is sensitive. using a "docker cp :/path/to/kernel ." should work to extract the kernel image back to the host. I don't recall anyway within the docker file to do this unless you mount a share.

nicholasmello commented 1 year ago

Hey! I saw the reddit post asking for help on this project. I think this is a good issue for me to start on, I will take a look today and get back to you guys.

edit: I will mention I have done this kind of stuff before which is why I am choosing it

davethiede commented 1 year ago

I'm still around. been chasing other squirrels. I pulled the latest and there seems to be a build error now.

error: failed to compile libertyos_kernel v0.17.0 (/), intermediate artifacts can be found at /target

Caused by: package log v0.4.19 cannot be built because it requires rustc 1.60.0 or newer, while the currently active rustc version is 1.59.0-nightly Error: building at STEP "RUN cargo install --debug --root /usr/local --path .": while running runtime: exit status 101

I'm happy to help clean this up.

Ugh. That's an issue with the updated dependencies. Try and pull the Cargo lockfile from the repository and use that to set up Docker. Sorry about that.

nicholasmello commented 1 year ago

I fixed that by updating rust-toolchain.toml by just 1 year. Let me know if there is a better fix for that. I am almost finished, I am getting successful copy out of the container.

nicholasmello commented 1 year ago

I drafted a PR, let me know about the rust-toolchain.toml change

22