File size: 2,077 Bytes
7f31c43 d3fa4e7 7f31c43 d3fa4e7 7f31c43 d3fa4e7 7f31c43 d3fa4e7 7f31c43 d3fa4e7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # ================================================
# Minimal VSCode (code-server) Setup for MERN Stack Development
# ================================================
FROM ubuntu:22.04
# Non-interactive apt
ENV DEBIAN_FRONTEND=noninteractive
# Create a non-root user
RUN apt-get update && apt-get install -y sudo \
&& useradd -m -s /bin/bash coder \
&& echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER root
WORKDIR /home/coder
# -------------------------------
# Basic Development Tools
# -------------------------------
RUN apt-get update && apt-get install -y \
curl wget git unzip zip build-essential gnupg ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# -------------------------------
# Install Node.js (v22 LTS) + npm + yarn + pnpm
# -------------------------------
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g yarn pnpm
# -------------------------------
# Install code-server (VS Code in browser)
# -------------------------------
RUN curl -fsSL https://code-server.dev/install.sh | sh
# -------------------------------
# Setup workspace directories
# -------------------------------
RUN mkdir -p /home/coder/workspace /home/coder/.config/code-server /home/coder/.local/share/code-server \
&& chown -R coder:coder /home/coder
# -------------------------------
# Configure code-server authentication
# -------------------------------
USER coder
WORKDIR /home/coder/workspace
# Default password (can be overridden by Hugging Face secret or -e PASSWORD)
ENV PASSWORD=mernpassword
# Write the config file so code-server knows to use password auth
RUN echo "bind-addr: 0.0.0.0:7860\nauth: password\npassword: ${PASSWORD}\ncert: false" > /home/coder/.config/code-server/config.yaml
# -------------------------------
# Expose port and start code-server
# -------------------------------
EXPOSE 7860
CMD ["bash", "-c", "PASSWORD=${PASSWORD} code-server --config /home/coder/.config/code-server/config.yaml --user-data-dir /home/coder/.local/share/code-server"]
|