From 904f53b0e0c7badbe5fd631ef860867ca2b55aec Mon Sep 17 00:00:00 2001 From: bretello Date: Thu, 28 Dec 2023 17:57:44 +0100 Subject: [PATCH] dockerfile: cleanup/improvements --- Dockerfile | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 259c567..5589b8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,39 +20,30 @@ RUN pacman --noconfirm -Syu && pacman --noconfirm -Sy \ # Enable colors in pacman RUN sed -i 's/^#Color/Color/' /etc/pacman.conf -FROM base as yay_builder +FROM base as builder -# prepare nobody makepkg user -RUN mkdir /home/build && \ - chgrp nobody /home/build && \ - chmod g+ws /home/build && \ - setfacl -m u::rwx,g::rwx /home/build && \ - setfacl -d --set u::rwx,g::rwx,o::- /home/build +# Cannot run makepkg as root: add build user +RUN useradd build && echo "build ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers -RUN sudo pacman -Sy --noconfirm go && rm -rf /var/cache/pacman/pkg/* +USER build -# Cannot run makepkg as root -USER nobody - -RUN git clone https://aur.archlinux.org/yay.git /home/build/yay +# yay (pre-compiled) and bretellofier WORKDIR /home/build/yay -RUN env GOCACHE=/home/build makepkg +RUN git clone https://aur.archlinux.org/yay-bin.git /home/build/yay && \ + git clone https://aur.archlinux.org/bretellofier.git /home/build/bretellofier && \ + cd /home/build/yay && env GOCACHE=/home/build makepkg --syncdeps --noconfirm && \ + cd /home/build/bretellofier && makepkg --syncdeps --noconfirm -USER root -RUN pacman --noconfirm -U /home/build/yay/*zst FROM base as final WORKDIR /root -RUN pacman -Sy --noconfirm zsh -RUN chsh -s /bin/zsh +RUN pacman -Sy --noconfirm zsh && chsh -s /bin/zsh -COPY --from=yay_builder /home/build/yay/*zst /tmp/ +COPY --from=builder /home/build/yay/*zst /tmp/ +COPY --from=builder /home/build/bretellofier/*zst /tmp/ RUN pacman --noconfirm -U /tmp/*zst && rm -rf /tmp/*zst -# telegram notifications -RUN yay -S bretellofier - # antibody RUN curl -sL https://git.io/antibody | sh -s - -b /usr/local/bin @@ -65,15 +56,15 @@ COPY . ${DOTFILES} WORKDIR /root/ -RUN echo "source $DOTFILES/brethil_dotfile.sh" >> .zshrc -RUN ln -s $DOTFILES/vim/vimrc .vimrc -RUN ln -s $DOTFILES/tmux.conf .tmux.conf -RUN echo -e "[include]\npath = $DOTFILES/gitconfig" >> .gitconfig +RUN echo -e "export DOTFILES=/root/.dotfiles\nsource \$DOTFILES/brethil_dotfile.sh" >> .zshrc && \ + ln -s $DOTFILES/vim/vimrc .vimrc && \ + ln -s $DOTFILES/tmux.conf .tmux.conf && \ + echo -e "[include]\npath = $DOTFILES/gitconfig" >> .gitconfig # Install vim plugins RUN vim -c 'PlugInstall|qa!' # Install zsh plugins -RUN zsh -il -c exit +RUN zsh -c exit CMD tmux