diff --git a/Dockerfile b/Dockerfile index 8f9956f..2ebb264 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,24 +7,18 @@ ENV GAMES_HOME=/opt/games ENV SCRIPTS_HOME=/opt/scripts ENV PATH=${PATH}:${SCRIPTS_HOME} -# unzip/smbclient are only needed to fetch and extract the games below, so they're -# purged again in this same layer instead of being left in the final image. +# unzip/smbclient are needed at runtime now too: the games are no longer baked into the +# image, fetch_games.sh pulls them into the ${GAMES_HOME} volume on first container start. RUN apt-get update && \ apt-get -y install --no-install-recommends dosbox alsa-utils unzip smbclient && \ - mkdir -p ${GAMES_HOME} /tmp/apps && \ - cd /tmp/apps && \ - smbget -au smb://vlda-01/software/Games/dosbox/stuntcar.zip && \ - smbget -au smb://vlda-01/software/Games/dosbox/t7g.zip && \ - unzip -o -d ${GAMES_HOME} "*.zip" && \ - cd / && \ - rm -rf /tmp/apps && \ - apt-get -y purge unzip smbclient && \ - apt-get -y autoremove && \ rm -rf /var/lib/apt/lists/* RUN openssl req -x509 -nodes -newkey rsa:2048 -keyout /tmp/novnc.key -out /tmp/novnc.pem -days 3650 -subj "/C=US/ST=NY/L=NY/O=NY/OU=NY/CN=NY emailAddress=email@example.com" RUN touch /root/.Xauthority +RUN mkdir -p ${GAMES_HOME} +VOLUME ${GAMES_HOME} + ADD scripts ${SCRIPTS_HOME} WORKDIR / diff --git a/TODO.md b/TODO.md index fdb4e41..3b6ff0f 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,12 @@ # TODO -- ~~Reduce image size of `jayfield/dosbox-novnc` (currently ~2.3GB).~~ Done: merged the - game download/extract steps and the unzip/smbclient install into a single layer (so the - downloaded zips and the packages only needed to extract them no longer persist in the - final image). 2.31GB -> 1.6GB. +- ~~Reduce image size of `jayfield/dosbox-novnc` (currently ~2.3GB).~~ Done in two steps: + 1. Merged the game download/extract steps and the unzip/smbclient install into a single + layer (so the downloaded zips and the packages only needed to extract them no longer + persist in the final image). 2.31GB -> 1.6GB. + 2. Stopped baking the games into the image at all (927MB of that was just t7g's two CD + ISOs). `scripts/fetch_games.sh` now downloads them from the SMB share into + `${GAMES_HOME}` (`/opt/games`) on first container start instead, skipping the fetch if + already present. `run.sh` mounts a named volume (`dosbox-games`) so the games persist + across `--rm` restarts. 1.6GB -> ~690MB. Container now needs network access to + `vlda-01` at runtime (not just build time) for the first start. diff --git a/run.sh b/run.sh index bbe6a45..7b91fba 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ #/bin/bash -docker run --name dosbox-novnc -d --rm --net bridge -e SCREEN_W=1536 -e SCREEN_H=960 --device /dev/snd jayfield/dosbox-novnc +docker run --name dosbox-novnc -d --rm --net bridge -e SCREEN_W=1536 -e SCREEN_H=960 --device /dev/snd -v dosbox-games:/opt/games jayfield/dosbox-novnc diff --git a/scripts/fetch_games.sh b/scripts/fetch_games.sh new file mode 100755 index 0000000..ca44bc7 --- /dev/null +++ b/scripts/fetch_games.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -e + +SMB_BASE="smb://vlda-01/software/Games/dosbox" +GAME_ZIPS="stuntcar.zip t7g.zip" + +if [ -n "$(ls -A "${GAMES_HOME}" 2>/dev/null)" ]; then + echo "Games already present in ${GAMES_HOME}, skipping fetch" + exit 0 +fi + +echo "Fetching games into ${GAMES_HOME}..." +TMPDIR=$(mktemp -d) +trap 'rm -rf "${TMPDIR}"' EXIT + +cd "${TMPDIR}" +for zip in ${GAME_ZIPS}; do + smbget -au "${SMB_BASE}/${zip}" +done +unzip -o -d "${GAMES_HOME}" "*.zip" diff --git a/scripts/server.sh b/scripts/server.sh index 95b588a..177e920 100755 --- a/scripts/server.sh +++ b/scripts/server.sh @@ -4,6 +4,8 @@ set -x RFB_PORT=59${DISPLAY_NUM} NOVNC_PORT=80${DISPLAY_NUM} +${SCRIPTS_HOME}/fetch_games.sh + echo Display at ${DISPLAY} with ${SCREEN_W}x${SCREEN_H}x24 Xvnc ${DISPLAY} -geometry ${SCREEN_W}x${SCREEN_H} -depth 24 +xinerama -securitytypes none >/var/log/xvfb.log & fluxbox &