Skip to content

Adding containerized linux builds #178

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

Merged
merged 3 commits into from
Nov 5, 2020
Merged

Adding containerized linux builds #178

merged 3 commits into from
Nov 5, 2020

Conversation

ko1N
Copy link
Contributor

@ko1N ko1N commented Oct 31, 2020

To make it simpler to build ReClass.NET on Linux systems this change introduces a way to build ReClass without having to set up GCC or MSBuild (as this process can be a bit tedious on some distributions).

Instead of manually installing those dependencies we just load a docker environment and build them there now.

The new commands are:
make docker_all/docker_debug/docker_release
make podman_all/podman_debug/podman_release

make docker_all and make podman_all will already invoke the make dist step automatically.

@ko1N ko1N changed the title Added containerized linux builds Adding containerized linux builds Oct 31, 2020
@waterbear515
Copy link

This is amazing! I was just trying to build reclass on arch last week and gave up.

@ko1N Thanks for submitting this, as well as all your work with the wonderful Membase.

@KN4CK3R
Copy link
Member

KN4CK3R commented Nov 4, 2020

I hope this will not be needed in the future (™) with .NET 5. But currently it looks like ReClass would loose the gui part on linux systems if I switch to .NET 5. With Xamarin as part of .NET I must rewrite the complete gui with XAML.

@ko1N
Copy link
Contributor Author

ko1N commented Nov 4, 2020

That would be great but for the time being this PR makes things a bit simpler for Linux users. Apart from that i also released a Plugin for ReClass that will make it super easy to interact with Windows VMs from Linux which makes this PR a bit more valuable :)

@KN4CK3R KN4CK3R merged commit 095edc6 into ReClassNET:master Nov 5, 2020
@KN4CK3R
Copy link
Member

KN4CK3R commented Nov 29, 2020

For #181 I used the docker build and it worked realy great. Only the gcc build was failing. For docker I used sudo make docker_debug:

docker container run --rm -v :/build:z -w /build -u 0:0 gcc:latest bash -c "cd NativeCore/Unix && make debug"
bash: line 0: cd: NativeCore/Unix: No such file or directory
make: *** [Makefile:40: docker_debug] Error 1

The reason was the -u 0:0 caused by -u $(shell id -u ${USER}):$(shell id -g ${USER}) because ${USER} is root now. I fixed it with sudo docker in the make files but I don't know if that is a good solution.

diff --git a/Makefile b/Makefile
index 10ab0620..03fef0c7 100644
--- a/Makefile
+++ b/Makefile
@@ -37,12 +37,12 @@ docker_all:
 docker_debug:
        cd ReClass.NET_Launcher && make docker_debug
        cd ReClass.NET && make docker_debug
-       docker container run --rm -v ${PWD}:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) gcc:latest bash -c "cd NativeCore/Unix && make debug"
+       sudo docker container run --rm -v ${PWD}:/build:z -w /build -u $(shell id -u):$(shell id -g) gcc:latest bash -c "cd NativeCore/Unix && make debug"

 docker_release:
        cd ReClass.NET_Launcher && make docker_release
        cd ReClass.NET && make docker_release
-       docker container run --rm -v ${PWD}:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) gcc:latest bash -c "cd NativeCore/Unix && make release"
+       sudo docker container run --rm -v ${PWD}:/build:z -w /build -u $(shell id -u):$(shell id -g) gcc:latest bash -c "cd NativeCore/Unix && make release"

 podman_all:
        make podman_debug
diff --git a/ReClass.NET/Makefile b/ReClass.NET/Makefile
index d66fd569..673ce704 100644
--- a/ReClass.NET/Makefile
+++ b/ReClass.NET/Makefile
@@ -22,12 +22,12 @@ update:
        mono --runtime=v4.0 ../Dependencies/nuget.exe restore ReClass.NET.csproj -SolutionDirectory ../

 docker_debug:
-       docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Debug /p:Platform=x86 ReClass.NET.csproj"
-       docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Debug /p:Platform=x64 ReClass.NET.csproj"
+       sudo docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u):$(shell id -g) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Debug /p:Platform=x86 ReClass.NET.csproj"
+       sudo docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u):$(shell id -g) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Debug /p:Platform=x64 ReClass.NET.csproj"

 docker_release:
-       docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Release /p:Platform=x86 ReClass.NET.csproj"
-       docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Release /p:Platform=x64 ReClass.NET.csproj"
+       sudo docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u):$(shell id -g) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Release /p:Platform=x86 ReClass.NET.csproj"
+       sudo docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u):$(shell id -g) mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Release /p:Platform=x64 ReClass.NET.csproj"

 podman_debug:
        podman container run --rm -v ${PWD}/..:/build:z -w /build mono:latest bash -c "cd ReClass.NET && msbuild /p:Configuration=Debug /p:Platform=x86 ReClass.NET.csproj"
diff --git a/ReClass.NET_Launcher/Makefile b/ReClass.NET_Launcher/Makefile
index bc9ddd11..468708ae 100644
--- a/ReClass.NET_Launcher/Makefile
+++ b/ReClass.NET_Launcher/Makefile
@@ -17,10 +17,10 @@ clean_release:
        msbuild /t:Clean ReClass.NET_Launcher.csproj

 docker_debug:
-       docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) mono:latest bash -c "cd ReClass.NET_Launcher && msbuild /p:Configuration=Debug ReClass.NET_Launcher.csproj"
+       sudo docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u):$(shell id -g) mono:latest bash -c "cd ReClass.NET_Launcher && msbuild /p:Configuration=Debug ReClass.NET_Launcher.csproj"

 docker_release:
-       docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u ${USER}):$(shell id -g ${USER}) mono:latest bash -c "cd ReClass.NET_Launcher && msbuild /p:Configuration=Release ReClass.NET_Launcher.csproj"
+       sudo docker container run --rm -v ${PWD}/..:/build:z -w /build -u $(shell id -u):$(shell id -g) mono:latest bash -c "cd ReClass.NET_Launcher && msbuild /p:Configuration=Release ReClass.NET_Launcher.csproj"

 podman_debug:
        podman container run --rm -v ${PWD}/..:/build:z -w /build mono:latest bash -c "cd ReClass.NET_Launcher && msbuild /p:Configuration=Debug ReClass.NET_Launcher.csproj"

@ko1N
Copy link
Contributor Author

ko1N commented Dec 12, 2020

Docker shouldn't require to be run with sudo. You can just add your own user to the "docker" group to get access to the docker socket. The -u flag that sets the user is just for convenience so the output directory is owned by your own user and not root (which makes it easier to work with it in the future).

Interestingly when i tested it on my Fedora laptop podman just maps it to the proper user from the get go without any quirks.

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

Successfully merging this pull request may close these issues.

3 participants