# The Dockerfile to build centos with a sudo user
FROM manjarolinux/base:latest

# Install the required packages
RUN pacman -Sy --noconfirm gedit vim git git-lfs curl wget zsh gcc make perl base-devel binutils screen tmux python-pipx p7zip unzip

# Create a new user
RUN useradd -m -s /bin/bash user && \
    usermod -aG wheel user && \
    echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# Set the working directory
WORKDIR /home/user
COPY run_user.sh /home/user/run_user.sh

# remove the last `zsh` in the script to prevent the endless runtime
RUN echo "" >> ./run_user.sh
RUN tac run_user.sh | awk '/^zsh$/ && !found { found = 1; next } 1' | tac > run_user.sh.tmp && mv run_user.sh.tmp run_user.sh

# remove the line `systemctl --user start syncthing.service`
RUN tac run_user.sh | awk '/^systemctl --user start syncthing.service$/ && !found { found = 1; next } 1' | tac > run_user.sh.tmp && mv run_user.sh.tmp run_user.sh

# Set the user
USER user

# Set the entrypoint
CMD bash run_user.sh
