|
|
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 && \ |
|
|
apt-get install -y \ |
|
|
vim \ |
|
|
htop \ |
|
|
curl \ |
|
|
wget \ |
|
|
git \ |
|
|
zip \ |
|
|
unzip \ |
|
|
jq \ |
|
|
iputils-ping \ |
|
|
python3 \ |
|
|
python3-pip \ |
|
|
sudo && \ |
|
|
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 |
|
|
|
|
|
|
|
|
RUN GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1) && \ |
|
|
wget -q https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz && \ |
|
|
tar -C /usr/local -xzf ${GO_VERSION}.linux-amd64.tar.gz && \ |
|
|
rm ${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 |
|
|
|
|
|
|
|
|
RUN NVM_VERSION=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r .tag_name) && \ |
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/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 |
|
|
|
|
|
|
|
|
RUN mkdir -p "$DEFAULT_WORKSPACE" && \ |
|
|
echo "# 开发环境说明" > "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "本环境已预装以下工具:" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "- **code-server**: Web版 VS Code" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "- **Node.js (LTS)**: 通过 nvm 管理" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "- **Python 3 & pip**" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "- **Go (Golang)**: Go 开发环境" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "- **Git, Vim, curl, wget** 等常用命令行工具" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
echo "" >> "$DEFAULT_WORKSPACE/README.md" && \ |
|
|
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"] |