Sign inSign up

sbx/copilot-mixin:latest

Multi-platform
Manifest digest

sha256:4111c036b0494bde312a5d8f56dcb9ff54adac4d1c7fcc30037e5e62b97d7139

Last pushed

about 3 hours by dhibot

Type

Sandbox Kit

Manifest digest

sha256:4111c036b0494bde312a5d8f56dcb9ff54adac4d1c7fcc30037e5e62b97d7139

yaml
schemaVersion: "3"
displayName: GitHub Copilot (mixin)
author: Docker, Inc. https://docker.com
description: GitHub Copilot CLI overlay with authentication, network policy, and native ACP support.
sourceUrl: https://github.com/docker-hardened-images/definitions
version: 1.0.110
licenses:
    - LicenseRef-Proprietary
kind: mixin
provides:
    - [email protected]
requires:
    - deb/jq
    - deb/util-linux
    - deb/libstdc++6
capabilities:
    - type: com.docker.sandbox/network-policy@1
      config:
        runtime:
            allow:
                - api.business.githubcopilot.com:443
                - api.enterprise.githubcopilot.com:443
                - api.github.com:443
                - api.githubcopilot.com:443
                - api.individual.githubcopilot.com:443
                - copilot.github.com:443
                - github.com:443
    - type: com.docker.sandbox/credential@1
      optional: true
      config:
        apiKey:
            inject:
                - domain: api.github.com
                  format: Bearer %s
                  header: Authorization
                - domain: github.com
                  format: Bearer %s
                  header: Authorization
            name: GH_TOKEN
            proxyManaged: true
        phase: runtime
        service: github
      description: GitHub API access for git and gh
    - type: com.docker.sandbox/credential@1
      optional: true
      config:
        apiKey:
            inject:
                - domain: api.business.githubcopilot.com
                  format: Bearer %s
                  header: Authorization
                - domain: api.enterprise.githubcopilot.com
                  format: Bearer %s
                  header: Authorization
                - domain: api.githubcopilot.com
                  format: Bearer %s
                  header: Authorization
                - domain: api.individual.githubcopilot.com
                  format: Bearer %s
                  header: Authorization
                - domain: copilot.github.com
                  format: Bearer %s
                  header: Authorization
            name: COPILOT_GITHUB_TOKEN
            proxyManaged: true
        phase: runtime
        service: copilot
      description: Copilot request access, separable from the broader github token
    - type: com.docker.sandbox/lifecycle@1
      config:
        install:
            - command: mkdir -p /home/agent/.copilot && chown agent:agent /home/agent/.copilot
              description: Ensure .copilot is owned by agent before bind mounts and the config seed run
              user: "0"
            - command: |
                set -e
                cfg=/home/agent/.copilot/config.json
                if [ -e "$cfg" ]; then exit 0; fi
                if [ -z "$WORKSPACE_DIR" ]; then
                  echo "WORKSPACE_DIR unset; skipping Copilot trusted-folder seed" >&2
                  exit 0
                fi
                esc=$(printf '%s' "$WORKSPACE_DIR" | sed 's/\\/\\\\/g; s/"/\\"/g')
                printf '{"trusted_folders": ["%s"]}\n' "$esc" > "$cfg"
              description: Copilot config with trusted workspace folder
              env:
                - WORKSPACE_DIR
              user: agent
        startup:
            - command:
                - sh
                - -c
                - |
                  set -e
                  [ -n "$MCP_GATEWAY_URL" ] || exit 0
                  cfg="$HOME/.copilot/mcp-config.json"
                  dir=$(dirname "$cfg")
                  mkdir -p "$dir"
                  gateway=$(cat <<EOF
                  {
                    "mcpServers": {
                      "mcp-gateway": {
                        "type": "http",
                        "url": "$MCP_GATEWAY_URL",
                        "headers": {
                          "Authorization": "Bearer $MCP_SENTINEL_TOKEN_NAME"
                        },
                        "tools": ["*"]
                      }
                    }
                  }
                  EOF
                  )
                  # Two overlapping starts would read-modify-write the same file.
                  exec 9>>"$dir/.mcp-config.lock"
                  flock 9
                  # mv would nest the config inside a directory here and still exit 0.
                  if [ -e "$cfg" ] && [ ! -f "$cfg" ]; then
                    echo "mcp-config.json is not a regular file; leaving the MCP gateway unregistered" >&2
                    exit 0
                  fi
                  if ! merged=$({ if [ -s "$cfg" ]; then cat "$cfg"; else echo '{}'; fi; printf '%s\n' "$gateway"; } | jq -s '
                      if length != 2 or (.[0] | type) != "object" or ((.[0].mcpServers // {}) | type) != "object" then
                        error("mcp-config.json must hold one JSON object whose mcpServers is an object")
                      else
                        .[0] + {mcpServers: ((.[0].mcpServers // {}) + .[1].mcpServers)}
                      end'); then
                    echo "mcp-config.json is not readable as JSON; leaving the MCP gateway unregistered" >&2
                    exit 0
                  fi
                  # The temp name is unpredictable, so a stale or crashed leftover is never installed.
                  tmp=$(mktemp "$dir/mcp-config.json.XXXXXX")
                  trap 'rm -f "$tmp"' EXIT
                  printf '%s\n' "$merged" > "$tmp"
                  mv -f "$tmp" "$cfg"
              description: Register the sandbox MCP gateway in ~/.copilot/mcp-config.json
              env:
                - MCP_GATEWAY_URL
                - MCP_SENTINEL_TOKEN_NAME
              user: agent
    - type: com.docker.sandbox/agent-context@1
      optional: true
      config:
        content: |
            GitHub Copilot is installed as `copilot`. Authentication and network access follow this Kit's capability declarations.
    - type: com.docker.sandbox/agent-context@2
      optional: true
      config:
        content: |
            GitHub Copilot is installed as `copilot`. Authentication and network access follow this Kit's capability declarations.
    - type: com.docker.sandbox/acp@1
      optional: true
      config:
        agent: copilot
        command:
            - copilot
            - --acp
args:
    version:
        required: true
        description: GitHub Copilot release carried by the image
        pattern: ^[0-9]+\.[0-9]+\.[0-9]+$
        buildArg: VERSION