Shrink image by merging game fetch/extract into one layer
The downloaded zips and their extracted contents lived in separate RUN layers, so the zips never actually left the image despite a later rm -rf /tmp/apps layer. unzip/smbclient were also left installed after only being needed at build time. Merging fetch, extract, cleanup, and package purge into a single RUN drops the image from 2.31GB to 1.6GB. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NiNnj78HGx1KWyCCo39HSz
This commit is contained in:
+19
-15
@@ -1,28 +1,32 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
FROM ich777/novnc-baseimage
|
FROM ich777/novnc-baseimage
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get -y install --no-install-recommends dosbox unzip alsa-utils smbclient && \
|
|
||||||
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"
|
|
||||||
ENV DISPLAY_NUM=99
|
ENV DISPLAY_NUM=99
|
||||||
ENV DISPLAY=:${DISPLAY_NUM}
|
ENV DISPLAY=:${DISPLAY_NUM}
|
||||||
RUN touch /root/.Xauthority
|
|
||||||
|
|
||||||
ENV GAMES_HOME=/opt/games
|
ENV GAMES_HOME=/opt/games
|
||||||
ENV SCRIPTS_HOME=/opt/scripts
|
ENV SCRIPTS_HOME=/opt/scripts
|
||||||
ENV PATH=${PATH}:${SCRIPTS_HOME}
|
ENV PATH=${PATH}:${SCRIPTS_HOME}
|
||||||
|
|
||||||
ADD scripts ${SCRIPTS_HOME}
|
# unzip/smbclient are only needed to fetch and extract the games below, so they're
|
||||||
WORKDIR /tmp/apps
|
# purged again in this same layer instead of being left in the final image.
|
||||||
RUN smbget -au smb://vlda-01/software/Games/dosbox/stuntcar.zip
|
RUN apt-get update && \
|
||||||
RUN smbget -au smb://vlda-01/software/Games/dosbox/t7g.zip
|
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 mkdir -p ${GAMES_HOME}
|
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 unzip -o -d ${GAMES_HOME} "/tmp/apps/*.zip"
|
RUN touch /root/.Xauthority
|
||||||
RUN rm -rf /tmp/apps
|
|
||||||
RUN cd ~
|
ADD scripts ${SCRIPTS_HOME}
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
EXPOSE 60${DISPLAY_NUM}
|
EXPOSE 60${DISPLAY_NUM}
|
||||||
EXPOSE 5900
|
EXPOSE 5900
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- Reduce image size of `jayfield/dosbox-novnc` (currently ~2.3GB).
|
- ~~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.
|
||||||
|
|||||||
Reference in New Issue
Block a user