| FROM codercom/code-server:latest |
|
|
| |
| ENV DEFAULT_WORKSPACE=/home/coder/workspace |
|
|
| USER root |
|
|
| |
| RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ |
| echo "Asia/Shanghai" > /etc/timezone |
|
|
| |
| RUN apt-get update && \ |
| DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| ca-certificates \ |
| gnupg \ |
| software-properties-common \ |
| vim \ |
| htop \ |
| curl \ |
| wget \ |
| git \ |
| default-jdk \ |
| git-lfs \ |
| bzip2 \ |
| libx11-6 \ |
| build-essential \ |
| libsndfile-dev \ |
| zip \ |
| unzip \ |
| jq \ |
| iputils-ping \ |
| python3 \ |
| python3-pip \ |
| sudo && \ |
| apt-get clean && \ |
| rm -rf /var/lib/apt/lists/* |
|
|
| |
| RUN jq '. += { \ |
| "extensionsGallery": { \ |
| "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery", \ |
| "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index", \ |
| "itemUrl": "https://marketplace.visualstudio.com/items", \ |
| "controlUrl": "", \ |
| "recommendationsUrl": "" \ |
| } \ |
| }' /usr/lib/code-server/lib/vscode/product.json > /tmp/product.json \ |
| && mv /tmp/product.json /usr/lib/code-server/lib/vscode/product.json |
|
|
| |
| ARG GO_VERSION=1.25.1 |
| RUN wget -q https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ |
| tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \ |
| rm go${GO_VERSION}.linux-amd64.tar.gz |
|
|
| USER coder |
|
|
| |
| RUN echo 'export PATH=/usr/local/go/bin:$PATH' >> /home/coder/.bashrc |
|
|
| |
| RUN mkdir -p /home/coder/.nvm && \ |
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && \ |
| echo 'export NVM_DIR="$HOME/.nvm"' >> /home/coder/.bashrc && \ |
| echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /home/coder/.bashrc && \ |
| echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> /home/coder/.bashrc |
|
|
| |
| RUN bash -c "source /home/coder/.nvm/nvm.sh && nvm install --lts && nvm alias default node" |
|
|
| |
| RUN echo "alias ll='ls -alF'" >> /home/coder/.bashrc && \ |
| echo "alias ls='ls --color=auto'" >> /home/coder/.bashrc |
|
|
| |
| RUN code-server --install-extension ms-python.python && \ |
| code-server --install-extension golang.go && \ |
| code-server --install-extension tencent-cloud.coding-copilot |
|
|
| |
| RUN mkdir -p "$DEFAULT_WORKSPACE" && \ |
| { \ |
| echo "# 开发环境说明"; \ |
| echo ""; \ |
| echo "本环境已预装以下工具:"; \ |
| echo "- **code-server**: Web版 VS Code"; \ |
| echo "- **Node.js (LTS)**: 通过 nvm 管理"; \ |
| echo "- **Python 3 & pip**"; \ |
| echo "- **Go (Golang)**: Go 开发环境"; \ |
| echo "- **Git, Vim, curl, wget** 等常用命令行工具"; \ |
| echo ""; \ |
| echo "时区已设置为 \`Asia/Shanghai\`。"; \ |
| } > "$DEFAULT_WORKSPACE/README.md" |
|
|
| WORKDIR $DEFAULT_WORKSPACE |
|
|
| EXPOSE 18080 |
|
|
| ENTRYPOINT [] |
|
|
| CMD ["sh", "-c", "code-server --bind-addr 0.0.0.0:18080 --auth password $DEFAULT_WORKSPACE"] |
|
|