{{< details >}}

  • Tier: 基础版,专业版,旗舰版
  • Offering: JihuLab.com,私有化部署

{{< /details >}}

极狐GitLab 提供了一个 API 端点,用于整个实例可用的 Dockerfile 模板。默认模板在极狐GitLab 仓库的 vendor/Dockerfile 中定义。

拥有 Guest 角色的用户无法访问 Dockerfile 模板。有关更多信息,请参见项目和群组可见性

重写 Dockerfile API 模板

{{< details >}}

  • Tier: 专业版,旗舰版
  • Offering: 极狐GitLab 私有化部署,极狐GitLab Dedicated

{{< /details >}}

极狐GitLab 专业版和旗舰版中,极狐GitLab 实例管理员可以在管理员区域重写模板。

列出 Dockerfile 模板

获取所有 Dockerfile 模板。

GET /templates/dockerfiles

示例请求:

curl "https://gitlab.example.com/api/v4/templates/dockerfiles"

示例响应:

[
  {
    "key": "Binary",
    "name": "Binary"
  },
  {
    "key": "Binary-alpine",
    "name": "Binary-alpine"
  },
  {
    "key": "Binary-scratch",
    "name": "Binary-scratch"
  },
  {
    "key": "Golang",
    "name": "Golang"
  },
  {
    "key": "Golang-alpine",
    "name": "Golang-alpine"
  },
  {
    "key": "Golang-scratch",
    "name": "Golang-scratch"
  },
  {
    "key": "HTTPd",
    "name": "HTTPd"
  },
  {
    "key": "Node",
    "name": "Node"
  },
  {
    "key": "Node-alpine",
    "name": "Node-alpine"
  },
  {
    "key": "OpenJDK",
    "name": "OpenJDK"
  },
  {
    "key": "PHP",
    "name": "PHP"
  },
  {
    "key": "Python",
    "name": "Python"
  },
  {
    "key": "Python-alpine",
    "name": "Python-alpine"
  },
  {
    "key": "Python2",
    "name": "Python2"
  },
  {
    "key": "Ruby",
    "name": "Ruby"
  },
  {
    "key": "Ruby-alpine",
    "name": "Ruby-alpine"
  },
  {
    "key": "Rust",
    "name": "Rust"
  },
  {
    "key": "Swift",
    "name": "Swift"
  }
]

单个 Dockerfile 模板

获取单个 Dockerfile 模板。

GET /templates/dockerfiles/:key
属性 类型 必需 描述
key string Dockerfile 模板的键

示例请求:

curl "https://gitlab.example.com/api/v4/templates/dockerfiles/Binary"

示例响应:

{
  "name": "Binary",
  "content": "# This file is a template, and might need editing before it works on your project.\n# This Dockerfile installs a compiled binary into a bare system.\n# You must either commit your compiled binary into source control (not recommended)\n# or build the binary first as part of a CI/CD pipeline.\n\nFROM buildpack-deps:buster\n\nWORKDIR /usr/local/bin\n\n# Change `app` to whatever your binary is called\nAdd app .\nCMD [\"./app\"]\n"
}