try slimming down docker image

This commit is contained in:
Jake Jarvis 2021-11-18 10:11:07 -05:00
parent 09e562c93e
commit ab6f8369f3
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
3 changed files with 20 additions and 24 deletions

View File

@ -9,19 +9,24 @@ ARG DEBIAN_FRONTEND=noninteractive
# corrects the time inside the Windows VM, if tzdata is installed below # corrects the time inside the Windows VM, if tzdata is installed below
ENV TZ=America/New_York ENV TZ=America/New_York
RUN apt-get update \ # do everything as an unprivileged user :)
&& apt-get -y upgrade \ RUN useradd -m vm
&& apt-get -y --no-install-recommends install \
ca-certificates \
tzdata \
qemu-system-x86 \
qemu-utils \
ruby \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# copy boot script and Windows HDD (must be at ./container/hdd/hdd.img)
COPY container/bin/boot.rb /usr/local/bin/boot-vm
COPY --chown=vm container/hdd/hdd.img /home/vm/hdd.img
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
tzdata \
ruby \
qemu-system-x86 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& chmod +x /usr/local/bin/boot-vm \
&& ls -lah /home/vm \
# make sure everything's okay so far # make sure everything's okay so far
RUN qemu-system-i386 --version \ && qemu-system-i386 --version \
&& ruby --version && ruby --version
# ---- # ----
@ -38,17 +43,6 @@ RUN qemu-system-i386 --version \
# EXPOSE 80 # EXPOSE 80
# ---- # ----
# do everything as an unprivileged user :)
RUN useradd -m vm
# copy boot script and Windows HDD (must be at ./container/hdd/hdd.img)
COPY container/bin/boot.rb /usr/local/bin/boot-vm
COPY --chown=vm container/hdd/hdd.img /home/vm/hdd.img
# make double sure the boot script is executable & the hard drive was copied
RUN chmod +x /usr/local/bin/boot-vm \
&& ls -lah /home/vm
# bye bye root <3 # bye bye root <3
USER vm USER vm
WORKDIR /home/vm WORKDIR /home/vm

View File

@ -12,7 +12,7 @@ test -f "$YOU_ARE_HERE"/container/hdd/hdd.img
doctl registry login doctl registry login
docker build -t registry.digitalocean.com/jakejarvis/y2k:latest --squash --no-cache "$YOU_ARE_HERE" docker build -t registry.digitalocean.com/jakejarvis/y2k:latest --squash --no-cache "$YOU_ARE_HERE"
# docker push registry.digitalocean.com/jakejarvis/y2k:latest docker push registry.digitalocean.com/jakejarvis/y2k:latest
# on DigitalOcean, old tags need to be purged manually: # on DigitalOcean, old tags need to be purged manually:
# doctl registry garbage-collection start --force --include-untagged-manifests # doctl registry garbage-collection start --force --include-untagged-manifests

View File

@ -38,6 +38,8 @@ docker version
## https://github.com/moby/moby/issues/4250 ## https://github.com/moby/moby/issues/4250
sed -i 's/\(GRUB_CMDLINE_LINUX="\)"/\1cgroup_enable=memory swapaccount=1"/' /etc/default/grub sed -i 's/\(GRUB_CMDLINE_LINUX="\)"/\1cgroup_enable=memory swapaccount=1"/' /etc/default/grub
update-grub update-grub
## enable `docker build --squash`
echo "{ \"experimental\": true }" > /etc/docker/daemon.json
#### install websocketd #### #### install websocketd ####
## https://github.com/joewalnes/websocketd/releases ## https://github.com/joewalnes/websocketd/releases