├── Dockerfile ├── README.md ├── entrypoint.sh └── registry_update.reg /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:eoan 2 | 3 | RUN dpkg --add-architecture i386 4 | 5 | RUN apt-get update -y 6 | 7 | RUN apt-get install -y --no-install-recommends winetricks xvfb openssh-server inotify-tools x11vnc ca-certificates cabextract net-tools 8 | 9 | RUN apt-get install -y --install-recommends wine-stable wine32 10 | 11 | RUN rm -rf /var/lib/apt/lists/* 12 | 13 | EXPOSE 5900 14 | 15 | COPY entrypoint.sh /usr/local/bin/ 16 | 17 | RUN chmod 755 /usr/local/bin/entrypoint.sh 18 | 19 | RUN useradd -ms /bin/bash aoc 20 | 21 | USER aoc 22 | 23 | ENV INSTALL /home/aoc 24 | ENV WINEPREFIX $INSTALL/wine 25 | ENV WINEARCH win32 26 | ENV DISPLAY :0.0 27 | ENV MSPATH $WINEPREFIX/drive_c/Program Files (x86)/Microsoft Games 28 | ENV AOCPATH $MSPATH/Age of Empires II 29 | ENV WKPATH $AOCPATH/Games/WololoKingdoms 30 | 31 | WORKDIR $INSTALL 32 | 33 | RUN wineboot -u && winetricks directplay 34 | 35 | COPY registry_update.reg $INSTALL 36 | 37 | RUN mkdir -p "$MSPATH" 38 | 39 | RUN ln -s /aoc "$AOCPATH" 40 | 41 | ENTRYPOINT ["entrypoint.sh"] 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aoc-docker 2 | 3 | Run Age of Empires II (WK) headlessly in docker. 4 | 5 | ## Build 6 | 7 | `docker build -t siegeengineers/aoc-headless:1.0 .` 8 | 9 | ## Run 10 | 11 | Prerequisites: 12 | - Set up a directory to drop recorded games (`$(pwd)/dropbox` in the example). 13 | - Have a copy of Age of Empires II available on the docker host. 14 | 15 | ``` 16 | docker run \ 17 | --name aoc \ 18 | --mount type=bind,source="$(pwd)/dropbox",target=/dropbox \ 19 | --mount type=bind,source="$(pwd)/Age of Empires II",target=/aoc \ 20 | siegeengineers/aoc-headless:1.0 21 | ``` 22 | 23 | # Play 24 | 25 | Place a recorded game file in the dropbox directory. The log should look something like this: 26 | 27 | ``` 28 | [11/15/19 22:50:37] aoc version 5.8.1 29 | [11/15/19 22:50:37] waiting for files ... 30 | [11/15/19 22:50:43] test.mgz received 31 | [11/15/19 22:50:44] test.mgz playback started 32 | ``` -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | log () { 4 | echo "[$(date +"%x %X")] $1" 5 | } 6 | 7 | # for reasons unknown, this command can not be run in the build (this just accepts the EULA) 8 | wine regedit $HOME/registry_update.reg 9 | 10 | # set up virtual display 11 | Xvfb :0 -screen 0 800x600x8 > $HOME/xvfb.log 2>&1 & 12 | 13 | # set up VNC server for debug purposes 14 | if [ -n $VNC_PASSWORD ]; then 15 | x11vnc -display :0 -noxrecord -noxfixes -noxdamage -forever -passwd $VNC_PASSWORD > $HOME/xvnc.log 2>&1 & 16 | fi 17 | 18 | # clear out dropbox 19 | rm -f /dropbox/* 20 | 21 | # wait for recorded game files to appear in the dropbox 22 | log "aoc version $(cat "$WKPATH/version.ini")" 23 | log "waiting for files ..." 24 | 25 | inotifywait -q -m /dropbox -e create -e moved_to | 26 | while read path action file; do 27 | log "$file received" 28 | 29 | # kill aoc if it's already running 30 | if [ -n "$PID" ]; then kill $PID; fi 31 | rm -f $HOME/aoc.log 32 | 33 | # kill debug/console (remnant of crash) 34 | ps -ef | grep 'winedbg' | grep -v grep | awk '{print $2}' | xargs -r kill -9 35 | ps -ef | grep 'wineconsole' | grep -v grep | awk '{print $2}' | xargs -r kill -9 36 | 37 | # move incoming file 38 | mv "/dropbox/$file" "$WKPATH/SaveGame/$HOSTNAME.mgz" 39 | 40 | # launch aoc 41 | WINEDEBUG=+loaddll wine "$AOCPATH/age2_x1/WK.exe" '"'$HOSTNAME.mgz'"' NOSOUND NODXCHECK > $HOME/aoc.log 2>&1 & 42 | PID=$! 43 | 44 | # wait for rec to load 45 | SECONDS=0 46 | SUCCESS=0 47 | while [ $SECONDS -le 5 ]; do 48 | grep -q -I SPI_SETSHOWIMEUI $HOME/aoc.log 49 | if [ $? -eq 0 ]; then SUCCESS=1; break; fi 50 | sleep 1 51 | ((SECONDS++)) 52 | done 53 | 54 | if [ $SUCCESS -eq 1 ]; then 55 | sleep 2 56 | log "$file playback started" 57 | # run specified additional commands 58 | eval "$@" 59 | else 60 | log "$file failed to play" 61 | fi 62 | done 63 | -------------------------------------------------------------------------------- /registry_update.reg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiegeEngineers/aoc-docker/74473ff29c314e062f2a9a689c6c4bd1c59d1d53/registry_update.reg --------------------------------------------------------------------------------