Skip to Content

PairSpaces

DocsBlog

PairSpaces

Bootstrapping Spaces

How to make anything a Space

PairSpaces works with the way you work today. You can bootstrap your GitHub Codespace, Devcontainer, or Devfile and any virtual machine into a PairSpace. This section describes how to bootstrap anything into a Space.

Two Steps to Bootstrap

The PairSpaces CLI is used to make any container or machine into a Space from which you can work together with your team. The PairSpaces CLI is first used to first create a token that authorizes a container or machine to become a Space and then used to bootstrap that container or machine into a Space.

Create a Token

When bootstrapping a Space you want to associate a Space you create with the container or machine you use. The first step is to create a token that registers your container or machine as a Space. From your local machine use pair spaces authorize and select members from your team to share your Space.


> pair spaces authorize

You're ready to bootstrap your Space "dynamic_stark".

Your Space's token is valid for 1 hour and is available from 6897a7fc330b945c16a89934.txt.

This command creates a new Space that is shared with your teammates and is listed using pair spaces list. The token saved to the file is used to bootstrap your container or machine. The token is valid for 1 hour.

Bootstrap an Environment

To make a container or machine into a Space, use the PairSpaces CLI and pair spaces bootstrap TOKEN.


> pair spaces bootstrap TOKEN

Your team can connect to your Space now. Use Ctrl-C to close the connection.

Your team members can now access your Space using pair spaces connect SPACE_ID.

Bootstrapping Environments

Bootstrapping Devfiles

Devfile is an open standard for defining containers and used to produce consistent and reproducible development environments.

The Devfile standard uses a YAML configuration file to define containers. To run pair spaces bootstrap from a Devfile we recommend the following Devfile.

schemaVersion: 2.2.0
metadata:
  name: devenv

components:
  - name: devenv
    container:
      image: node:18
      mountSources: true
      command: ['sleep']
      args: ['infinity']

commands:
  - id: install-pair
    exec:
      component: devenv
      commandLine: curl -fsSL https://raw.githubusercontent.com/pairspaces/devfiles/main/install.sh | bash
      group:
        kind: run

  - id: start-supervisord
    exec:
      component: devenv
      commandLine: supervisord -c /etc/supervisor/supervisord.conf
      group:
        kind: run

  - id: bootstrap
    exec:
      component: devenv
      commandLine: |
        while [ ! -x /opt/pair/pair ]; do sleep 1; done
        /opt/pair/pair spaces bootstrap "[OUTPUT from `pair spaces authorize` HERE]"
      workingDir: /projects
      group:
        kind: run
        isDefault: true

events:
  postStart:
    - install-pair
    - start-supervisord
    - bootstrap

The devenv component represents your own image. To successfully bootstrap a Devfile container, include the commands and events in your own Devfile.

We used AWS CodeCatalyst to develop this approach, but the Devfile standard is adopted differently on different platforms. This approach should be general enough to work elsewhere, but contact us (support at pairspaces dot com) if you experience challenges using PairSpaces with your Devfile.

Bootstrapping DevContainers

Devcontainers is an open specification to define coding environments.

The Development Container specification uses a JSON configuration file to define containers. To run pair spaces bootstrap from a Devcontainer we provide a Devcontainer Feature publicly. This .devcontainer.json file describes how to bootstrap a Devcontainer.

{
  ...,
  "features": {
    "ghcr.io/pairspaces/devcontainers/pairspaces:0.8.6": {
      "token": "[OUTPUT from `pair spaces authorize` HERE]"
    }
  },
  "postStartCommand": "supervisord -c /etc/supervisor/supervisord.conf",
  "postAttachCommand": "/opt/pair/pair spaces bootstrap",
  "remoteUser": "root",
  ...
}

To complete this configuration include the output from pair spaces authorize in the token field.

We used GitHub Codespaces to develop this approach. This approach should be general enough to work elsewhere, but contact us (support at pairspaces dot com) if you experience challenges using PairSpaces with your Devcontainer.

Previous

Sharing Services

Next

AWS