Using Chromebook as a Development Workstation
Tags: chromebook, devcontainers, programming, docker
Published: 2023-12-26 09:01:17

# Introduction
Chromebooks are becoming more popular as time goes on. With the adoption of devcontainers using a chromebook as your developer workstation becomes a viable alternative. In this post I will show you how I have setup my chromebook as a development workstation using Docker and Visual Studio Code.

# Devcontainers and Dotfiles
This setup is designed with Devcontainers and Dotfiles in mind. I'm not going into depth on this subject being that there is a lot of information on these topics. If you would like me to cover these topics for use in this setup leave a comment and I'll write a post explaining how to setup Devcontainers and Dotfiles.

# Enable Linux Development Environment
Open Settings → Advanced → Developers
Next to "Linux development environment," select Turn On.
Follow the on-screen instructions.

# Installing Docker
While you can use codespaces to use your chromebook as a thin client, I've always preferred my own hardware. So we're going to install docker running the following commands:

```sh
sudo apt-get update
sudo apt-get install software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > docker.gpg
sudo install -o root -g root -m 644 docker.gpg /usr/share/keyrings/docker-keyring.gpg
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list'
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER
```
These commands in order:

- Update the package database
- Install lsb_release to get the Debian version
- Download the Docker GPG Key
- Install the Docker Keyring
- Add the Docker Deb repository to APT
- Update the package database to add docker
- Install Docker
- Add your user to the docker group
You will need to restart for your user to be added to the docker group.

# Installing Visual Studio Code
While you can use any IDE that can run on linux vscode has the best devcontainer support imho. The commands to install vscode are:

```sh
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /usr/share/keyrings/microsoft-archive-keyring.gpg
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install code # or code-insiders
```
These commands in order:

- Download the Microsoft GPG Key
- Install Microsoft's Keyring
- Add the VSCode Deb repository to APT
- Update the package database to add VSCode
- Install VSCode

# Quality of Life Tweeks
These are random tweeks that I have done after doing the above. If you followed the top steps you should have a working development workstation, these are random fixes to tweek the setup to be less overhead on a chromebook.

## VSCode Title Bar
If you use dark mode like me, you might have noticed that the default title bar is light mode. My solution for that was to set the title bar style to custom.

Open menu File → Preferences → Settings

and add the following setting:

"window.titleBarStyle": "custom"

## Prune Docker Storage
Chromebooks typically do not have much storage space so unneeded and old files need to be removed regularly where you do not run out of storage. My solution for this was to create an systemd timer which removes containers and images not used in a week and unnamed volumes.

/etc/systemd/system/docker-purge.service
```
[Unit]
Description=Prune Docker Older than 1 Week
Requires=docker.service
Wants=docker-purge.timer

[Service]
Type=oneshot
ExecStart=/usr/bin/docker system prune -fa --filter "until=168h"
ExecStart=/usr/bin/docker volume prune -f

[Install]
WantedBy=multi-user.target
```

/etc/systemd/system/docker-purge.timer
```
[Unit]
Description=Prune Docker Older than 1 Week
Requires=docker-purge.service

[Timer]
Unit=docker-purge.service
OnCalendar=daily
AccuracySec=24h

[Install]
WantedBy=timers.target
```

After you created these files enable and start the timer by running:
```sh
sudo systemctl enable docker-purge.timer
sudo systemctl start docker-purge.timer
```

## Unattended Upgrade
While I would never suggest full unattended upgrades on a production server, it makes perfect sense on a chromebook since VSCode and Docker are running on a slim container with minimal services and having to remember to go in and running upgrades yourself takes time. All that is needed is to go into the following file and change this section to.

/etc/apt/apt.conf.d/50unattended-upgrades
```
Unattended-Upgrade::Origins-Pattern {
"origin=*";
};
```

# Request For Comments
This setup is what I am currently using. I would love to hear your thoughts and ideas for improvement.