<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Docker build environment gets an upgrade!</title>
		<link>http://www.allegro.cc/forums/view/618390</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 08 Apr 2021 16:38:14 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey,</p><p>For the past few years I&#39;ve been maintaining docker build environments for allegro. These docker containers have all the dependencies needed to build a typical allegro game.</p><p>With docker installed, a typical build would look like this:</p><div class="source-code snippet"><div class="inner"><pre>docker run \
  <span class="k3">-</span>v `pwd`<span class="k2">:</span><span class="k3">/</span>data \
  amarillion<span class="k3">/</span>alleg5-buildenv \
  make
</pre></div></div><p>

This will download the latest docker image <span class="source-code">amarillion<span class="k3">/</span>alleg5-buildenv</span>, volume-mount the current directory inside this docker image, and run <span class="source-code">make</span>.</p><p>Apart from the linux variant, since the release of allegro 5.2.7, I&#39;ve added a few variants, so now we have:</p><ul><li><p>linux variant. Standard ubuntu-based build environment, with Release, Debug, Static and Monolith builds installed.
</p></li><li><p>allegro 4 variants. For compiling older games on linux.
</p></li><li><p>mingw-w64 variant. For cross-compiling windows binaries. Targets the i686 architecture (i.e. 32 bit). If desired, I could also whip up a variant for x86-64. Release, Debug, Static and Monolith all included. At the moment, I&#39;ve omitted a few of the deps that I don&#39;t use much myself, like theora and physfs, but I can add them if desired.
</p></li><li><p>d-lang variant. Includes D-lang tools (dmd) and SiegeLord&#39;s DAllegro5.
</p></li><li><p>I&#39;ve been working on android and emscripten variants, but these are still a work-in-progress. A raspberry PI variant is not out of the question either.</p></li></ul><p>You can find all of these on dockerhub here: <a href="https://hub.docker.com/u/amarillion">https://hub.docker.com/u/amarillion</a><br />Sources and some documentation is here: <a href="https://github.com/amarillion/allegro-buildenv/">https://github.com/amarillion/allegro-buildenv/</a></p><p>So what can you do with this? Quite a lot...</p><ul><li><p>Build a windows game from your linux machine. Using the mingw-w64 variant, you can have a working cross compilation toolchain up in a single command. No need to figure out how to cross-build all the dependencies of allegro, because I already did that for you!
</p></li><li><p>Build a linux game from your windows/mac machine. Wait, what??? Yes that&#39;s right! In the past years, Docker Desktop for Windows has gone from a weird hack to a reliable technology (we use it all the time at my day job). So that means you can easily build a linux version of your allegro game without having to maintain a linux setup.  
</p></li><li><p>Continuous integration servers. This is how I use these myself. I have a little Jenkins-CI server at home, that monitors all my projects, and builds several variants every time I push a change. With the new mingw-w64 setup, I can now build both linux and windows variants from the same jenkins server. Since both github and gitlab now provide CI pipelines that use docker under the hood, potentially you can make it work for any open source project hosted on those sites. 
</p></li><li><p>Documenting how to build allegro. Dockerfiles contain all the precise steps needed to get Allegro compiling, starting from a pristine environment. If you want to know how to cross-compile allegro on mingw-w64, the best starting point is to follow the steps here: <a href="https://github.com/amarillion/allegro-buildenv/blob/master/alleg5-mingw/Dockerfile">https://github.com/amarillion/allegro-buildenv/blob/master/alleg5-mingw/Dockerfile</a> 
</p></li><li><p>Testing allegro builds. Docker containers are cordoned off from the rest of your OS, so you can quickly test a variation of your allegro dependency chain in isolation, without screwing with your development setup. I&#39;ve been experimenting with emscripten this way (still WIP at this point)</p></li></ul><p>I&#39;d really love some feedback. Would you use it? Have you tried it? Does it work for you? What would you like to see added? What sort of documentation would you need?</p><p>See also the original announcement a few years back: <a href="https://www.allegro.cc/forums/thread/616906/">https://www.allegro.cc/forums/thread/616906/</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (amarillion)</author>
		<pubDate>Mon, 05 Apr 2021 14:17:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618390/1049714#target">amarillion</a> said:</div><div class="quote"><p> Build a windows game from your linux machine. Using the mingw-w64 variant, you can have a working cross compilation toolchain up in a single command. No need to figure out how to cross-build all the dependencies of allegro, because I already did that for you!</p></div></div><p>A-mazing.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> Would you use it?</p></div></div><p>Absolutely.  It&#39;ll take a while for me to get to it, but I&#39;ve been trying to put something like this together myself for a long while. Right now, it&#39;s git push on mac, git pull on win, make, but I want it to all be completely automated, tests included.  I&#39;m looking forward to using this. My dream is to build this as a web service.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Tue, 06 Apr 2021 02:22:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nice.  I wonder if I can do the same thing for Allegro.pas, but I&#39;m always busy <img src="http://www.allegro.cc/forums/smileys/cry.gif" alt=":&#39;(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Niunio)</author>
		<pubDate>Tue, 06 Apr 2021 14:42:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is this intended to build your own games?</p><p>e.g. A directory containing:</p><ul><li><p>Makefile  (my makefile with instructions on how to build my game with -lallegro)
