Adjusted to use non-root user.
This commit is contained in:
@@ -5,14 +5,20 @@ FROM debian:unstable
|
|||||||
RUN apt-get update && apt-get install -y locales
|
RUN apt-get update && apt-get install -y locales
|
||||||
|
|
||||||
# Set image locale.
|
# Set image locale.
|
||||||
ENV LANG en_US.UTF-8
|
ENV LANG=en_US.UTF-8
|
||||||
ENV LANGUAGE en_US:en
|
ENV LANGUAGE=en_US:en
|
||||||
ENV LC_ALL en_US.UTF-8
|
ENV LC_ALL=en_US.UTF-8
|
||||||
ENV TZ=America/New_York
|
ENV TZ=America/New_York
|
||||||
ENV TERM=xterm-256color
|
ENV TERM=xterm-256color
|
||||||
|
|
||||||
# Update repositories and install software:
|
# Create a non-root user with UID 1000
|
||||||
RUN apt-get update && apt-get -y install curl fzf ripgrep tree git xclip python3 python3-pip python3-venv nodejs npm tzdata ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config zip unzip fish tmux
|
RUN useradd -m -u 1000 -s /usr/bin/fish shaun
|
||||||
|
|
||||||
|
# Install required software
|
||||||
|
RUN apt-get update && apt-get -y install \
|
||||||
|
curl fzf ripgrep tree git xclip python3 python3-pip python3-venv nodejs npm \
|
||||||
|
tzdata ninja-build gettext libtool libtool-bin autoconf automake cmake g++ \
|
||||||
|
pkg-config zip unzip fish tmux
|
||||||
|
|
||||||
# Cooperate Neovim with Python 3.
|
# Cooperate Neovim with Python 3.
|
||||||
RUN python3 -m pip install --break-system-packages --root-user-action ignore pynvim
|
RUN python3 -m pip install --break-system-packages --root-user-action ignore pynvim
|
||||||
@@ -21,45 +27,47 @@ RUN python3 -m pip install --break-system-packages --root-user-action ignore pyn
|
|||||||
RUN npm i -g neovim
|
RUN npm i -g neovim
|
||||||
|
|
||||||
# Install Neovim from source.
|
# Install Neovim from source.
|
||||||
RUN mkdir -p /root/TMP
|
RUN mkdir -p /tmp/neovim-src && \
|
||||||
RUN cd /root/TMP && git clone https://github.com/neovim/neovim
|
git clone --depth 1 --branch stable https://github.com/neovim/neovim /tmp/neovim-src && \
|
||||||
RUN cd /root/TMP/neovim && git checkout stable && make -j4 && make install
|
cd /tmp/neovim-src && make -j$(nproc) && make install && \
|
||||||
RUN rm -rf /root/TMP
|
rm -rf /tmp/neovim-src
|
||||||
|
|
||||||
# Clone configuration files.
|
# Clone configuration files.
|
||||||
RUN git clone https://gitea.setlock.net/shaun/dotfiles.git /root/dotfiles
|
USER shaun
|
||||||
|
WORKDIR /home/shaun
|
||||||
|
|
||||||
# Create directory configuration files.
|
RUN git clone https://gitea.setlock.net/shaun/dotfiles.git /home/shaun/dotfiles
|
||||||
RUN mkdir -p /root/.config
|
|
||||||
|
|
||||||
# fish needs the .ssh directory
|
# Create directories.
|
||||||
RUN mkdir -p /root/.ssh
|
RUN mkdir -p /home/shaun/.config /home/shaun/.ssh
|
||||||
|
|
||||||
# Softlink configuration files.
|
# Softlink configuration files.
|
||||||
RUN ln -s /root/dotfiles/nvim /root/.config
|
RUN ln -s /home/shaun/dotfiles/nvim /home/shaun/.config
|
||||||
RUN ln -s /root/dotfiles/fish /root/.config
|
RUN ln -s /home/shaun/dotfiles/fish /home/shaun/.config
|
||||||
RUN ln -s /root/dotfiles/tmux /root/.config
|
RUN ln -s /home/shaun/dotfiles/tmux /home/shaun/.config
|
||||||
|
|
||||||
# Make sure tmux plug-in manager is installed.
|
# Install tmux plugin manager.
|
||||||
RUN git clone https://github.com/tmux-plugins/tpm /root/.config/tmux/plugins/tpm
|
RUN git clone https://github.com/tmux-plugins/tpm /home/shaun/.config/tmux/plugins/tpm && \
|
||||||
RUN /root/.config/tmux/plugins/tpm/scripts/install_plugins.sh
|
/home/shaun/.config/tmux/plugins/tpm/scripts/install_plugins.sh
|
||||||
|
|
||||||
# Get oh-my-fish and bob-the-fish installed.
|
# Get oh-my-fish and bob-the-fish installed.
|
||||||
RUN curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install > install
|
RUN curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install > install
|
||||||
RUN fish install --noninteractive
|
RUN fish install --noninteractive
|
||||||
RUN fish -c "omf install bobthefish"
|
RUN fish -c "omf install bobthefish"
|
||||||
|
|
||||||
# Install neovim plugins
|
# Install Neovim plugins
|
||||||
RUN nvim --headless "+Lazy! sync" +qa
|
RUN nvim --headless "+Lazy! sync" +qa
|
||||||
|
|
||||||
# Set root's default shell.
|
# Set default shell for shaun
|
||||||
RUN usermod --shell /usr/bin/fish root
|
USER root
|
||||||
|
RUN usermod --shell /usr/bin/fish shaun
|
||||||
|
|
||||||
# Create directory for projects (there should be mounted from host).
|
# Set workspace directory
|
||||||
RUN mkdir -p /root/workspace
|
RUN mkdir -p /workspace && chown shaun:shaun /workspace
|
||||||
|
WORKDIR /workspace
|
||||||
|
|
||||||
# Set default location after container startup.
|
# Switch to non-root user
|
||||||
WORKDIR /root/workspace
|
USER shaun
|
||||||
|
|
||||||
# Avoid container exit.
|
# Avoid container exit.
|
||||||
CMD ["tail", "-f", "/dev/null"]
|
CMD ["tail", "-f", "/dev/null"]
|
||||||
|
|||||||
Reference in New Issue
Block a user