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
ENV TZ=America/New_York
RUN apt-get update \
&& apt-get -y upgrade \
&& 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/*
# do everything as an unprivileged user :)
RUN useradd -m vm
# make sure everything's okay so far
RUN qemu-system-i386 --version \
# 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
&& qemu-system-i386 --version \
&& ruby --version
# ----
@ -38,17 +43,6 @@ RUN qemu-system-i386 --version \
# 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
USER vm
WORKDIR /home/vm

View File

@ -12,7 +12,7 @@ test -f "$YOU_ARE_HERE"/container/hdd/hdd.img
doctl registry login
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:
# doctl registry garbage-collection start --force --include-untagged-manifests

View File

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