From 978052b4304aa9a3730857cb03c62c8883852772 Mon Sep 17 00:00:00 2001 From: unai_71 Date: Tue, 25 Aug 2026 13:36:19 +0200 Subject: [PATCH] feat: changed to neovim based development, removed root remote user --- .devcontainer/Dockerfile | 46 ++++++++++++++++++++++++++++++--- .devcontainer/devcontainer.json | 25 +++++++++++------- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 13eb708..3e00ac8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,43 @@ FROM python:3.14-slim -# Instalar git y herramientas básicas -RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/* -# Instalar Poetry -RUN pip install poetry + +ARG USERNAME=dev +ARG USER_UID=1000 +ARG USER_GID=1000 + +# Herramientas básicas + zsh + utilidades que usará neovim (ripgrep/fd para telescope, etc.) +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + curl \ + zsh \ + sudo \ + ripgrep \ + fd-find \ + unzip \ + build-essential \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Debian llama al binario "fdfind" en vez de "fd": creamos un enlace para que +# los plugins de neovim que esperan "fd" lo encuentren. +RUN ln -s $(which fdfind) /usr/local/bin/fd + +# Crear grupo y usuario "dev" con UID:GID 1000:1000 (evita problemas de +# permisos con los bind mounts del host) y darle sudo sin contraseña. +RUN groupadd --gid ${USER_GID} ${USERNAME} \ + && useradd --uid ${USER_UID} --gid ${USER_GID} -m -s /bin/zsh ${USERNAME} \ + && echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} \ + && chmod 0440 /etc/sudoers.d/${USERNAME} + +# Poetry a nivel de sistema (como root) para que quede disponible en el PATH +# de cualquier usuario y no se pierda al cambiar de shell. +RUN pip install --no-cache-dir poetry \ + && poetry config virtualenvs.in-project true + +# A partir de aquí trabajamos como el usuario "dev", igual que se hace con +# "ubuntu" en el ejemplo de esp-idf, para instalar oh-my-zsh en su propio HOME. +USER ${USERNAME} +WORKDIR /home/${USERNAME} + +RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended + +WORKDIR /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index db404d3..4d7270d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,17 @@ { "name": "Python Poetry Dev", "build": { - "dockerfile": "Dockerfile" + "dockerfile": "Dockerfile", + "args": { + "USERNAME": "dev", + "USER_UID": "1000", + "USER_GID": "1000" + } + }, + "features": { + "ghcr.io/duduribeiro/devcontainer-features/neovim:1": { + "version": "stable" + } }, "customizations": { "vscode": { @@ -22,17 +32,14 @@ } } }, - "runArgs": [ - "--privileged", - "-v", - "/dev:/dev" - ], + "runArgs": ["--privileged", "-v", "/dev:/dev"], "mounts": [ - "source=${localEnv:XDG_RUNTIME_DIR}/ssh-agent.socket,target=/tmp/ssh-agent.socket,type=bind" + "source=${localEnv:XDG_RUNTIME_DIR}/ssh-agent.socket,target=/tmp/ssh-agent.socket,type=bind", + "source=${env:HOME}/.config/nvim,target=/home/dev/.config/nvim,type=bind" ], "remoteEnv": { "SSH_AUTH_SOCK": "/tmp/ssh-agent.socket" }, - "remoteUser": "root", + "remoteUser": "dev", "postCreateCommand": "poetry install" -} \ No newline at end of file +}