diff --git a/plasma/Dockerfile b/plasma/Dockerfile index 131bd9e..49b0ccd 100644 --- a/plasma/Dockerfile +++ b/plasma/Dockerfile @@ -1,31 +1,57 @@ # syntax = docker/dockerfile:1 -FROM myvnc/arch/base +FROM quay.io/archlinux/archlinux:base-devel USER root -# X session environment variable -ENV STARTXBIN=startplasma-x11 +# Build ARG for additional packages to install (eg, openssh) +ARG addpkg + +# Build ARG: use "root" for debugging +ARG debug + +# Copy mirrorlist +COPY mirrorlist /etc/pacman.d/mirrorlist + +# Copy app folder +COPY app /app # Install packages RUN --mount=type=cache,sharing=locked,target=/var/cache/pacman \ - pacman -Syu --ask 4 --needed \ - tigervnc \ - cuda openssh vim pacman-contrib rsync git \ - plasma konsole kate dolphin kompare kcalc \ - jack2 ttf-dejavu \ - firefox firefox-decentraleyes firefox-ublock-origin \ - torbrowser-launcher \ - shotwell ffmpegthumbs ark okular \ - remmina libvncserver \ + pacman-key --init \ + && sed -i '/ParallelDownloads/c ParallelDownloads = 10' /etc/pacman.conf \ + && pacman -Sy --ask 4 archlinux-keyring \ + && pacman -Su --ask 4 --needed ${addpkg} \ + sudo bash bash-completion \ + tigervnc \ + cuda openssh vim pacman-contrib rsync git \ + plasma konsole kate dolphin kompare kcalc \ + jack2 ttf-dejavu \ + firefox firefox-decentraleyes firefox-ublock-origin \ + torbrowser-launcher \ + shotwell ffmpegthumbs ark okular \ + remmina libvncserver \ && pacman -Scc --ask 4 \ - && printf '%s\n' 'Cmnd_Alias MISCELLANEOUS = /usr/bin/pacman' >/etc/sudoers.d/01-MISCELLANEOUS + && useradd --create-home --gid users --shell /usr/bin/bash user \ + && printf '%s\n' 'user ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman' \ + 'Defaults lecture = never' >/etc/sudoers.d/zz-DOCKER \ + && passwd -l root >/dev/null 2>&1 \ + && mkdir -p /app/nginx /app/logs \ + && chown -R user:users /app + +# Default environment +USER ${debug:-user} +WORKDIR /home/user +ENV HOME=/home/user +ENV DISPLAY=:0 +ENV SHELL=/usr/bin/bash +ENV PS1="[\u@\h \W \$?]\$ " + +# X session environment variable +ENV STARTXBIN=startplasma-x11 # configure nvidia container runtime # https://github.com/NVIDIA/nvidia-container-runtime#environment-variables-oci-spec ENV NVIDIA_VISIBLE_DEVICES=all ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility -# Tigervnc -COPY *.sh /app/init.d/ - -# Reset user home directory -USER user +# Docker entrypoint +ENTRYPOINT ["/app/entrypoint"] diff --git a/plasma/app/entrypoint b/plasma/app/entrypoint new file mode 100755 index 0000000..b1ea375 --- /dev/null +++ b/plasma/app/entrypoint @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Export all variables +set -a + +# Abort if an error is encountered +set -e + +# SSH config +if [ -f ~/.ssh/id_ed25519 ] +then + chmod 0600 ~/.ssh/id_ed25519 +fi + +# Run all scripts in init folder +for file in /app/init.d/*.sh +do + /usr/bin/bash -c ${file} >>/app/logs/$(echo ${file} | sed 's|/app/init.d/||;s|\.sh$||').log +done + +# Read cli parameters +exec "${@}" & + +# Monitor log +tail -f /app/logs/*.log diff --git a/plasma/app/init.d/01-init.sh b/plasma/app/init.d/01-init.sh new file mode 100755 index 0000000..20bf29d --- /dev/null +++ b/plasma/app/init.d/01-init.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# Create base directories +for dir in ssh config/tigervnc +do + [ -d ~/.${dir} ] || mkdir -p ~/.${dir} +done diff --git a/plasma/10-tigervnc.sh b/plasma/app/init.d/10-tigervnc.sh similarity index 100% rename from plasma/10-tigervnc.sh rename to plasma/app/init.d/10-tigervnc.sh diff --git a/plasma/90-tigervnc.sh b/plasma/app/init.d/90-tigervnc.sh similarity index 100% rename from plasma/90-tigervnc.sh rename to plasma/app/init.d/90-tigervnc.sh diff --git a/plasma/build b/plasma/build new file mode 100755 index 0000000..45eeffb --- /dev/null +++ b/plasma/build @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Docker build +# Optional buildtag, addpkg +# addpkg=openssh \ +set -e + +## Fetch latest mirrorlist +curl --fail --silent https://git.myvelabs.com/lab/archlinux/raw/branch/master/mirrorlist -o mirrorlist + +DOCKER_BUILDKIT=1 \ +docker build . \ + --build-arg addpkg=${addpkg:-""} \ + --build-arg debug=${debug:-""} \ + --tag ${buildtag:-myvnc/arch/plasma} +rm mirrorlist