Tech Blog

クラウド開発環境をセルフホストする

Cover Image for クラウド開発環境をセルフホストする

いつ如何なる時も開発ができる環境を作りたいので、 GitHub Codespaces のようなクラウド開発環境をセルフホストして運用してみる
今回は Open Source Project の選択肢 GitPod, Coder, DevPod の中から DevPodRaspberry Pi 5 で試してみる

今回の環境

TL;DR

1. 環境を用意する

neofetch

sudo apt upgrade -y
The following packages will be upgraded:
  libgssapi-krb5-2 libk5crypto3 libkrb5-3 libkrb5support0 libssl3 openssl raspi-config
7 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

2. Docker をインストールする

curl https://get.docker.com | sh
# Executing docker install script, commit: 1ce4e39c9502b89728cdd4790a8c3895709e358d
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq ca-certificates curl >/dev/null
+ sudo -E sh -c install -m 0755 -d /etc/apt/keyrings
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/debian/gpg" -o /etc/apt/keyrings/docker.asc
+ sudo -E sh -c chmod a+r /etc/apt/keyrings/docker.asc
+ sudo -E sh -c echo "deb [arch=arm64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin >/dev/null
+ sudo -E sh -c docker version
Client: Docker Engine - Community
 Version:           27.1.1
 API version:       1.46
 Go version:        go1.21.12
 Git commit:        6312585
 Built:             Tue Jul 23 19:57:14 2024
 OS/Arch:           linux/arm64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.1.1
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.12
  Git commit:       cc13f95
  Built:            Tue Jul 23 19:57:14 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.7.19
  GitCommit:        2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41
 runc:
  Version:          1.7.19
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

================================================================================

To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:

    dockerd-rootless-setuptool.sh install

Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.


To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/

WARNING: Access to the remote API on a privileged Docker daemon is equivalent
         to root access on the host. Refer to the 'Docker daemon attack surface'
         documentation for details: https://docs.docker.com/go/attack-surface/

================================================================================
sudo usermod -aG docker $USER
newgrp docker

3. DevPod CLI をインストールする

curl -L -o devpod "https://github.com/loft-sh/devpod/releases/latest/download/devpod-linux-arm64" && sudo install -c -m 0755 devpod /usr/local/bin && rm -f devpod
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 65.5M  100 65.5M    0     0  22.8M      0  0:00:02  0:00:02 --:--:-- 35.9M
devpod provider add docker
16:08:44 done Successfully installed provider docker
16:08:44 done Successfully configured provider 'docker'

4. Workspace を作成する

devpod up github.com/microsoft/vscode-remote-try-node --ide openvscode
0:09:10 info Creating devcontainer...
16:09:10 info Cloning into '/home/pi/.devpod/agent/contexts/default/workspaces/vscode-remote-try-node/content'...
16:09:10 info Inspecting image mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye
16:09:11 info Image mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye not found
16:09:11 info Pulling image mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye
16:17:02 info aee5bad9486d15ea802d871ac17250af0214a34a8a69b45a8431573c2c9c1da8
16:17:20 info Setup container...
16:17:20 info Chown workspace...
16:17:20 info Chown projects...
16:17:20 info Run command : yarn install...
16:17:20 info yarn install v1.22.19
16:17:21 info [1/4] Resolving packages...
16:17:21 info [2/4] Fetching packages...
16:17:21 info [3/4] Linking dependencies...
16:17:23 info [4/4] Building fresh packages...
16:17:23 info Done in 2.93s.
16:17:23 done Successfully ran command : yarn install
16:17:34 info Install extensions 'dbaeumer.vscode-eslint,streetsidesoftware.code-spell-checker' in the background
16:17:34 info Starting openvscode in background...
16:17:34 info Run 'ssh vscode-remote-try-node.devpod' to ssh into the devcontainer
16:17:34 info Starting vscode in browser mode at http://localhost:10800/?folder=/workspaces/vscode-remote-try-node
16:17:41 done Successfully opened http://localhost:10800/?folder=/workspaces/vscode-remote-try-node
16:17:41 info Successfully started vscode in browser mode. Please keep this terminal open as long as you use VSCode browser version

5. タブレットからアクセスしてみる

VSCode for the Web

参考にしたページ