Setup a Chromebook for web development
By: Matt Gosden
Tags: Python, Chrome OS, Pixelbook, Software Development, Django

Can I set up a Chromebook for software development? What do I need to install? And is it actually any good for development?

I have been playing with a Chromebook recently. I like how they are small and low power. They are also useful for taking on the road. I have been exploring how well a Chromebook works as the main development machine on the go.

This post covers the installation of the main tools to get the Chromebook ready for development.

2020 update — new scripts

There are now some scripts available you can use (at your own risk) that automate many of the steps involved in this post. You can read about it here or on the Github repo.

Our software development stack

These are the tools we will install and set up on the Chromebook:

Python 3.7 — so need to upgrade from the standard Python 3.5 on the Chromebook

Pip, pipenv, virtual environments and various python packages for development using Django, Flask, and Dash

Postgres and PGAdmin — for the webapp backend

Docker — for deploying apps and testing containerisation

VS Code — for writing and editing the code — my current preferred IDE

The full set up took less than 45 mins.

Which Chromebook?

In theory most mid-level and up Chromebooks can be used for development. I have a second-hand 128GB i5 Pixelbook with 8GB of memory which is more than sufficient for the task. No lag or performance issues.

Google Pixelbook i5 being used for development

Enable Linux on ChromeOS

Up until a few months ago, you needed to set up Crouton or the Chromebook development mode to use Linux. But now it is available in the normal setup. This is much more pleasant to use.

To enable Linux mode in your Chromebook, go to your system settings, scroll down to the, Linux settings (currently in Beta at the time of writing this) and enable Linux.

This will then kick off a process which will take a few seconds to enable Linux on your Chromebook.

To enter a Linux terminal, go to your Chrome search and type Linux or Terminal. This will take you into the settings.

Install an IDE (VS Code)

I have been using VS Code for the last few months and like how it works. It is both fully-featured and also relatively light so that it runs on many machines.

To install — Download the latest VS Code version for the Debian Linux and follow the simple installation

To access VS Code from any project directory type code . from that directory in the Terminal.

Alternatively VS Code can be loaded any time as an app from the Chrome search — Push the Chrome button, and search for the VSCode icon.

Install Python 3.7

The ChromeOS Linux build comes with python 3.5 installed. Typing python3 on the command line fires up the default Python 3 version.

I wanted to upgrade to Python 3.7 for development. The easiest option seems to be to install Python 3.7 from source.

First install some of additional prerequisites to avoid compile errors later on. This seemed to do the job

$ sudo apt-get install libffi-dev

Then download Python 3.7, compile and install. The instructions here work well and installed 3.7 with no errors in about 5 minutes.

Typing python3.7 on the command line will check the installation and open the Python 3.7 shell.

Set up pip and virtual environments

Next we needed pip and virtualenv to set up multiple development environments and give access to the packages.

Detailed instructions for this installation are contained in this Github Gist.

The following were the key installation steps I took on my Chromebook:

Install the nano editor

$ sudo apt-get install nano

Install pip and its prerequisites

$ sudo apt-get install build-essential libssl-dev libffi-dev

$ sudo apt-get install python python-dev python-pip

$ sudo apt-get install python3 python3-dev python3-pip

Add the updated path to the bash shell by adding the following line to the .profile file in your home directory.

$ nano ~/.profile # Add this line

export PATH="$PATH:$HOME/.local/bin"

Then run source ~/.profile or reboot to pick up these new environment variables.

Install virtualenv to enable creation of different virtual environments for different packages.

$ pip install --user virtualenv

Creating new virtual environments (in my case in a new .virtualenvs directory) then works as normal

$ mkdir ~/.virtualenvs

$ cd ~/.virtualenvs $ virtualenv -p python3.7 my_new_environment

Activating virtual environments is done as usual using

$ source ~/.virtualenvs/my_new_environment/bin/activate

Packages now install nicely using pip

