base-debian refactor

This commit is contained in:
2025-02-25 07:37:56 +01:00
parent 752824afa0
commit 087eee8ca7
7 changed files with 134 additions and 32 deletions

View File

@@ -1,39 +1,39 @@
ARG VARIANT="bookworm"
ARG VARIANT="trixie"
FROM debian:${VARIANT}
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
ca-certificates \
zsh \
vim \
tmux \
curl \
unzip \
git \
python3 \
build-essential \
libssl-dev \
sudo \
&& apt-get clean \
ENV TERM=xterm-256color
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
# basics
git wget locales ca-certificates sudo \
# utils
tree jq \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Set up UTF-8 locale
RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LC_CTYPE=en_US.UTF-8
ARG WORKSPACE_DIR="/workspace"
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG UID=1000
ARG GID=1000
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
RUN groupadd -g ${GID} ${USERNAME} \
&& useradd -u ${UID} -g ${GID} -m -s /bin/zsh ${USERNAME} \
&& echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN mkdir /workspace && chown -R $USERNAME:$USERNAME /workspace
USER $USERNAME
RUN mkdir -p ${WORKSPACE_DIR} && chown ${USERNAME}:${USERNAME} ${WORKSPACE_DIR}
WORKDIR ${WORKSPACE_DIR}
RUN git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git ~/.dotfiles
RUN ~/.dotfiles/install.sh
USER ${USERNAME}
SHELL ["/bin/zsh", "-c"]
WORKDIR /workspace
ENV w=/workspace
COPY install-packages.sh /tmp/install-packages.sh
RUN sudo chmod +x /tmp/install-packages.sh && /tmp/install-packages.sh && sudo rm /tmp/install-packages.sh
CMD ["zsh"]

View File

@@ -0,0 +1,52 @@
#!/bin/bash
set -e
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
luarocks curl unzip ripgrep fd-find \
python3 build-essential
# Install Tree-sitter and Neovim
ARCH=$(dpkg --print-architecture)
TREE_SITTER_VERSION="0.25.2"
NVIM_VERSION="0.10.4"
if [[ "$ARCH" == "arm64" ]]; then
TREE_SITTER_URL="https://github.com/tree-sitter/tree-sitter/releases/download/v${TREE_SITTER_VERSION}/tree-sitter-linux-arm64.gz"
NVIM_URL="https://github.com/neovim/neovim/releases/download/v${NVIM_VERSION}/nvim-linux-arm64.tar.gz"
elif [[ "$ARCH" == "amd64" ]]; then
TREE_SITTER_URL="https://github.com/tree-sitter/tree-sitter/releases/download/v${TREE_SITTER_VERSION}/tree-sitter-linux-x64.gz"
NVIM_URL="https://github.com/neovim/neovim/releases/download/v${NVIM_VERSION}/nvim-linux-x86_64.tar.gz"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
# Download and install Tree-sitter
echo "Installing Tree-sitter..."
wget -O /tmp/tree-sitter.gz "$TREE_SITTER_URL"
gzip -d /tmp/tree-sitter.gz
chmod +x /tmp/tree-sitter
sudo mv /tmp/tree-sitter /usr/local/bin/tree-sitter
# Download and install Neovim
echo "Installing Neovim..."
wget -O /tmp/nvim.tar.gz "$NVIM_URL"
sudo tar -xzf /tmp/nvim.tar.gz -C /opt
NVIM_DIR=$(find /opt -maxdepth 1 -type d -name "nvim-linux-*")
sudo ln -s "${NVIM_DIR}/bin/nvim" /usr/local/bin/nvim
rm /tmp/nvim.tar.gz
git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git $HOME/.dotfiles
cd $HOME/.dotfiles
echo $(pwd)
echo $(ls -a)
python3 manage.py install linux-dev
python3 manage.py link linux-dev --copy --force
# Cleanup
rm -rf $HOME/.dotfiles
# sudo apt-get purge -y build-essential python3
sudo apt-get autoremove -y
sudo apt-get clean -y
sudo rm -rf /var/lib/apt/lists/*