From ee3b96fd89dc46ec1ebeb02f143a0b1bf180370e Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Tue, 9 Sep 2025 20:15:09 +0200 Subject: [PATCH] init --- .devcontainer/devcontainer.json | 33 ++++++++++++++++++ .gitconfig_template | 8 +++++ Dockerfile | 59 +++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitconfig_template create mode 100644 Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..dd77f9e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +{ + "name": "My Coder Test Environment", + "build": { + "dockerfile": "../Dockerfile", + "context": ".." + }, + "remoteUser": "coder", // This should match the USERNAME arg in your Dockerfile + // "workspaceMount": "Source=./workspace,target=/home/coder/workspace,type=bind,consistency=cached", + "workspaceFolder": "/workspaces", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "zsh", + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + } + }, + "extensions": [ + "ms-azuretools.vscode-docker", + "golang.go", // Example: Add extensions relevant to your work + "rust-lang.rust-analyzer", + "esbenp.prettier-vscode", + "editorconfig.editorconfig" + ] + } + }, + "postCreateCommand": "/etc/profile.d/nvm.sh && nvm install --lts && nvm use --lts", + "containerEnv": { + "MY_CUSTOM_VAR": "some-value" + } +} diff --git a/.gitconfig_template b/.gitconfig_template new file mode 100644 index 0000000..cc9e50c --- /dev/null +++ b/.gitconfig_template @@ -0,0 +1,8 @@ +[commit] + gpgsign = true + +[gpg] + format = ssh + +[url "ssh://git@ssh-gitea.olsen.cloud:2205/"] + insteadOf = "https://gitea.olsen.cloud/" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b10d014 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,59 @@ +FROM ubuntu:22.04 + +# --- Setup for NVM and other tools --- + +# Update package lists and install basic dependencies +RUN apt-get update && apt-get install -y \ + curl \ + git \ + nodejs \ + npm \ + build-essential \ + zsh \ + tmux \ + wget \ + unzip \ + iputils-ping \ + sudo \ + procps \ + && rm -rf /var/lib/apt/lists/* + +# Install NVM +# Using a specific NVM version is good practice. Check the latest stable version. +ENV NVM_DIR="/usr/local/nvm" +RUN mkdir -p ${NVM_DIR} && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && \ + # Ensure NVM paths are added to shell profiles for all users + echo 'export NVM_DIR="/usr/local/nvm"' >> /etc/profile.d/nvm.sh && \ + echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >> /etc/profile.d/nvm.sh && \ + echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> /etc/profile.d/nvm.sh && \ + chmod +x /etc/profile.d/nvm.sh + +# Install some default Node.js version and global packages with NVM +# This will be available to all users. +# You might want to install `npm` itself, or specific global packages. +# Ensure NVM is sourced before using it. +RUN bashenv="$(mktemp)" && \ + echo '#!/bin/bash' > "$bashenv" && \ + echo '. /etc/profile.d/nvm.sh' >> "$bashenv" && \ + echo 'nvm install 23' >> "$bashenv" && \ + echo 'nvm use 23' >> "$bashenv" && \ + echo 'corepack enable' >> "$bashenv" && \ + chmod +x "$bashenv" && \ + "$bashenv" && \ + rm "$bashenv" + + +RUN groupadd --gid 1000 coder \ + && useradd -s /bin/bash --uid 1000 --gid 1000 -m coder \ + && apt-get update && apt-get install -y sudo \ + && echo coder ALL=\(ALL\) NOPASSWD:ALL > /etc/sudoers.d/coder \ + && chmod 0440 /etc/sudoers.d/coder \ + && chsh -s /usr/bin/zsh coder + +RUN mkdir -p /home/coder/.config && chown -R coder:coder /home/coder +USER coder +RUN git clone https://gitea.olsen.cloud/morten/nvim.git /home/coder/.config/nvim + +COPY --chown=coder:coder .gitconfig_template /home/coder/.gitconfig +