Skip to content
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

Create Docker container setup for the project #51

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions alignment.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# syntax=docker/dockerfile:1
FROM ubuntu:focal
ARG ENABLE_SDL2
ENV DEBIAN_FRONTEND=noninteractive

RUN <<EOF
# build SDL2
Ryu1845 marked this conversation as resolved.
Show resolved Hide resolved
set -ex # display used commands and exit if any of the lines fail
sed -i -e 's#http://archive.ubuntu.com/ubuntu#http://mirror.enzu.com/ubuntu/#' /etc/apt/sources.list # change mirror because the default one is dying on me
apt-get update -y
apt install -y git build-essential
if [ -n "$ENABLE_SDL2" ];then
# build SDL2
# define installation directory
mkdir SDL2
# clone SDL
git clone https://github.com/libsdl-org/SDL.git -b SDL2 && cd SDL && git checkout tags/release-2.26.2
# build
mkdir build && cd build
../configure --prefix=/SDL2 --enable-video-offscreen && make && make install
fi
EOF

RUN <<EOF
# build Irrlicht
set -ex
# install missing dependency
apt-get update -y
apt install -y zlib1g-dev libjpeg-dev libpng-dev libxi-dev cmake libglu1-mesa-dev freeglut3-dev mesa-common-dev
# clone irrlicht
git clone https://github.com/EleutherAI/irrlicht && cd irrlicht
# define lib paths
if [ -n "$ENABLE_SDL2" ];then
cmake . -DBUILD_SHARED_LIBS=OFF -DBUILD_HEADLESS=1 -DSDL2_DIR=/SDL2/lib/cmake/SDL2
else
cmake . -DBUILD_SHARED_LIBS=OFF -DBUILD_HEADLESS=1
fi
# build
make -j8
EOF

RUN <<EOF
# build minetest
set -ex
# install dependencies
apt-get update -y
apt install -y libzmqpp-dev libgmp3-dev protobuf-compiler libprotobuf-dev libzstd-dev libfreetype-dev libsqlite3-dev
# clone minetest fork
git clone https://github.com/EleutherAI/minetest
git clone --depth 1 https://github.com/minetest/minetest_game.git minetest/games/minetest_game
cd minetest
git checkout develop
# compile protobuf
cd hacking_testing
./compile_proto.sh
cd ..
# define lib paths
export IRRLICHT_REPO=/irrlicht
# build
if [ -n "$ENABLE_SDL2" ];then
cmake . -B build_headless_render -DCMAKE_BUILD_TYPE=Debug -DSDL2_DIR=/SDL2/lib/cmake/SDL2 -DIRRLICHTMT_BUILD_DIR=$IRRLICHT_REPO -DBUILD_HEADLESS=1 -DENABLE_SOUND=OFF -DRUN_IN_PLACE=1
else
cmake . -B build_headless_render -DCMAKE_BUILD_TYPE=Debug -DIRRLICHTMT_BUILD_DIR=$IRRLICHT_REPO -DBUILD_HEADLESS=1 -DENABLE_SOUND=OFF -DRUN_IN_PLACE=1
fi
cmake --build build_headless_render
EOF

RUN <<EOF
# Install Python packages and Xvfb
set -ex
apt-get install -y python3 python3-pip xvfb
pip install numpy matplotlib gym zmq protobuf
EOF

WORKDIR minetest
EXPOSE 30000
CMD ["hacking_testing/server.sh"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this got me wondering, will we need a separate Dockerfile for clients?
If this is specifically for running a server then we actually don't need to build with SDL at all.
On the other hand, I guess initially we will have server and client(s) running on the same machine, maybe even the same docker container..
So in case of a single Dockerfile it probably would make sense to not hardcode the entry point here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMD is just a default, we could make a cli with support for the different options as an entry point maybe?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that sounds good. even simpler: optionally pass a any script that is being used as entrypoint