Skip to content

Instantly share code, notes, and snippets.

@devlights
Created December 22, 2023 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devlights/939352a6fdadac1b6a595e5db7171cf6 to your computer and use it in GitHub Desktop.
Save devlights/939352a6fdadac1b6a595e5db7171cf6 to your computer and use it in GitHub Desktop.
Use Gitpod CLI

Gitpod on Local Command Line

Install

$ brew install gitpod-io/tap/gitpod
==> Tapping gitpod-io/tap
Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/gitpod-io/homebrew-tap'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (40/40), done.
remote: Total 63 (delta 12), reused 53 (delta 10), pack-reused 0
Receiving objects: 100% (63/63), 21.01 KiB | 1.31 MiB/s, done.
Resolving deltas: 100% (12/12), done.
Tapped 1 formula (16 files, 134.4KB).
==> Fetching gitpod-io/tap/gitpod
==> Downloading https://gitpod.io/static/bin/gitpod-cli-linux-amd64
########################################################################################################################################## 100.0%
Warning: Cannot verify integrity of '998ea5409698932806d6379b7719e80a0fa31eb0820409d708eb2fad03b71394--gitpod-cli-linux-amd64'.
No checksum was provided.
For your reference, the checksum is:
  sha256 "7859e2f5dfff7c6e6e5a3c487d236ed5d8573de86c2e05acca230f6bf80d6ee6"
==> Installing gitpod from gitpod-io/tap
🍺  /home/linuxbrew/.linuxbrew/Cellar/gitpod/0.1.4: 3 files, 26.7MB, built in 0 seconds
==> Running `brew cleanup gitpod`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
$ which gitpod
/home/linuxbrew/.linuxbrew/bin/gitpod

次にGitpod上でアクセストークンを発行する。

やり方は AccessToken を参照。

Login

$ gitpod login --token $GITPOD_TOKEN
Dec 22 13:48:30.831 [WARN ] could not write token to keyring, storing in config file instead. Use -v to see the error.
Dec 22 13:48:33.150 [INFO ] login successful

User name:       user1
User ID:         xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Organization:    user1
Organization ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Host:            https://gitpod.io

Create Workspace (SSH)

$ gitpod workspace create https://github.com/gitpod-io/empty --ssh
Dec 22 13:54:56.497 [INFO ] waiting for workspace to start... workspaceID=gitpodio-empty-6cq1udujhac
Dec 22 13:54:56.497 [INFO ] workspace status: preparing
Dec 22 13:54:59.389 [INFO ] workspace status: pending
Dec 22 13:54:59.389 [INFO ] workspace status: creating
Dec 22 13:54:59.389 [INFO ] workspace status: pending
Dec 22 13:54:59.389 [INFO ] workspace status: initializing
Dec 22 13:54:59.392 [INFO ] workspace status: preparing
Dec 22 13:54:59.392 [INFO ] workspace status: pending
Dec 22 13:54:59.393 [INFO ] workspace status: creating
Dec 22 13:55:02.707 [INFO ] workspace status: initializing
Dec 22 13:55:03.322 [INFO ] workspace running
Warning: Permanently added 'gitpodio-empty-6cq1udujhac.ssh.ws-eu107.gitpod.io' (ECDSA) to the list of known hosts.
Welcome to Gitpod: Always ready to code. Try the following commands to get started:

        gp tasks list         List all your defined tasks in .gitpod.yml
        gp tasks attach       Attach your terminal to a workspace task

        gp ports list         Lists workspace ports and their states
        gp stop               Stop current workspace
        gp help               To learn about the gp CLI commands

For more information, see the Gitpod documentation: https://gitpod.io/docs
 $ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ lscpu | grep 'CPU(s)'
CPU(s):                             16
On-line CPU(s) list:                0-15
NUMA node0 CPU(s):                  0-15
$ free -h
               total        used        free      shared  buff/cache   available
Mem:            62Gi        21Gi       4.3Gi       1.8Gi        37Gi        39Gi
Swap:          374Gi        79Mi       374Gi

Install Go

$ brew install golang
$ go version
go version go1.21.5 linux/amd64
$ go mod init app
go: creating new go.mod: module app

$ vim main.go

$ go fmt
$ go vet
$ go build

$ ./app
hello world

Stop workspace

exitでシェルを終了してもワークスペースは動いたままなので注意。

ワークスペースを停止させる場合は gp stop を実行。

$ gp stop
Connection to gitpodio-empty-qbnso39or4b.ssh.ws-eu107.gitpod.io closed by remote host.
Connection to gitpodio-empty-qbnso39or4b.ssh.ws-eu107.gitpod.io closed.
Error: exit status 0xffffffff
$ gitpod workspace list | head -n 2
ID                                REPOSITORY             BRANCH STATUS
gitpodio-empty-6cq1udujhac        gitpod-io/empty        main   stopped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment