Stephane-D / SGDK

SGDK - A free and open development kit for the Sega Mega Drive
https://www.patreon.com/SGDK
MIT License
1.7k stars 179 forks source link

Add native docker images w/ build workflow #316

Closed joeyparrish closed 3 months ago

joeyparrish commented 4 months ago

Rebased, cleaned-up version of PR #292, which adds Docker images that do not rely on Wine, with a GitHub Actions workflow to build and push Docker images to ghcr.io.

Compared with #292, this:

Resolves #290 Resolves #304

joeyparrish commented 4 months ago

I'm debugging and streamlining the workflows on my fork. I'll convert this to a draft for now until that process is complete. Sorry for the noise!

joeyparrish commented 4 months ago

This is ready now. Please take a look!

loki666 commented 4 months ago

Nice, could you add git to the second stage image. It would be handy when using the image in a VS Code devcontainer.

Thanks

joeyparrish commented 3 months ago

Nice, could you add git to the second stage image. It would be handy when using the image in a VS Code devcontainer.

I would like to keep this PR focused. When it is merged, and we have build pipelines that automatically publish new Docker images, you could always follow up with a PR to add git. And ultimately, it will be @Stephane-D who decides whether or not to allow that.

joeyparrish commented 3 months ago

@Stephane-D, I believe I have addressed all the feedback so far. My only outstanding question for you is this:

This Dockerfile can regenerate all binaries. I can delete all .exe, .dll, .jar, and .a files from the repo and everything still works from source natively on Linux. Deleting those from the repo would resolve https://github.com/Stephane-D/SGDK/issues/297, but I'm not sure if that would have negative consequences for Windows users. Should I do it here? In a follow-up PR? Not at all?

Thanks!

Stephane-D commented 3 months ago

@Stephane-D, I believe I have addressed all the feedback so far. My only outstanding question for you is this:

This Dockerfile can regenerate all binaries. I can delete all .exe, .dll, .jar, and .a files from the repo and everything still works from source natively on Linux. Deleting those from the repo would resolve #297, but I'm not sure if that would have negative consequences for Windows users. Should I do it here? In a follow-up PR? Not at all?

Thanks!

@joeyparrish Thanks for taking the time to fix all that ! Well about the JAR file rebuild, it's just that i'm afraid that this increase significantly the Docker call. As I understand it, it will rebuild all tools at each time will compile through the Docker call right ?

joeyparrish commented 3 months ago

Well about the JAR file rebuild, it's just that i'm afraid that this increase significantly the Docker call. As I understand it, it will rebuild all tools at each time will compile through the Docker call right ?

Those steps (building tools, jars, etc) will only run when someone runs "docker build ..." to create the image from SGDK source. The GitHub Actions workflow will build images every time you push to the master branch. These are all the steps with "RUN".

When a user wants to compile their ROM with SGDK using Docker, the tools will not be rebuilt. It will start at "ENTRYPOINT".

Does this answer your concern?

joeyparrish commented 3 months ago

@Stephane-D, let me know if you have other concerns or if you would like me to make other changes. I believe the PR is in a good state. Everything is rebuilt from source at Docker build time in the automated workflow. Each change to the master branch will trigger a new Docker image with native Linux binaries to be published via GitHub. And the Docker image is now based on Alpine Linux instead of Ubuntu, which should make it much smaller and faster to download.

iratahack commented 3 months ago

@joeyparrish , any thoughts on using crosstool-ng and bulding the latest gcc 13.2.0?

Also, Sjasm sources are included under tools as a submodule. There is no need to clone independently.

joeyparrish commented 3 months ago

@joeyparrish , any thoughts on using crosstool-ng and bulding the latest gcc 13.2.0?

Also, Sjasm sources are included under tools as a submodule. There is no need to clone independently.

Looks like it would be useful. I could explore redoing the GCC Dockerfile with crosstool-ng after this PR is merged. Or you could send a PR yourself if you already have experience with crosstool-ng. (I have none.)

iratahack commented 3 months ago

@joeyparrish , any thoughts on using crosstool-ng and bulding the latest gcc 13.2.0? Also, Sjasm sources are included under tools as a submodule. There is no need to clone independently.

Looks like it would be useful. I could explore redoing the GCC Dockerfile with crosstool-ng after this PR is merged. Or you could send a PR yourself if you already have experience with crosstool-ng. (I have none.)

I have the Dockerfile specific to building the tools using crosstool-ng but I may need some assistance integrating it. Maybe a collaboration? Take a look at the Dockerfile here https://github.com/iratahack/SGDK/commit/ba9fc473937e2d79ab349940dc1d5272325910f1

joeyparrish commented 3 months ago

@iratahack, I was hoping to get this PR merged as a baseline before I moved on to improvements, so I would at least be able to refer to the official Docker image from ghcr.io for my own project. But since this hasn't been re-reviewed, I'll take a look at your work and try to integrate it if I can. It may be days to weeks before I have the time, though. Thank you for your offer of collaboration!