时间:2023-07-24 23:54:02 | 来源:网站运营
时间:2023-07-24 23:54:02 来源:网站运营
爽爆了!我搞了一个网页版 VS Code:VS Code 想必大家都听说过吧,VS Code 凭借其强大的插件生态简直把 IDE 玩出花来了,现在我身边越来越多的程序员朋友现在都转向使用 VS Code 来写代码了,我也不例外。Run VS Code on any machine anywhere and access it in the browser.正式我想要的!它在浏览器里面的运行效果如图所示:
curl -fsSL https://code-server.dev/install.sh | sh
这条命令运行之后会自动判断当前的平台,然后运行安装步骤。FROM ubuntu:18.04RUN apt-get update && apt-get install -y / openssl / net-tools / git / zsh / locales / sudo / dumb-init / vim / curl / wget / bash-completion / python3 / python3-pip / python3-setuptools / build-essential / python3-dev / libssl-dev / libffi-dev / libxml2 / libxml2-dev / libxslt1-dev / zlib1g-devRUN chsh -s /bin/bashENV SHELL=/bin/bashRUN ARCH=amd64 && / curl -sSL "https://github.com/boxboat/fixuid/releases/download/v0.4.1/fixuid-0.4.1-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - && / chown root:root /usr/local/bin/fixuid && / chmod 4755 /usr/local/bin/fixuid && / mkdir -p /etc/fixuid && / printf "user: coder/ngroup: coder/n" > /etc/fixuid/config.ymlRUN CODE_SERVER_VERSION=3.10.2 && / curl -sSOL https://github.com/cdr/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_amd64.deb && / sudo dpkg -i code-server_${CODE_SERVER_VERSION}_amd64.debRUN locale-gen en_US.UTF-8ENV LC_ALL=en_US.UTF-8RUN adduser --disabled-password --gecos '' coder && / adduser coder sudo && / echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers;RUN chmod g+rw /home && / mkdir -p /home/coder/workspace && / mkdir -p /home/coder/.local && / chown -R coder:coder /home/coder && / chown -R coder:coder /home/coder/.local && / chown -R coder:coder /home/coder/workspace;USER coderRUN git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && / ~/.fzf/installENV PASSWORD=${PASSWORD:-P@ssw0rd}COPY ./extensions /home/coder/.local/extensionsRUN /usr/bin/code-server --install-extension ms-python.python && / /usr/bin/code-server --install-extension esbenp.prettier-vscode && / /usr/bin/code-server --install-extension equinusocio.vsc-material-theme && / /usr/bin/code-server --install-extension codezombiech.gitignore && / /usr/bin/code-server --install-extension piotrpalarz.vscode-gitignore-generator && / /usr/bin/code-server --install-extension aeschli.vscode-css-formatter && / /usr/bin/code-server --install-extension donjayamanne.githistory && / /usr/bin/code-server --install-extension ecmel.vscode-html-css && / /usr/bin/code-server --install-extension pkief.material-icon-theme && / /usr/bin/code-server --install-extension equinusocio.vsc-material-theme-icons && / /usr/bin/code-server --install-extension eg2.vscode-npm-script && / /usr/bin/code-server --install-extension ms-ceintl.vscode-language-pack-zh-hans && / /usr/bin/code-server --install-extension /home/coder/.local/extensions/tkrkt.linenote-1.2.1.vsix && / /usr/bin/code-server --install-extension dbaeumer.vscode-eslintRUN /usr/bin/python3 -m pip install -U pip setuptoolsRUN /usr/bin/python3 -m pip install requests httpx scrapy aiohttp pyquery beautifulsoup4 / selenium pyppeteer pylint flask django tornado numpy pandas scipy autopep8COPY settings.json /home/coder/.local/share/code-server/User/settings.jsonRUN sudo chown coder /home/coder/.local/share/code-server/User/settings.jsonCOPY entrypoint.sh /home/coder/.local/entrypoint.shRUN sudo chmod +x /home/coder/.local/entrypoint.shWORKDIR /home/coder/workspaceEXPOSE 8080ENTRYPOINT ["/bin/sh", "/home/coder/.local/entrypoint.sh"]
这里就直接把 Dockerfile 列出来了,主要分这么几步:{ "workbench.colorTheme": "Material Theme", "workbench.iconTheme": "material-icon-theme", "git.enableSmartCommit": true, "editor.tabSize": 2, "editor.detectIndentation": false, "editor.formatOnSave": true, "editor.formatOnPaste": true, "editor.defaultFormatter": "es{ "workbench.colorTheme": "Material Theme", "workbench.iconTheme": "material-icon-theme", "git.enableSmartCommit": true, "editor.tabSize": 2, "editor.detectIndentation": false, "editor.formatOnSave": true, "editor.formatOnPaste": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.fontSize": 16, "editor.suggestSelection": "first", "files.autoGuessEncoding": true, "files.autoSave": "afterDelay", "terminal.integrated.inheritEnv": false, "vetur.experimental.templateInterpolationService": true, "[typescript]": { "editor.tabSize": 2 }, "[javascript]": { "editor.tabSize": 2 }, "[python]": { "editor.tabSize": 4, "editor.defaultFormatter": "ms-python.python" }}
这里配置文件主要配置了主题、字体大小、缩进等内容,当然这个如果你要自己配置的话就按照自己的喜好来就好了。version: "3"services: code-server: container_name: "code-server" build: . image: "germey/code-server" ports: - "8080:8080"
OK,基本就是这样,运行:docker-compose build
就可以成功构建一个镜像了,然后运行:docker-compose push
即可把镜像 push 到我的 Docker Hub 上面,等待部署即可。如果你没有用过 Helm 的话可以搜索相关资料了解下。这里 Chart 的具体实现我就不再赘述了,主要就包括了几个部分:
helm install code-server-<username> . --namespace <namespace> --set user=<username> --set password=<password>
注意运行目录在 chart 路径下才可以。这里我们传入了 usrname、namespace、password。
helm install code-server-germey . --namespace scrape --set user=germey --set password=1234
这里用户名我替换成了 germey,命名空间我用了 scrape,密码用了 1234。pip3 install pillow
非常方便。关键词: