Docker


我们的 Representer 以 Docker 镜像的形式部署。

请阅读工具 Docker 通用信息,熟悉它们的工作方式。

集成

当我们运行 Representer 为提交的解答生成 representation 时,执行的 Docker 命令如下:

docker run \
        --rm \
        --network none \
        --mount type=bind,src="${solution_dir}",dst=/solution \
        --mount type=bind,src="${output_dir}",dst=/output \
        --tmpfs /tmp:rw \
        "exercism/${track_slug}-representer" \
        "${exercise_slug}" "/solution" "/output"

可以看到,我们向 Docker 镜像传入了 3 个实参:

  1. 练习的 slug
  2. 提交的解答所在目录的路径
  3. 输出目录的路径

约定

我们所有的 Representer 在实现中都遵循以下约定:

  • Dockerfile位于代码仓库的根目录。
  • 工作目录应为/opt/representer。
  • 入口点是/opt/representer/bin/run.sh
  • /opt/representer/bin/run.sh脚本接受 3 个实参:
    1. 练习的 slug
    2. 提交的解答所在目录的路径
    3. 输出目录的路径

更多信息请参见接口。

Note

新建的 representer 代码仓库默认会使用这些约定。