dockerfile: cleanup/improvements

pull/7/head
bretello 2023-12-28 17:57:44 +01:00
parent a275d1fefc
commit 904f53b0e0
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
1 changed files with 17 additions and 26 deletions

View File

@ -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