From 982998f969d2bf4e29769aaa3e2e78eaf3722c78 Mon Sep 17 00:00:00 2001 From: Timo Reichl Date: Wed, 3 Jan 2024 17:20:46 +0100 Subject: [PATCH] improve docker build Signed-off-by: Timo Reichl --- src/Dockerfile | 89 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/src/Dockerfile b/src/Dockerfile index d79ad80..23b56b6 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,46 +1,73 @@ -FROM kasmweb/core-ubuntu-bionic:1.10.0 -USER root +######### Config Arguments ########### +ARG NERD_FONTS_ARCHIVE="Hack.zip" +ARG NERD_FONTS_VERSION="v2.1.0" -ENV HOME /home/kasm-default-profile -ENV STARTUPDIR /dockerstartup -ENV INST_SCRIPTS $STARTUPDIR/install -WORKDIR $HOME +######### Temporary Files Layer ########### +FROM busybox:1.36.1-glibc AS temp-files -######### Customize Container Here ########### +# Make config arguments from above known in this layer +ARG NERD_FONTS_ARCHIVE +ARG NERD_FONTS_VERSION -RUN apt update -RUN apt -y upgrade -RUN apt -y install openvpn -RUN apt -y install unzip +# Local files +COPY assets/mr-robot-wallpaper.png /copy/configs/usr/share/extra/backgrounds/bg_default.png +COPY config/starship.toml /copy/configs/root/.config/starship.toml +COPY config/terminator.toml /copy/configs/root/.config/terminator/config -# Change Background to sth cool -COPY assets/mr-robot-wallpaper.png /usr/share/extra/backgrounds/bg_default.png +# Nerd fonts (remote) +ADD https://github.com/ryanoasis/nerd-fonts/releases/download/${NERD_FONTS_VERSION}/${NERD_FONTS_ARCHIVE} /tmp/${NERD_FONTS_ARCHIVE} +RUN mkdir -p /copy/configs/usr/local/share/fonts +RUN unzip /tmp/${NERD_FONTS_ARCHIVE} -d /copy/configs/usr/local/share/fonts -# Install Starship -RUN wget https://starship.rs/install.sh -RUN chmod +x install.sh -RUN ./install.sh -y +# Starship (remote) +ADD https://starship.rs/install.sh /copy/starship/install.sh +RUN chmod +x /copy/starship/install.sh -# Add Starship to bashrc -RUN echo 'eval "$(starship init bash)"' >> .bashrc -# Add Starship Theme -COPY config/starship.toml .config/starship.toml +######### KASM Container Here ########### -# Install Hack Nerd Font -RUN wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Hack.zip -RUN unzip Hack.zip -d /usr/local/share/fonts +FROM kasmweb/core-ubuntu-bionic:1.10.0 +USER root + +ENV HOME /home/kasm-default-profile +ENV STARTUPDIR /dockerstartup +ENV INST_SCRIPTS $STARTUPDIR/install +WORKDIR $HOME -# Install Terminator -RUN apt -y install terminator -# Set up Nerd font in Terminator -RUN mkdir .config/terminator -COPY config/terminator.toml .config/terminator/config +######### Customize Container Here ########### -# Install XFCE Dark Theme -RUN apt install numix-gtk-theme +# Install packages and configure the container +RUN --mount=type=bind,from=temp-files,source=/copy,target=/tmp/copy \ + # Make APT/DPKG aware that we're building an image, so no user interaction is possible + # (only for this specific shell) + export DEBIAN_FRONTEND=noninteractive && \ + # Fix locales when installing packages + # (only for this specific shell) + export LC_ALL=C \ + && \ + # Upgrade the system + apt-get update && \ + apt-get -y full-upgrade \ + && \ + # Install packages + apt-get -y install --no-install-recommends \ + numix-gtk-theme \ + openvpn \ + terminator \ + && \ + # Clear APT caches + apt-get -y clean && \ + rm -rf /var/lib/apt/lists/* \ + && \ + # Copy config files from mounted /tmp/copy/configs directory + mkdir -p root/.config/terminator && \ + cp -R /tmp/copy/configs/* / && \ + # Install Starship + /tmp/copy/starship/install.sh -y && \ + # Configure Bash for Starship + echo 'eval "$(starship init bash)"' >> .bashrc ######### End Customizations ###########