Skip to content

Instantly share code, notes, and snippets.

@tzickel
Last active April 1, 2021 10:33
Show Gist options
  • Save tzickel/d1dc99a0f6919b0b8b2f05fd56eb989e to your computer and use it in GitHub Desktop.
Save tzickel/d1dc99a0f6919b0b8b2f05fd56eb989e to your computer and use it in GitHub Desktop.
Running SerenityOS inside a Docker container
FROM archlinux
# Temporary patch for support old docker versions (like the default one in ubunutu 18.04)
RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst && \
curl -LO "https://repo.archlinuxcn.org/x86_64/$patched_glibc" && \
bsdtar -C / -xvf "$patched_glibc"
RUN pacman -Syyu --noconfirm && pacman-db-upgrade && pacman -S --noconfirm --needed base-devel cmake curl mpfr libmpc gmp e2fsprogs ninja qemu qemu-arch-extra git pulseaudio-alsa
RUN git clone https://github.com/bestouff/genext2fs
RUN cd /genext2fs && ./autogen.sh && ./configure && make && make install
# Changed here to only build the changes to the OS without rebuilding the toolchain each time
#ADD https://api.github.com/repos/SerenityOS/serenity/git/refs/heads/ version.json
RUN git clone https://github.com/SerenityOS/serenity/
RUN cd /serenity/Toolchain && ./BuildIt.sh
#RUN cd /serenity/Build/i686 && cmake ../../ -G Ninja && ninja install
RUN cd /serenity/Build/i686 && cmake ../../ -G Ninja
ADD https://api.github.com/repos/SerenityOS/serenity/git/refs/heads/ version.json
RUN cd /serenity/ && git pull
RUN cd /serenity/Build/i686 && ninja install
# Uncomment if you want curl support (you can add other Ports like this)
#RUN cd /serenity/Ports/curl && ./package.sh
WORKDIR /serenity/Build/i686
RUN ninja image
CMD ninja run
#CMD ninja image && ninja run
# You can build the image with: docker build -t serenityos - < Dockerfile
docker run -it --rm \
--device /dev/kvm \
--mount type=bind,source=/tmp/.X11-unix,target=/tmp/.X11-unix,readonly -e XAUTHORITY=/tmp/xauthority --mount type=bind,source="$(realpath "${XAUTHORITY}")",target=/tmp/xauthority,readonly -e DISPLAY=${DISPLAY} \
--mount type=bind,source="$(realpath "${XDG_RUNTIME_DIR}/pulse/native")",target=/tmp/pulseaudio,readonly --mount type=bind,source="$(realpath ~/.config/pulse/cookie)",target=/root/.config/pulse/cookie,readonly -e PULSE_SERVER=unix:/tmp/pulseaudio \
serenityos "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment