11# ==============================================================================
2- # Dockerfile for a professionally architected, optimized code-server environment
2+ # Dockerfile for a "Batteries-Included", professional, and optimized code-server environment
33#
44# Architecture:
5- # - Installation by 'root': The entire Python/Conda toolchain is installed
6- # by the root user into a system-wide location (/opt/conda).
7- # - Usage by 'coder': The non-root 'coder' user is configured to seamlessly
8- # use this immutable, pre-built environment.
5+ # - Installation by 'root': The entire Python/Conda toolchain is installed system-wide.
6+ # - Usage by 'coder': The non-root 'coder' user uses this immutable environment.
97#
108# Features:
119# - Base: code-server (latest)
12- # - Python: Miniforge (Conda) with a pre-created Python 3.11 environment
13- # - Package Manager: 'uv' (installed via Conda for consistency)
14- # - Root & Coder Access: 'python', 'conda', 'uv' are available for all users.
15- # - Optimization (China):
16- # - Timezone: Asia/Shanghai
17- # - PyPI Mirror: Alibaba Cloud (configured for the 'coder' user)
18- # - Pre-installed Libraries: A minimal set (numpy, pandas, matplotlib)
19- # - Convenience: Auto-activates conda environment for the 'coder' user.
10+ # - IDE Enhancement: Pre-installs essential Python VS Code extensions.
11+ # - Python: Miniforge (Conda) with a pre-created Python 3.11 environment.
12+ # - Package Manager: 'uv' (installed via Conda).
13+ # - Root & Coder Access: All tools are available for all users.
14+ # - Optimization (China): Timezone set to Asia/Shanghai, PyPI mirror configured.
15+ # - Pre-installed Libraries: A minimal set (numpy, pandas, matplotlib).
2016# ==============================================================================
2117
2218# --- Build Stage ---
23- # FIX: Use uppercase 'AS' for better style consistency.
2419FROM codercom/code-server:latest AS builder
2520
2621# Set arguments for tool versions.
@@ -81,13 +76,21 @@ RUN \
8176 mkdir -p ~/.config/uv && \
8277 printf 'index-url = "https://mirrors.aliyun.com/pypi/simple"\n ' > ~/.config/uv/uv.toml && \
8378 \
84- # 2. Configure the user's shell to auto-activate the system-wide environment.
79+ # ## --- [ NEW FEATURE: PRE-INSTALL EXTENSIONS ] --- ###
80+ # 2. Install essential VS Code extensions for a rich Python experience.
81+ # This must be run as the 'coder' user.
82+ code-server --install-extension ms-python.python \
83+ --install-extension frhtylcn.pythonsnippets \
84+ --install-extension dongli.python-preview \
85+ --install-extension njqdev.vscode-python-typehint \
86+ --install-extension LittleFoxTeam.vscode-python-test-adapter && \
87+ \
88+ # 3. Configure the user's shell to auto-activate the system-wide environment.
8589 conda init bash && \
8690 echo "conda activate py${PYTHON_VERSION}" >> ~/.bashrc
8791
8892
8993# --- Verification and Final Stage ---
90- # This stage ensures both root and coder environments are correctly configured.
9194FROM builder
9295
9396# Final check as ROOT.
@@ -100,11 +103,11 @@ RUN echo "Verifying root environment..." && \
100103# Final check as CODER.
101104USER coder
102105RUN echo "Verifying coder environment..." && \
103- # ## --- [ THE FINAL FIX IS HERE ] --- ###
104- # Use the POSIX-compliant dot ('.') instead of the bash-specific 'source'.
105106 . ~/.bashrc && \
106107 python --version && \
107108 uv --version && \
109+ # Also verify that extensions are installed by checking the directory.
110+ ls -l ~/.local/share/code-server/extensions && \
108111 echo "Coder environment check PASSED!"
109112
110113# The base image's CMD is inherited automatically.
0 commit comments