The nomad developer setup #2: infrastructure as code
In a first article, I shared a quick and easy way to access VScode from any browser. You still need to create a cloud provider account and setup a server. In this second article I will share with you a way to automate all the steps needed from the moment you have created your account to using VScode in the browser. In order to do this I am sharing a GitHub repo at the end of this article. It contains all the Infrastructure as Code (IaC) you need.
IaC is a practice in software engineering, mostly on the devops side, that involves managing and provisioning infrastructure through code, rather than manual processes. It allows for the automated deployment and configuration of infrastructure, enabling consistency, scalability, and version control for your infrastructure.
The repository combines three very powerful tools: Packer, Ansible and Terraform.
- Packer is a tool to create machine images avoiding to re-install everything every time you start an instance.
- Ansible is an automation tool that simplifies complex tasks like configuration management. In a simple yaml file (a playbook) you can install and configure your server(s).
- Terraform is an infrastructure as code tool that enables the provisioning and management of cloud resources using declarative configuration files.
Please check the README carefully, it lists the current limitations and will be updated when the repo evolves.
In a next article I will add even more automation to it using a ci/cd (continuous integration and continuous delivery) pipeline using GitHub workflow to allow you to start/stop this infrastructure as you wish without accessing anything else than a web browser.
The nomad developer setup #1: A guide for beginners
Fun fact, I first wrote this article on another platform when working on Bluwr in a train. No matter the distance, it is always nice to be able to work from anywhere you want. All you need for this setup to work is an access to a web browser.
In this article I will share part of the setup that I am using. It is the first one of a series where I will be covering the whole setup I am using.
This first article is about how to set up vscode to work from any device with a web browser. Visual Studio Code is a text editor by microsoft. It can be customized with an almost infinite number of plugins. We will be using vscode in a client/server mode. The vscode server will be running on a virtual machine hosted by a cloud provider, the client can be any web browser. We will use the browser to connect to the vscode server. The interface inside the web browser will be identical to the standard vscode interface, and you will be able to edit any file on the virtual machine.
So first you need a host. Any cloud provider will do, the only thing you need is an IP address and a user that can ssh to the host. Side note here, I almost exclusively use ssh keys, never user/password to connect to cloud hosts as it is way more secure.
Once the ssh session started, install docker if not already available on the host. the execute the following command:
docker run -d \
-p 8443:8443 \
-e PASSWORD=”1234” \
We could basically end this article right now. However, there are a few more things I want to talk about. These points took me a bit of time figure out and I thought I’d share them with you:
1. How to make sure you don’t have to re-install all your plugins every time you start a new code server instance
2. How to make sure your settings stored, so you don’t have to manually re-enter them every time you restart your docker container
3. How to set a custom working directory where all your code will be stored
These are all technically achieved using the same principle: bind mount a folder of your host to a dedicated folder in the docker container.
If you look at the container folder structure, you can see that all plugins are installed in the /config/extensions folder. Vscode configuration in the container is stored in /config/data/User/settings.json. If you have been using vscode for sometime and would like to use that same configuration, you can take that existing settings file and put it somewhere on your virtual machine. Finally, to get a defined workspace, you can bind mount the folder where you usually put your code to the one that is dedicated to it in the container.
The full command is :
docker run -d \
-p 8443:8443 \
-e PASSWORD="1234" \
-v "/home/username/vscode_extensions:/config/extensions" \
-v "/home/user/vscode_settings:/config/data/User/" \
-v "/home/user/workspace/:/config/workspace" \
To save money, I only start and pay for cloud resources when I need them. Of course, I don’t repeat all these steps and re-install all the tools I need each time I start a new virtual machine. I use a packer/ansible/terraform combination to create a snapshot that I can use as a base image each time I create a new host. This will be the subject of my next article.
Now, working from anywhere as a digital nomad is really nice and convenient, but does not mean you should work all the time. I made this setup originally only to be geographically free, I still make it a point to have a healthy work/life balance. I have many hobbies and would not trade them for more hours of coding.
Automation existed long before the advent of AI.
Automation, the process of leveraging technology to perform tasks without human intervention, has a rich history that long precedes the rise of artificial intelligence.
The textile industry, in the early 1800s, witnessed the introduction of automated looms that could weave fabric without constant manual operation. Before the Jacquard loom, weaving complex designs required workers who manually operated looms for long hours. The Jacquard Loom laid the foundation for the development of modern computing concepts like binary systems and programming, as its punch cards served as an early form of programming instructions
The mid-20th century brought forth the development of programmable computers. These machines facilitated automation by executing predefined instructions, enabling the automation of complex calculations, data processing, and control systems in various industries.
While AI has undeniably transformed automation, introducing powerful capabilities such as machine learning and cognitive reasoning, it is crucial to recognize that thoughtful application remains key. When used judiciously, AI significantly enhances automation and innovation, ultimately leading to a promising futur.