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

75
node/Dockerfile Normal file
View File

@@ -0,0 +1,75 @@
ARG VARIANT="bookworm"
FROM debian:${VARIANT}
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
ca-certificates \
zsh \
vim \
tmux \
curl \
wget \
unzip \
git \
python3 \
build-essential \
libssl-dev \
openssh-client \
sudo \
luarocks \
fd-find \
ripgrep \
locales \
tree \
htop \
jq \
man \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Install Neovim
ENV TREE_SITTER_VERSION="0.23.1"
ENV TREE_SITTER_URL="https://github.com/tree-sitter/tree-sitter/releases/download/v${TREE_SITTER_VERSION}/tree-sitter-linux-arm64.gz"
ENV NVIM_VERSION="0.10.0"
ENV NVIM_URL="https://gitea.tomastm.com/tomas.mirchev/neovim/releases/download/v${NVIM_VERSION}/nvim-linux-arm64.deb"
RUN set -ex \
&& mkdir -p /tmp/downloads \
&& cd /tmp/downloads \
# Install tree-sitter
&& wget -O tree-sitter.gz ${TREE_SITTER_URL} \
&& gzip -d tree-sitter.gz \
&& chmod +x tree-sitter \
&& mv tree-sitter /usr/local/bin/ \
# Install Neovim
&& wget -O nvim.deb ${NVIM_URL} \
&& apt-get install -y ./nvim.deb \
# Clean up
&& rm -rf /tmp/downloads
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LC_CTYPE=en_US.UTF-8
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
&& locale-gen
ARG UID=1000
ARG GID=1000
RUN groupadd -g ${GID} dev
RUN useradd -u ${UID} -g dev -m -s /bin/zsh dev
RUN echo "dev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN mkdir /workspace && chown dev:dev /workspace
WORKDIR /workspace
COPY install-tools.sh /usr/local/bin/install-tools.sh
RUN chmod +x /usr/local/bin/install-tools.sh
USER dev
ENV TERM=xterm-256color
RUN /usr/local/bin/install-tools.sh
CMD ["zsh"]

26
node/README.md Normal file
View File

@@ -0,0 +1,26 @@
# Dev containers
## Commands
Build
```
docker build \
--build-arg UID=$(id -u) \
--build-arg GID=$(id -g) \
-t web-stack .
```
Run. Mount /workspace if you want to preserve changes. Mount /workspace if you want to preserve changes.
```
podman run -it --rm \
--userns=keep-id \
--network host \
-v $HOME/.ssh:/home/dev/.ssh:ro,Z \
-v $PWD:/workspace:Z \
my-dev-container
```
## Installed tools
- Common ones: curl, git, vim, tmux, zsh. Included dotfiles.
- NVM and nodejs (lts, v18, v20, v22).
- All package managers preinstalled (npm, pnpm, yarn). Enable with `corepack enable <pm>`.

39
node/install-tools.sh Normal file
View File

@@ -0,0 +1,39 @@
#!/bin/sh
set -e
# Install dotfiles
git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git $HOME/.dotfiles
python3 $HOME/.dotfiles/install.py -e linux-dev
# Install NVM
export NVM_DIR="$HOME/.nvm"
mkdir -p "$NVM_DIR"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
. "$NVM_DIR/nvm.sh"
# Preinstall a few nodejs versions
nvm install --lts # The first version installed becomes the default
nvm install 18
nvm install 20
nvm install 22
# Preinstall all package managers
corepack prepare npm --activate
corepack prepare yarn --activate
corepack prepare pnpm --activate
# corepack disable
corepack enable npm
corepack enable pnpm
corepack enable yarn
cat << 'EOF' >> $HOME/.zshrc
# pnpm
export PNPM_HOME="$HOME/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
EOF