</p></li><li><p>main.c (my source code)</p></li></ul><p>Then run docker from that directory?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 07 Apr 2021 00:14:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618390/1049719#target">Matthew Leverton</a> said:</div><div class="quote"><p>
Is this intended to build your own games?</p><p>e.g. A directory containing:</p><p>    Makefile (my makefile with instructions on how to build my game with -lallegro)</p><p>    main.c (my source code)</p><p>Then run docker from that directory? 
</p></div></div><p>

Yes indeed, that&#39;s the primary use case. To make it clearer, I&#39;ve created a minimal example, containing just a makefile, a single source file, and a script to collect DLLs. </p><p>It should be possible to compile this example for windows and linux, using only docker. No need to set up any build tools or even allegro (You&#39;d still want at least one toolchain during development, of course. But you don&#39;t need it here). So far I&#39;ve only tested it on a linux host, but it should be possible on Mac/Windows hosts as well.</p><p>You can find the example here: <a href="https://github.com/amarillion/allegro-buildenv-example">https://github.com/amarillion/allegro-buildenv-example</a></p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618390/1049718#target">Niunio</a> said:</div><div class="quote"><p>
I wonder if I can do the same thing for Allegro.pas, but I&#39;m always busy
</p></div></div><p>
If you can explain in a few simple bash commands how to set up Allegro.pas on Ubuntu (i.e. install Pascal, wget bindings, compile bindings), I can set you up with a simple Dockerfile. Then you can take it from there.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618390/1049715#target">Mark Oates</a> said:</div><div class="quote"><p>
My dream is to build this as a web service. 
</p></div></div><p>
That would be cool indeed. The Unity game engine provides a similar service, so it would be cool to be able to match that. I believe it should be possible to do this using the (free) CI pipelines provided by github / gitlab too, but I still have to try that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (amarillion)</author>
		<pubDate>Wed, 07 Apr 2021 16:10:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Two issues that could trip people up:</p><ul><li><p>File permissions. I&#39;m unable to use this without giving world write access to the current folder because docker is trying to write the file as user id 1000 (whatever that happens to be). I&#39;m not a docker expert when it comes to running it as a tool like this, but I assume there&#39;s something else trivial that can be done to remedy this.</p><br /></li><li><p>The include uses local path (#include &quot;allegro5/allegro.h&quot;) whereas I traditionally am used to building it from a system path (&lt;allegro5/allegro.h&gt;).
