11# ==============================================================================
2- # Dockerfile for a feature-rich , optimized code-server development environment
2+ # Dockerfile for a streamlined , optimized code-server development environment
33#
44# Features:
55# - Base: code-server (latest)
88# - Optimization (China):
99# - Timezone: Asia/Shanghai
1010# - PyPI Mirror: Alibaba Cloud (for uv/pip)
11- # - Conda Mirror: TUNA (Tsinghua University)
1211# - Convenience: Auto-activates conda environment in the terminal
1312# ==============================================================================
1413
@@ -26,13 +25,13 @@ ENV UV_DIR=/home/coder/.local
2625ENV PATH=${CONDA_DIR}/bin:${UV_DIR}/bin:${PATH}
2726# Set the timezone.
2827ENV TZ=Asia/Shanghai
29- # Configure UV/pip to use the Alibaba Cloud mirror.
28+ # Configure UV/pip to use the Alibaba Cloud mirror. This is the core of the optimization.
3029ENV UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple
3130
3231# Step 4: Switch to the ROOT user for system-level installations.
3332USER root
3433
35- # Step 5: Install system dependencies, set timezone, install and configure Conda .
34+ # Step 5: Install system dependencies, set timezone, and install Miniforge .
3635RUN \
3736 # Update package lists and install necessary tools.
3837 apt-get update && apt-get install -y --no-install-recommends \
4948 && rm miniforge.sh \
5049 # Give the 'coder' user ownership of the conda directory.
5150 && chown -R coder:coder ${CONDA_DIR} \
52- # Create symbolic links for 'conda' and 'python3' to be accessible by root for debugging.
51+ # Create symbolic links for 'conda' and 'python3' for easier root access ( debugging) .
5352 && ln -s ${CONDA_DIR}/bin/conda /usr/local/bin/conda \
5453 && ln -s ${CONDA_DIR}/bin/python /usr/local/bin/python3 \
5554 # Clean up apt cache to reduce image size.
@@ -59,28 +58,16 @@ RUN \
5958# Step 6: Switch back to the standard, non-root 'coder' user.
6059USER coder
6160
62- # Step 7: As the 'coder' user, configure tools and create the development environment.
61+ # Step 7: As the 'coder' user, install 'uv' and create the development environment.
6362RUN \
6463 # Install 'uv' (the fast Python package manager).
6564 curl -LsSf https://astral.sh/uv/install.sh | sh && \
6665 \
67- # Configure Conda to use Tsinghua University mirrors for faster package downloads.
68- # We add our desired channels first.
69- conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/conda-forge/ && \
70- conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ && \
71- conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/ && \
72- conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/ && \
73- # --- [ THE FIX IS HERE ] ---
74- # Then, we tell conda to NOT use the built-in 'defaults' channels.
75- conda config --set nodefaults true && \
76- # (Optional) We can verify the channel configuration.
77- conda config --set show_channel_urls true && \
78- \
79- # Create the default conda environment. This will be fast due to the mirror.
66+ # Create the default conda environment using Conda's default channels.
8067 conda create -n py${PYTHON_VERSION} python=${PYTHON_VERSION} -y && \
8168 \
8269 # Pre-install common Python packages into the new environment using 'uv'.
83- # This will use the Alibaba Cloud PyPI mirror configured via ENV var .
70+ # This will automatically and quickly use the Alibaba Cloud PyPI mirror.
8471 uv pip install --python=${CONDA_DIR}/envs/py${PYTHON_VERSION}/bin/python \
8572 numpy \
8673 pandas \
9279 # Configure the shell to automatically activate this environment on login.
9380 echo "conda activate py${PYTHON_VERSION}" >> ~/.bashrc
9481
95- # Step 8: The base image's entrypoint will automatically start code-server.
96- # All our PATH and environment variable configurations will be inherited by the application.
82+ # Step 8: The base image's entrypoint will start code-server.
0 commit comments