code-server / Dockerfile
cacode's picture
Upload 2 files
be2a1d7 verified
raw
history blame
2.85 kB
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
ENV PORT=7860
ENV HOME=/home/coder
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# 1) 系统与开发工具(重度版)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl wget git bash sudo tini gnupg dirmngr jq \
# 常用工具
unzip zip xz-utils less vim nano openssh-client \
# C/C++
build-essential gcc g++ make cmake ninja-build gdb lldb clang clangd pkg-config \
# Python
python3 python3-pip python3-venv python3-dev \
# Java + build tools
openjdk-17-jdk maven gradle \
# Node.js
nodejs npm \
# 其他
ripgrep fd-find \
&& rm -rf /var/lib/apt/lists/*
# 2) 安装 code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh
# 3) 安装 Node 包管理器补充
RUN npm install -g yarn pnpm
# 4) Python 常见依赖(可按需删减)
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel && \
python3 -m pip install --no-cache-dir \
numpy pandas scipy scikit-learn matplotlib seaborn plotly \
jupyter jupyterlab ipykernel notebook \
requests httpx aiohttp pyyaml python-dotenv tqdm rich \
flask fastapi uvicorn[standard] pydantic \
sqlalchemy alembic psycopg2-binary redis \
pytest pytest-cov black isort mypy ruff pre-commit
# 5) 安装 Rust(stable)
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# 6) 安装 Go(Debian 包,稳定即可)
RUN apt-get update && apt-get install -y --no-install-recommends golang-go && \
rm -rf /var/lib/apt/lists/*
# 7) 安装 Codex CLI(若仓库不可用,不阻断)
RUN npm install -g @openai/codex || true
# 8) 创建用户
RUN useradd -m -u 1000 -s /bin/bash coder && \
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
mkdir -p /home/coder/.config/code-server /home/coder/.codex && \
chown -R coder:coder /home/coder
# 9) 预装常用 VSCode 扩展(失败不阻断)
RUN code-server --install-extension ms-python.python || true && \
code-server --install-extension ms-toolsai.jupyter || true && \
code-server --install-extension ms-vscode.cpptools || true && \
code-server --install-extension llvm-vs-code-extensions.vscode-clangd || true && \
code-server --install-extension vscjava.vscode-java-pack || true && \
code-server --install-extension redhat.vscode-yaml || true && \
code-server --install-extension esbenp.prettier-vscode || true
COPY --chown=coder:coder start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh
USER coder
WORKDIR /home/coder
EXPOSE 7860
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/usr/local/bin/start.sh"]