</p></li></ul></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 07 Apr 2021 23:19:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Could I use this to cross compile from Windows 10 to OSX / Apple / iOS / Linux?</p><p>That would be neat. &gt;.&gt;&lt;.&lt;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 08 Apr 2021 09:11:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618390/1049724#target">Matthew Leverton</a> said:</div><div class="quote"><p>
    File permissions. I&#39;m unable to use this without giving world write access to the current folder because docker is trying to write the file as user id 1000 (whatever that happens to be). I&#39;m not a docker expert when it comes to running it as a tool like this, but I assume there&#39;s something else trivial that can be done to remedy this.
</p></div></div><p>

Yes, this can be solved by specifying your uid, for example</p><div class="source-code snippet"><div class="inner"><pre>docker run \
  <span class="k3">-</span>u `id <span class="k3">-</span>u`<span class="k2">:</span>`id <span class="k3">-</span>g` \
  <span class="k3">-</span>v `pwd`<span class="k2">:</span><span class="k3">/</span>data \
  amarillion<span class="k3">/</span>alleg5-buildenv \
  make
</pre></div></div><p>

I&#39;ll add a note to the documentation.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
    The include uses local path (#include &quot;allegro5/allegro.h&quot;) whereas I traditionally am used to building it from a system path (&lt;allegro5/allegro.h&gt;). 
</p></div></div><p>

I&#39;m not sure, is this actually a problem? I copied the code from one of the allegro examples, I believe it should work either way.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618390/1049727#target">Edgar Reynaldo</a> said:</div><div class="quote"><p>
Could I use this to cross compile from Windows 10 to OSX / Apple / iOS / Linux?
</p></div></div><p>

Linux, yes for sure. But OSX / Apple / iOS is a different problem altogether, I have no idea if this is possible. Probably not.</p><p>Docker containers are basically tiny linux virtual machines(*). Compiling for windows relies on the pre-existing possibility to cross-compile for windows on linux hosts. Docker doesn&#39;t create this possibility out of thin air, it just makes it easier to set it up.</p><p>*) On linux they&#39;re process groups that are walled-off from the rest of the system. On Mac / Windows, they really are implemented as a small virtual machine.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (amarillion)</author>
		<pubDate>Thu, 08 Apr 2021 10:59:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I may be wrong but I think it is doable even for windows, as there are official windows docker images hosted by <s>microsoft</s> docker (<a href="https://hub.docker.com/_/microsoft-windows-base-os-images">https://hub.docker.com/_/microsoft-windows-base-os-images</a>)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 08 Apr 2021 16:26:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I understand correctly, the windows base images only work on windows. It&#39;s really a very different technology, a case of microsoft having linux envy. It&#39;s not really much help for me.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (amarillion)</author>
		<pubDate>Thu, 08 Apr 2021 16:31:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, after reading it you&#39;re right. As the docker image will have to use underlying host system calls, one need a windows host to run windows images.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 08 Apr 2021 16:34:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah I just did a quick proof on my linux machine:</p><div class="source-code snippet"><div class="inner"><pre>docker run mcr.microsoft.com<span class="k3">/</span>windows<span class="k3">/</span>servercore:ltsc2019
ltsc2019: Pulling from windows<span class="k3">/</span>servercore
docker: no matching manifest <span class="k1">for</span> linux<span class="k3">/</span>amd64 in the manifest list entries.
See <span class="s">'docker run --help'</span>.
</pre></div></div><p>


Best to stick to linux, it&#39;s the greatest common divisor.</p><p>As for cross-compiling mac from linux, there is a project called &quot;darling&quot;, a bit like WINE but for Macs. Who knows, this could be useful here?</p><p><a href="https://stackoverflow.com/questions/39409082/cross-compiling-for-os-x-from-linux">https://stackoverflow.com/questions/39409082/cross-compiling-for-os-x-from-linux</a><br /><a href="https://github.com/darlinghq/darling">https://github.com/darlinghq/darling</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (amarillion)</author>
		<pubDate>Thu, 08 Apr 2021 16:38:14 +0000</pubDate>
	</item>
</rss>
