Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Building allegro games with docker

This thread is locked; no one can reply to it. rss feed Print
Building allegro games with docker
amarillion
Member #940
January 2001
avatar

I run a build server at home and recently I've been experimenting with Docker. Has anyone tried this? Docker makes it easy to bundle up a set of dependencies in a neat package.

The idea is that instead of having to install allegro plus all the other dependencies of your game, all you need to do is install docker, and then run something like:

docker run \
  -v `pwd`:/data 
  amarillion/alleg5-buildenv \
  make

In that command, docker pulls the image amarillion/alleg5-buildenv (which I prepared) from dockerhub, then maps the current directory to /data inside the container, and then runs the command make. As long as all the build tools and dependencies are packaged properly in the docker image, the build will work normally. The build artifacts will remain in the current directory as expected.

No matter how complex your build dependencies, they only need to be dockerized once and become available to everybody.

The source for building the docker image is on github:
https://github.com/amarillion/allegro-buildenv/blob/master/alleg5/Dockerfile

I've made the docker image public on dockerhub:
https://hub.docker.com/r/amarillion/alleg5-buildenv/

Potential applications of this technology:

  • Manage exotic build environments. Whether games are written in rust, D, pascal, java, all you need is docker. This should actually be a boon for TINS

  • Set up complicated builds, such as cross-platform compilation, and make it easy to use for everybody.

  • Manage conflicting versions of libraries on the same system

  • Test a build against different versions. For example, you could imagine running the same command against amarillion/alleg5-buildenv:5.2.2.0 and amarillion/alleg5-buildenv:latest to ensure that no compatibility errors have crept in

I'm working on an allegro4 image, to see if I can get some old games compiling that way. This is all a work in progress. Feedback is welcome.

SiegeLord
Member #7,827
October 2006
avatar

That seems pretty sweet, although I'm concerned that I'd still have to provide regular build instructions for people that refuse to install docker :P.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

amarillion
Member #940
January 2001
avatar

I don't expect this to storm the world and completely replace the need for build instructions. Also, this is mainly going to benefit Linux users.

But it's definitely going to be some help if you can say - either follow these 12 steps to install dependencies and build my allegro project. Or install docker and now it's down to only 3 steps.

Gideon Weems
Member #3,925
October 2003

Manage exotic build environments. Whether games are written in rust, D, pascal, java, all you need is docker. This should actually be a boon for TINS

Heck yes, this should be a boon for TINS. There have been hack-athons in the past where none of the entries compiled as-is. Please make entrants using non-C/C++ Allegro bindings aware of this potential solution (though to be honest, even many C/C++ entries don't compile).

Niunio
Member #1,975
March 2002
avatar

I think I should read this carefully and see how it works. I find it a bit confusing though. :-/

-----------------
Current projects: Allegro.pas | MinGRo

amarillion
Member #940
January 2001
avatar

Ok, here is a very practical example of how this is working. Suppose you want to compile AMGC2, an old game using allegro 4 + other dependencies, on linux.

Before, you had to set up

  • allegro 4

  • alfont

  • masking

  • dumb

Which takes some effort, and could mess up your current installation of allegro 5.

Now you can just use the docker image that I prepared, which contains all those dependencies in one place. You can compile it with:

#SelectExpand
1# Get amgc2 bundle 2wget http://members.allegro.cc/miran/archives/amgc2.tar.gz 3# Unpack it 4tar -zxvf amgc2.tar.gz 5cd amgc2 6# Run inside docker image: `make -C games/tetris` 7docker run \ 8 -v `pwd`:/data \ 9 -u `stat -c "%u:%g" .` \ 10 amarillion/alleg4-plus-buildenv \ 11 make -C games/tetris 12# Run inside docker image: `make -C src`. 13# I had to override LIBS setting of the makefile as it was missing -lX11. 14docker run \ 15 -v `pwd`:/data \ 16 -u `stat -c "%u:%g" .` \ 17 amarillion/alleg4-plus-buildenv \ 18 make -C src LIBS="-lmasking -lalfont -laldmb -ldumb -ldl `allegro-config --libs` -lX11" 19# Now you can run the game outside docker! 20./amgc2

Let me know if you can get this working too!

It took me a while to come up with a good example, because most game sources I find do not compile very cleanly (especially my own :( ). Even for this example I had to tweak the compilation, overriding the LIBS variable. Nevertheless, I think this example illustrates the potential.

So far I've prepared the following docker images:

amarillion/alleg5-buildenv

  • allegro 5, release, debug and static builds

amarillion/alleg5-plus-buildenv

  • same as above, but also includes libcurl-dev and cppunit

amarillion/alleg4-buildenv

  • allegro 4, release and debug builds

amarillion/alleg4-plus-buildenv

  • same as above, but with alfont, dumb and masking add-ons

amarillion/android

  • still WIP - the intention is to prepare all the dependencies needed for compiling allegro for android

Gideon Weems
Member #3,925
October 2003

Holy heck, that was almost too easy--and I've never even touched docker before. Thank you for going through the trouble of doing this.

Miran's Tetris clone isn't too shabby, either. The UI is snazzy.

video

Go to: