Creating a Dev Server

Creating a Dev Server

in

I had an old LG Gram laptop with a ton of memory on it gathering dust. I’ve been meaning to create a development environment for my future endeavors, 2 birds, 1 stone. My goals were as follows:

  1. Open source OS that doesn’t require too much upkeep
  2. Auto healing environment
  3. Easy to deploy
  4. Learn something

Installing Ubuntu on an Old Laptop

To get started, you’ll need to install Ubuntu on your old laptop. You can download the latest version of Ubuntu from the official Ubuntu website and follow the installation instructions to install it on your laptop.

Once you have Ubuntu installed, you’ll need to update your system and install some necessary packages. Run the following commands in a terminal to update your system and install the necessary packages:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y curl wget

Setting Up Local SSH Access

It’s important to set up local SSH access for easy access to your server. To set up local SSH access, you’ll need to install the OpenSSH server on your Ubuntu laptop. Run the following command to install it:

sudo apt-get install openssh-server

Then to enable it on startup and to run it run the following:

systemctl enable sshd && systemctl start sshd

Once the OpenSSH server is installed, you can log in to your server locally by opening a terminal and typing:

ssh user@laptop-ip-address

Where “user” is your username on the server. You can find your laptop’s external IP address by looking at your eth0 broadcast IP or looking at your router’s network.

Setting Up SSH Access Through Tailscale

Next, we’ll set up remote SSH access through Tailscale. Tailscale is a VPN service that allows you to securely access your remote servers from anywhere in the world. To set up Tailscale, you’ll need to sign up for an account and install the Tailscale client on your laptop. You’ll follow the instructions from the website.

Once you have Tailscale set up, you can log in to your remote server using SSH by running the following command in a terminal:

ssh user@your-server-ip-address

Setting up Docker and Watchtower

Next, we will install Docker on our server. Docker is a platform that allows you to easily create, deploy, and run applications in containers. To install Docker on Ubuntu, run the following commands in a terminal:

sudo apt-get install docker.io
sudo systemctl start docker
sudo systemctl enable docker

Now that we have Docker installed, let’s set up the Watchtower repository. Watchtower is a simple application that automatically updates your running Docker containers. To install Watchtower, run the following command:

docker run --restart always -d --name watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower

Setting Up a Development Environment with Docker Compose

Now that we have both local and remote SSH access set up, let’s talk about setting up a development environment using Docker and Docker Compose. Docker Compose is a tool for defining and running multi-container Docker applications. By using Docker Compose, you can easily manage the different components of your application and ensure that they are always running in a consistent state.

One of the key benefits of using Docker Compose is the ability to create an autohealing environment. This means that if one of your containers fails, Docker Compose will automatically restart it, ensuring that your application stays up and running. To create an autohealing environment, you can specify the restart property in your Docker Compose file, like this:

version: '3'
services:
  my_service:
    image: my_image
    restart: always

To set up a development environment, you’ll need to create a Docker Compose file that specifies the different components of your application, including any dependencies and environment variables. Once you have your Docker Compose file set up, you can run your application using the following command:

docker-compose up

This will start all of the containers specified in your Docker Compose file and run your application in a development environment.

Github Setup

Finally, let’s set up our containers on GitHub. GitHub is a platform that allows you to store and share your code with others. To create a repository, log in to your GitHub account and follow the instructions to create a new repository. Once you have created your repository, you can use it to store your Docker containers and automatically update them using Watchtower.

In conclusion, setting up a server using Docker, Linux, Watchtower, and GitHub is a great way to turn an old laptop into a powerful and flexible development platform. By setting up local SSH access, using Docker Compose to create an autohealing environment, and using GitHub to store your containers, you can easily manage and update your applications, ensuring that they always run smoothly.