init
This commit is contained in:
70
Dockerfile
Normal file
70
Dockerfile
Normal file
@@ -0,0 +1,70 @@
|
||||
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 20' >> "$bashenv" && \
|
||||
echo 'nvm use 20' >> "$bashenv" && \
|
||||
echo 'npm install -g pnpm yarn' >> "$bashenv" && \
|
||||
chmod +x "$bashenv" && \
|
||||
"$bashenv" && \
|
||||
rm "$bashenv"
|
||||
|
||||
|
||||
# --- Setup a non-root user (important for Coder) ---
|
||||
# Coder typically runs the workspace user as `coder`.
|
||||
# We'll create a `coder` user and give it sudo privileges without password.
|
||||
# This aligns with how Coder manages workspace users.
|
||||
ARG USERNAME=coder
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
|
||||
RUN groupadd --gid $USER_GID $USERNAME \
|
||||
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
|
||||
&& apt-get update && apt-get install -y sudo \
|
||||
&& echo $USERNAME ALL=\(ALL\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
|
||||
&& chmod 0440 /etc/sudoers.d/$USERNAME
|
||||
|
||||
# Ensure the /home/$USERNAME directory exists and has correct permissions
|
||||
RUN mkdir -p /home/$USERNAME && chown $USERNAME:$USERNAME /home/$USERNAME
|
||||
|
||||
USER $USERNAME
|
||||
RUN git clone https://gitea.olsen.cloud/morten/nvim.git
|
||||
|
||||
COPY .gitconfig_template /home/$USERNAME/.gitconfig
|
||||
RUN chown $USERNAME:$USERNAME /home/$USERNAME/.gitconfig
|
||||
|
||||
RUN sudo chsh -s /usr/bin/zsh $USERNAME
|
||||
Reference in New Issue
Block a user