欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

加速 Elixir 开发环境

最编程 2024-02-23 20:22:03
...

Elixir 应用构建拉依赖经常需要走外网,但 GitHub 默认创建的 Codespaces 环境默认一般都是 js 的开发环境 Dockerfile,并没有 Elixir 环境,需要我们自己单独配置一手,好在提供了 devcontainer 的形式供我们自定义自己的基础开发环境,我们只需要提供配置文件就好, 我们需要做的如下:

  • 1、GitHub 仓库创建 .devcontainer 目录;
  • 2、.devcontainer 下的 devcontainer.json 文件声明开发环境配置;

示范仓库如: https://github.com/yeshan333/erlang_elixir_asdf_ubuntu_container/tree/main/.devcontainer

{
  "image": "ghcr.io/yeshan333/erlang_elixir_asdf_ubuntu_container:latest",
  "customizations": {
    "vscode": {
      "extensions": ["jakebecker.elixir-ls"]
    }
  },
  "postCreateCommand": "git config --global core.fileMode false"
}

通过 image 字段,我们直接声明了 GitHub Codespaces 使用的 Docker 镜像,extensions 指定了要启用哪些 vscode 插件,postCreateCommand 制定了环境起来之后要跑的 shell 命令。甚至于也可以指定我们自己写的 Dockerfile 来启动 GitHub Codespaces 环境,可参考:https://github.com/devcontainers/images/blob/main/src/go/.devcontainer/devcontainer.json

基于以上,我们可以通过 https://github.com/codespaces/new 指定海外节点进行 GitHub Codespaces 创建即刻.