Skip to main content

Setting a minimum specification for codespace machines

You can avoid under-resourced machine types being used for Codespaces for your repository.

People with write permissions to a repository can create or edit the codespace configuration.

Codespaces is available for organizations using GitHub Team or GitHub Enterprise Cloud. 詳しい情報については「GitHubの製品」を参照してください。

概要

Each codespace that you create is hosted on a separate virtual machine, and you can usually choose from different types of virtual machines. Each machine type has different resources (CPUs, memory, storage) and, by default, the machine type with the least resources is used. For more information, see "Changing the machine type for your codespace."

If your project needs a certain level of compute power, you can configure GitHub Codespaces so that only machine types that meet these requirements can be used by default, or selected by users. You configure this in a devcontainer.json file.

Important: Access to some machine types may be restricted at the organization level. Typically this is done to prevent people choosing higher resourced machines that are billed at a higher rate. If your repository is affected by an organization-level policy for machine types you should make sure you don't set a minimum specification that would leave no available machine types for people to choose. 詳しい情報については「マシンタイプへのアクセス制限」を参照してください。

Setting a minimum machine specification

  1. Codespaces for your repository are configured in a devcontainer.json file. If your repository does not already contain a devcontainer.json file, add one now. See "Add a dev container configuration to your repository."

  2. Edit the devcontainer.json file, adding a hostRequirements property such as this:

    JSON
    "hostRequirements": {
       "cpus": 8,
       "memory": "8gb",
       "storage": "32gb" 
    }

    You can specify any or all of the options: cpus, memory, and storage.

    To check the specifications of the Codespaces machine types that are currently available for your repository, step through the process of creating a codespace until you see the choice of machine types. 詳しい情報については、「codespace を作成する」を参照してください。

  3. Save the file and commit your changes to the required branch of the repository.

    Now when you create a codespace for that branch of the repository, and you go to the creation configuration options, you will only be able to select machine types that match or exceed the resources you've specified.

    Dialog box showing a limited choice of machine types

参考リンク