$ (my_new_environment) pip install numpy

Install Docker

Most of our apps are deployed in docker containers. I was interested to see whether the Chromebook would play nicely with adding Docker into the development pipeline.

To install Docker, first install some prerequisites

$ sudo apt-get update

$ sudo apt-get install apt-transport-https ca-certificates \

curl gnupg-agent software-properties-common

Install docker itself

$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

"deb [arch=amd64]

$(lsb_release -cs) \

stable" $ sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) \stable" $ sudo apt-get update

$ sudo apt-get install docker-ce

Test docker

To check if docker is working run the hello-world container

$ sudo docker run hello-world

This should give you the hello world message from Docker which shows everything is working nicely.

More details can be found on the Docker installation site.

As your storage will probably be limited on your Chromebook, you will regularly want to clean out your docker images and containers before they eat up too much space. The docker prune command will be very helpful

$ sudo docker system prune [-a]

Databases

Install Postgres

To create web apps we use Postgres as the back-end database. Other options back-end tools might include Mongo DB, Redis, or other databases.

To install the database we follow the normal Debian Linux installation

$ sudo apt install postgresql postgresql-contrib

More detailed instructions for Debian Linux installation are here.

Install a database manager (DBeaver)

Usually I would use PGAdmin4 for managing the database in a nice GUI. But I did not find a nice way to install PGAdmin on the Chromebook.

Instead we opted to install for DBeaver, which was simple to install and is more fully-featured.

The easiest method to install was to download the DBeaver package for Debian Linux from the official downloads page. Click to install DBeaver, and then open the application using dbeaver from the Linux terminal.

Alternatively do it all with Docker

Instead of running the database locally and having all of this database installation to do, now we have Docker we can run our full app in Docker.

The benefit of this approach is that you don’t need to install and manage all the database tools locally. The way to do this is covered in other posts, for example here.

Final steps

Clone your projects

Pull down development projects by cloning repositories from GitHub or Bitbucket, install the requirements as usual and get coding.

Set up SSH keys

For communicating with code repositories and avoiding the need for passwords, you can set up SSH keys on the Linux virtual machine.

From your home directory, to create keys in your .ssh folder

$ ssh-keygen -t rsa -b 4096 -C "email@my_email.com"

Install the public key on your Github or Bitbucket account.

Getting ‘localhost’ to work

This is an important quirk to be aware of when developing software on a Chromebook

When building or web apps on a local machine, or running docker containers locally, we usually access the app from our browser at http://localhost:8080 (or another port number). We can then see the app in development.

Unfortunately this doesn’t usually work on a Chromebook. In the Chromebook, the Linux terminal environment is essentially a separate machine within your Chromebook. Therefore ‘localhost’ points to the wrong machine when you access it from your normal Chrome browser.

There are two simple workarounds when this is the case:

Use http: //penguin.termina.linux.test:8080/ (assuming your app is on port 8080) from your normal browser, in place of http://localhost:8080 .

(assuming your app is on port 8080) from your normal browser, in place of . Or, install a browser within your Linux environment, fire it up, and use that browser instead — it should be able to see the right localhost

For bonus points — If you want to see exactly what IP address your Linux virtual machine is using so that you can connect to it from your main Chromebook machine, you can use ip address in the terminal and see the IP of the external connection.

Proof — the Chromebook running a full Django / Postgres app and the development server

So how well does the Chromebook work as a dev machine?

Having used the Chromebook for development now for a few days on the road, I can say it works pretty much as well as any small Macbook or PC would.

The installation was a little more complex, but not much.

The Chromebook setup is fast enough for most coding tasks. However I have noticed the performance is significantly lower when running tests or database-heavy tasks.

Docker works well, but you need to make sure you clean out old images regularly to avoid running out of space

It really comes into its own though when on the road as it is nice and small, has a great screen, great browser experience, and has a super battery life.

Score = 8/10