diff --git a/README.md b/README.md index 361af0e91a..e3d4187ee0 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ - [Current Status](#current-status) - [Methodology](#methodology) - [Setting up a Development Environment](#setting-up-a-development-environment) + - [Docker](#docker) - [Linux](#linux) - [Ubuntu (20.04)](#ubuntu-2004) - [Arch](#arch) @@ -95,6 +96,30 @@ The remainder of this README is catered towards people interested in building th If this does not sound like you and you just want to play the game, refer to the above section [How to play the game](#how-to-play-the-game) +### Docker + +All three Linux systems are supported using Docker. + +Pick your supported prefered flavour of linux and build your chosen image + +``` +docker build -f docker/(Arch|Fedora|Ubuntu)/Dockerfile -t jak . +``` + +This will create an image with all required dependencies and already built. + +``` +docker run -v "$(pwd)"/build:/home/jak/jak-project/build -it jak bash +``` + +Note: If you the build directory you'll need to rerun the build command. Alteratively you can get the build via `docker cp` + +This will link your build folder to the images so can validate your build or test it on an external device. + +Docker images can be linked into your IDE (e.g. CLion) to help with codesniffing, static analysis, run tests and continuous build. + +Unfortently you'll still need task runner on your local machine to run the game or instead, manually run the game via the commands found in `Taskfile.yml` + ### Linux #### Ubuntu (20.04) diff --git a/docker/Arch/Dockerfile b/docker/Arch/Dockerfile new file mode 100644 index 0000000000..1e82723e8b --- /dev/null +++ b/docker/Arch/Dockerfile @@ -0,0 +1,28 @@ +FROM archlinux:latest + +RUN pacman -Syyu --noconfirm --needed cmake libpulse base-devel nasm python git libx11 libxrandr libxinerama libxcursor libxi + +# makepkg user and workdir +ARG user=jak +RUN useradd --system --create-home $user \ + && echo "$user ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/$user +USER $user +WORKDIR /home/$user + +# Install yay +RUN git clone https://aur.archlinux.org/yay.git \ + && cd yay \ + && makepkg -sri --needed --noconfirm \ + && cd \ + # Clean up + && rm -rf .cache yay + +RUN yay --noconfirm -S go-task + +RUN mkdir /home/$user/jak-project/ +COPY --chown=jak:jak . /home/$user/jak-project +RUN git config --global --add safe.directory /home/jak/jak-project + +WORKDIR /home/$user/jak-project + +RUN cmake -B build && cmake --build build -j 8 \ No newline at end of file diff --git a/docker/Fedora/Dockerfile b/docker/Fedora/Dockerfile new file mode 100644 index 0000000000..a150cf2fb0 --- /dev/null +++ b/docker/Fedora/Dockerfile @@ -0,0 +1,20 @@ +FROM fedora:latest + +RUN dnf install -y curl cmake python lld clang nasm libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel pulseaudio-libs-devel +RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + +ARG user=jak + +RUN useradd -m -d /home/${user} ${user} + +USER $user + +WORKDIR /home/$user + +RUN mkdir /home/$user/jak-project/ +COPY --chown=jak:jak . /home/$user/jak-project + +WORKDIR /home/$user/jak-project + +RUN cmake -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -B build +RUN cmake --build build -j$(nproc) \ No newline at end of file diff --git a/docker/Ubuntu/Dockerfile b/docker/Ubuntu/Dockerfile new file mode 100644 index 0000000000..4d88164918 --- /dev/null +++ b/docker/Ubuntu/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:20.04 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update +RUN apt-get install -y gcc make cmake build-essential g++ nasm clang-format libxrandr-dev libxinerama-dev libxcursor-dev libpulse-dev libxi-dev python lld clang curl + +RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + +ARG user=jak + +RUN useradd -m -d /home/${user} ${user} + +USER $user + +WORKDIR /home/$user + +RUN mkdir /home/$user/jak-project/ +COPY --chown=jak:jak . /home/$user/jak-project + +WORKDIR /home/$user/jak-project/build + +RUN cmake -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. +WORKDIR /home/$user/jak-project +RUN cmake -B build && cmake --build build -j 8