The Wayback Machine - https://web.archive.org/web/20201020081706/https://docs.github.com/ja/free-pro-team@latest/github/developing-online-with-codespaces/configuring-codespaces-for-your-project
ドキュメントには頻繁に更新が加えられ、その都度公開されています。本ページの翻訳はまだ未完成な部分があることをご了承ください。最新の情報については、英語のドキュメンテーションをご参照ください。本ページの翻訳に問題がある場合はこちらまでご連絡ください。

プロジェクトの Codespace の設定

リポジトリの新しい codespace ごとにデフォルトの設定を行い、コントリビューターがオンライン開発環境で必要なすべてのツールと設定を確実に行えるようにすることができます。

リポジトリへの書き込み権限を持つユーザは、デフォルトの codespace 設定を作成または編集できます。

Codespacesは、GitHub FreeもしくはGitHub Proを使っているユーザアカウントで利用できます。 For more information, see "GitHub's products."

ここには以下の内容があります:

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

OR, learn how to contribute.

注釈: 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 拡張機能のすでに用意された設定を使用して素早く開始できます。

  1. vscode-dev-containers リポジトリをクローンまたはダウンロードします。
  2. vscode-dev-containers リポジトリで、コンテナフォルダに移動し、プロジェクトのニーズに合わせてコンテナ設定を選択します。 例として、Node.js & JavaScript コンテナ設定を使用します。
  3. Node.js & JavaScript フォルダから、.devcontainer フォルダをプロジェクトのリポジトリのルートにコピーします。
  4. 新しい設定をコミットして、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のエディタ設定を行う際には、WorkspaceRemote [Codespaces]Userという3つのスコープが利用できます。 複数のスコープ内で定義された設定については、Workspaceの設定が優先され、次がRemote [Codespaces]、そしてUserとなります。

2 つの場所で Visual Studio Code のデフォルトのエディタ設定を定義できます。

  • .vscode/settings.json で定義されたエディタ設定は、Workspace スコープの設定として codespace に適用されます。
  • devcontainer.json設定キーで定義されたエディタ設定は、codespace の リモート [Codespaces] スコープ設定として適用されます。

サポートされている codespace 設定キー

devcontainer.json の Codespaces でサポートされている設定キーを使用できます。

一般設定

  • name
  • settings
  • extensions
  • forwardPorts
  • devPort
  • postCreateCommand

Docker、Dockerfile、またはイメージ設定

  • image
  • dockerFile
  • context
  • containerEnv
  • remoteEnv
  • containerUser
  • remoteUser
  • updateRemoteUserUID
  • mounts
  • workspaceMount
  • workspaceFolder
  • runArgs
  • overrideCommand
  • shutdownAction
  • dockerComposeFile

devcontainer.json で使用可能な設定の詳細については、Visual Studio Code ドキュメントの「devcontainer.json の参照」をご覧ください。

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

OR, learn how to contribute.