注釈: Codespaces は現在限定パブリックベータであり、変更されることがあります。 ベータ期間中、GitHubはCodespacesの可用性について保証しません。 ベータへの参加に関する詳しい情報については「Codespacesについて」を参照してください。
デフォルトの codespace 設定について
リポジトリのデフォルトのcodespace設定を作成し、そのリポジトリで作成されたすべての新しいcodespaceの環境を決定できます。 The configuration defines a development container that can include frameworks, tools, extensions, and port forwarding.
If you don't define a configuration in your repository, GitHub creates a codespace with a base Linux image. The base Linux image includes tools for Node.js, JavaScript, TypeScript, Python, C++, Java, C#, .NET Core, PHP, and PowerShell. For more information about the base Linux image, see the microsoft/vscode-dev-containers repository.
自分のアカウントで作成したcodespaceについて、codespace環境の様々な側面をパーソナライズすることもできます。 パーソナライズには、シェルの環境設定や追加のツールが含まれます。dotfilesのパーソナライゼーションは、リポジトリのデフォルトのcodespace設定よりも先に適用されます。詳しい情報については、「アカウントの Codespaces をパーソナライズする」を参照してください。
プロジェクトタイプ用にビルド済みコンテナ設定を使用してデフォルトの codespace 設定を作成するか、プロジェクトのニーズに固有のカスタム設定を作成できます。
Codespaces uses settings contained in a configuration file named devcontainer.json. This file can be located in the root of the repository or in a folder called .devcontainer. If the file is located in the root of the repository, the filename must begin with a period: .devcontainer.json.
You can use your devcontainer.json to set default settings for the entire codespace environment, including the Visual Studio Code editor, but you can also set editor-specific settings in a file named .vscode/settings.json.
リポジトリの codespace 設定への変更は、すべての新しい codespace にのみ適用され、既存の codespace には影響しません。
ビルド済みのコンテナ設定を使用する
vscode-dev-containers リポジトリで利用可能な、Visual Studio Code 用のビルド済みコンテナ設定を使用できます。 ビルド済みコンテナの定義には、特定のプロジェクトタイプの共通設定が含まれており、適切なコンテナオプション、Visual Studio Code 設定、およびインストールする必要がある Visual Studio Code 拡張機能のすでに用意された設定を使用して素早く開始できます。
vscode-dev-containersリポジトリをクローンまたはダウンロードします。vscode-dev-containersリポジトリで、コンテナフォルダに移動し、プロジェクトのニーズに合わせてコンテナ設定を選択します。 例として、Node.js & JavaScript コンテナ設定を使用します。Node.js & JavaScriptフォルダから、.devcontainerフォルダをプロジェクトのリポジトリのルートにコピーします。- 新しい設定をコミットして、GitHub のプロジェクトのリポジトリにプッシュします。
.devcontainer フォルダを含むブランチから作成された新しい codespace はそれぞれ、フォルダの内容に従って設定されます。 詳しい情報については、「codespace を作成する」を参照してください。
カスタム codespace 設定を作成する
If none of the pre-built configurations meet your needs, you can create a custom configuration by adding a devcontainer.json file. This file can be located in the root of the repository or in a folder called .devcontainer. If the file is located in the root of the repository, the filename must begin with a period: .devcontainer.json.
このファイルでは、サポートされている設定キーを使用して、codespace の環境の要素を指定できます。たとえば、Visual Studio Code 拡張機能がインストールできます。
Visual Studio Codeのエディタ設定を行う際には、Workspace、Remote [Codespaces]、Userという3つのスコープが利用できます。 複数のスコープ内で定義された設定については、Workspaceの設定が優先され、次がRemote [Codespaces]、そしてUserとなります。
2 つの場所で Visual Studio Code のデフォルトのエディタ設定を定義できます。
.vscode/settings.jsonで定義されたエディタ設定は、Workspace スコープの設定として codespace に適用されます。devcontainer.jsonの設定キーで定義されたエディタ設定は、codespace の リモート [Codespaces] スコープ設定として適用されます。
サポートされている codespace 設定キー
devcontainer.json の Codespaces でサポートされている設定キーを使用できます。
一般設定
namesettingsextensionsforwardPortsdevPortpostCreateCommand
Docker、Dockerfile、またはイメージ設定
imagedockerFilecontextcontainerEnvremoteEnvcontainerUserremoteUserupdateRemoteUserUIDmountsworkspaceMountworkspaceFolderrunArgsoverrideCommandshutdownActiondockerComposeFile
devcontainer.json で使用可能な設定の詳細については、Visual Studio Code ドキュメントの「devcontainer.json の参照」をご覧ください。