vsc / Dockerfile
rocky1410's picture
Update Dockerfile
fbd24a7 verified
# Use Ubuntu 22.04 LTS
FROM ubuntu:22.04
# Install dependencies including Node.js, Python, and a wide range of tools
RUN apt-get update && apt-get install -y \
curl \
python3 \
python3-pip \
npm \
git \
bash \
sudo \
vim \
nano \
htop \
wget \
neofetch \
gnupg \
ca-certificates \
docker.io \
build-essential \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Remove existing nodejs and libnode-dev to avoid conflicts
RUN apt-get remove -y nodejs libnode-dev || true
# Clean cached packages just in case
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Re-update and install Node.js from NodeSource
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y nodejs
# Install code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh
# Create the user and set up permissions for /app and /home/user
RUN useradd -m -u 1000 user && \
mkdir -p /app/workspace && \
mkdir -p /app/.local/share/code-server/User && \
mkdir -p /home/user && \
chown -R 1000:1000 /app && \
chown -R 1000:1000 /home/user && \
# Add user to sudo group
usermod -aG sudo user && \
# Remove password for user (optional, since we're setting passwordless sudo)
passwd -d user && \
# Configure passwordless sudo for the user
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/user
# Switch to the user
USER user
ENV HOME=/home/user
# Set the working directory to a subdirectory for clarity
WORKDIR /app/workspace
# Expose the port (7860 is required for Hugging Face Spaces)
EXPOSE 7860
# Set the password using an environment variable
ENV PASSWORD="Rakibul14@"
# Start code-server with --user-data-dir explicitly set
CMD ["code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "password", "--user-data-dir", "/app/.local/share/code-server"]