read

I love Visual Studio Code. It has been a workhorse for me both professionally and personally. When I stumbled upon a project called code-server, I was blown away by the ability to easily stand up an instance of vscode accessible by a web browser from anywhere in the world. Personally, I keep a web server with this running 24/7 so that I can access it anytime anywhere and its incredible. I've used it countless times when I needed to quickly pull down a repo to make a change while traveling with only my iPad.

I even created a nice little gist for quickly spinning up code-server using docker-compose.

There are many other imaginable situations where having this capability would be quite useful as well. And as much as I have come around to actually liking vim (stockholm syndrome? :q!), I still find myself wanting for the ease and vast eco-system that vscode provides.

Having run into many situations where I wished I had the power of my beloved editor and all its wonderful extensions at my fingertips, I finally set out to create (dare I say it) a turnkey solution to my problems. Something that could be spun up with a single command when I needed it without any impact on the system I was using it on. Docker, code-server and ngrok to the rescue.

code-anywhere is simply an integration of these 3 technologies into a single docker image which can be built and run on any server where docker is installed.

The README has more advanced instructions for further customization, but the quick start instructions go like this:

  1. Build the docker image with your current user's id and group id

    git clone git@github.com:bitbldr/code-anywhere.git
    cd code-anywhere
    docker image build \
    --build-arg USER_ID=$(id -u ${USER}) \
    --build-arg GROUP_ID=$(id -g ${USER}) \
    -t code-anywhere:${USER} \
    .
    
  2. Run the docker container

    docker run -it --rm -e PASSWORD=changeme -v `pwd`:/workspace code-anywhere:${USER}
    

That's it! Your container logs will print out a publicly accessible ngrok url where you can access your instance, no firewall or port configuring needed. The current working directory will be mapped into the container so you can edit any files and subdirectories as your current user.

Make sure you change the PASSWORD variable to something secure so that only you can access it from the web!

Check out the repository and full instructions at https://github.com/bitbldr/code-anywhere.

Blog Logo

Eli Knebel

I'm a software developer in Pittsburgh, where I was born and raised. Part-time maker, traveler and bread baker. Skiing during the winter months, kayaking in the summer.


Published