Coder
公式サイト: Coder - Your Self-Hosted Remote Development Platform
リモート開発環境をセルフホストできるサーバー(Coder Server)と、そこにリモート開発環境を建てたり、建てた環境にアクセスしたりするためのソフトウェア等から成るプラットフォーム。
作成する開発環境のTemplateをTerraform Resourceとして記述できる。
Coder Server内蔵TerraformがTemplateからWorkspace(リモート開発環境)を作成し、クライアントがCoder Serverを通してそのWorkspaceに接続することで開発を行うことができる。
クライアントとしては、Coder CLIや、その上に載っているVSCodeのCoder拡張機能やブラウザ等を用いることができる。
Workspace - Coder Server間の通信の仕組み
Workspaceの作成が完了すると、WorkspaceがCoder Serverに接続する。
つまり、WorkspaceにあたるTerraform Resourceは、起動時にCoder Serverに接続するように設定しておく必要がある。
WorkspaceからCoder Serverに接続するにはCoder Agentを用いる。
All templates need to create and run a Coder agent. This lets developers connect to their workspaces. The coder_agent resource runs inside the compute aspect of your workspace, typically a VM or container. In our case, it will run in Docker.
You do not need to have any open ports on the compute aspect, but the agent needs curl access to the Coder server. Remember that we installed curl in Dockerfile, earlier.
実際にCoder Serverの前に置いてあるリバースプロキシのログを読むと、Workspaceが/bin/coder-linux-amd64をダウンロードして、ドキュメントに載っていないAPIにアクセスしていることがわかる。
code:txt
172.18.0.1:45172 02/Mar/2024:12:01:42.747 proxy coder/coder 0/0/0/592/2678 200 12170541 - - ---- 10/10/8/8/0 0/0 "GET /bin/coder-linux-amd64 HTTP/1.1"
172.18.0.1:45172 02/Mar/2024:12:01:48.355 proxy coder/coder 0/0/0/20/20 200 464 - - ---- 10/10/9/9/0 0/0 "POST /api/v2/workspaceagents/me/report-stats HTTP/1.1"
172.18.0.1:45172 02/Mar/2024:12:01:48.611 proxy coder/coder 0/0/0/1/1 200 317 - - ---- 11/11/10/10/0 0/0 "GET /derp/latency-check HTTP/1.1"
172.18.0.1:52644 02/Mar/2024:11:57:12.063 proxy coder/coder 0/0/0/5/278481 200 29827 - - CD-- 12/12/9/9/0 0/0 "GET /api/v2/workspaces/546b5278-2208-4f3e-893f-2cfe14f55e7a/watch HTTP/1.1"
172.18.0.1:45172 02/Mar/2024:12:01:50.570 proxy coder/coder 0/0/0/6/6 200 436 - - ---- 10/10/9/9/0 0/0 "PATCH /api/v2/workspaceagents/me/logs HTTP/1.1"
172.18.0.1:45172 02/Mar/2024:12:01:50.846 proxy coder/coder 0/0/0/9/9 204 424 - - ---- 10/10/9/9/0 0/0 "POST /api/v2/workspaceagents/me/metadata HTTP/1.1"