white-rabbit-dfplex/dfplex

docker support

lizelive opened this issue · 12 comments

I am trying to put this into a docker container so i can play with my friends and other people can play with their friends.

FROM ubuntu:16.04

# Pre install
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update

RUN apt-get -y install --no-install-recommends libsdl1.2debian libsdl-image1.2 libsdl-ttf2.0-0 libopenal1 libsndfile1 libgtk2.0-0 libncursesw5 libglu1 unzip curl libboost1.58-all-dev bzip2

# RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

ENV DEBIAN_FRONTEND=dialog


ADD http://www.bay12games.com/dwarves/df_44_12_linux.tar.bz2 df.tar.bz2
ADD https://github.com/white-rabbit-dfplex/dfplex/releases/download/v0.1-dfplex/dfplex-v0.1-linux64.zip dfplex.zip
ADD https://github.com/DFHack/dfhack/releases/download/0.44.12-r3/dfhack-0.44.12-r3-Linux-64-gcc-4.8.tar.bz2 dfhack.tar.bz2
RUN tar xfj df.tar.bz2 && rm df.tar.bz2
RUN tar xfj dfhack.tar.bz2 -C /df_linux && rm dfhack.tar.bz2
RUN unzip dfplex.zip && rm dfplex.zip && cp -r dfplex-v0.1-linux64/* df_linux/ && rm -rf dfplex-v0.1-linux64/
RUN echo "\n[PRINT_MODE:TEXT]\n[INTRO:NO]\n[TRUETYPE:NO]\n[SOUND:NO]" >> /df_linux/data/init/init.txt
RUN echo "\n[BIRTH_CITIZEN:A_D:D_D]\n[MOOD_BUILDING_CLAIMED:A_D:D_D]\n[ARTIFACT_BEGUN:A_D:D_D]" >> /df_linux/data/init/announcements.txt
EXPOSE 8000
EXPOSE 5000

#RUN df_linux/df -gen 1 RANDOM

#ENTRYPOINT [ "df_linux/df", "-gen", "1", "RANDOM" ]

ENTRYPOINT ["df_linux/dfhack"]

run like

docker build --pull --rm -f "Dockerfile" -t dfplex:latest "."
 docker run --security-opt seccomp=unconfined --rm -it  -p 5000:5000 -p 8000:8000/tcp dfplex:latest

but it fails with this error

loading plugin dfplex
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /df_linux/hack/plugins/dfplex.plug.so)
Can't load plugin dfplex
Can't load plugin dfplex
Starting the TCP listener.
Starting dfhack.init thread.
Starting DF input capture thread.
Listening on port 5000
DFHack is running.
Invoking: enable dfplex
Cannot enable plugin: dfplex

i don't know much about df or what enviroment dfplex expects but i feel we are quite close

Hi,

as far as I'm concerned, I managed to made it work by installing build_essential and removing the libs libstdc++.so.6 and libgcc_s.so.1 from the "libs" folder in dwarf fortress.

I don't know much about docker, but the error looks to me like perhaps build-essential needs to be installed? If you can figure this out I'll gladly accept a docker PR.

I've modified the Dockerfile @lizelive posted above into this:

FROM ubuntu:20.04

# Pre install
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update

RUN apt-get -y install --no-install-recommends build-essential libsdl1.2debian libsdl-image1.2 libsdl-ttf2.0-0 libopenal1 libsndfile1 libgtk2.0-0 libncursesw5 libglu1 unzip curl libboost-all-dev bzip2

ENV DEBIAN_FRONTEND=dialog

ADD http://www.bay12games.com/dwarves/df_47_04_linux.tar.bz2 df.tar.bz2
ADD https://github.com/white-rabbit-dfplex/dfplex/releases/download/v0.2.1-dfplex/dfplex-v0.2.1-linux64.zip dfplex.zip
ADD https://github.com/DFHack/dfhack/releases/download/0.47.04-r1/dfhack-0.47.04-r1-Linux-64bit-gcc-4.8.tar.bz2 dfhack.tar.bz2
RUN tar xfj df.tar.bz2 && rm df.tar.bz2
RUN tar xfj dfhack.tar.bz2 -C /df_linux && rm dfhack.tar.bz2
RUN unzip dfplex.zip && rm dfplex.zip && cp -r dfplex-v0.2.1-Linux64/* df_linux/ && rm -rf dfplex-v0.2.1-Linux64/
RUN echo "\n[PRINT_MODE:TEXT]\n[INTRO:NO]\n[TRUETYPE:NO]\n[SOUND:NO]" >> /df_linux/data/init/init.txt
RUN echo "\n[BIRTH_CITIZEN:A_D:D_D]\n[MOOD_BUILDING_CLAIMED:A_D:D_D]\n[ARTIFACT_BEGUN:A_D:D_D]" >> /df_linux/data/init/announcements.txt
EXPOSE 8000
EXPOSE 5000
EXPOSE 1234

ENTRYPOINT ["df_linux/dfhack"]

These are the updates:

  • bumped the Ubuntu version
  • bumped the versions of DF, DFHack, DFPlex
  • Added build-essentials
  • Changed libboost1.58-all-dev to libboost-all-dev
  • Added EXPOSE rule for port 1234

I'm able to get this to run!

@jsisson Did you do anything special to get networking working on your build? I'm using your Dockerfile and while it builds and runs, I'm not able to access it through the server IP.

@jsisson Did you do anything special to get networking working on your build? I'm using your Dockerfile and while it builds and runs, I'm not able to access it through the server IP.

NVM, I added --network host and it worked.

Although, I strongly recommend against running this docker container with the -d flag in Docker. Seems to create a massive file that grows until you are out of system space. I have gotten around this by using screen to run the container, but the reason for this whole thing is unknown.

Fascinating. Thanks for all your work, everyone! Would anybody be interested in making a PR?

created pr
#19

was working on getting it to compile in the docker image but have beeiany idea why i get the ett[ 21%] Built target lua
[ 21%] Building CXX object depends/protobuf/CMakeFiles/protobuf.dir/google/protobuf/io/zero_copy_stream_impl_lite.cc.o
[ 21%] Linking CXX shared library libprotobuf.so
[ 21%] Built target protobuf
make: *** [Makefile:152: all] Error 2
installation failed.
The command '/bin/sh -c cd dfhack && ./plugins/dfplex/devel/df-assemble.sh' returned a non-zero code: 4

any thoughts on how to debug it?

I assume it has something to do with
Can't locate XML/LibXML.pm in @inc (you may need to install the XML::LibXML module) (@inc contains: /dfhack/library/xml /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /dfhack/library/xml/codegen.pl line 14.
BEGIN failed--compilation aborted at /dfhack/library/xml/codegen.pl line 14.
make[2]: *** [library/CMakeFiles/generate_headers.dir/build.make:120: ../library/include/df/codegen.out.xml] Error 2
make[1]: *** [CMakeFiles/Makefile2:1012: library/CMakeFiles/generate_headers.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I'm trying to fiddle around and get docker-compose to work but I'm not getting build errors.

I'm not sure where DF saves its data, but I don't see any "VOLUME" directives in the Dockerfile.
Would be best to expose this so world data persists.