Post

Any Adhd Devs Here Hate Your Chair

Welcome, fellow DevOps enthusiasts and self-proclaimed chair haters! This article is specifically designed for those who have ADHD (or just a restless spirit) and are seeking to create an optimized,.

# Any ADHD Devs Here? Hate Your Chair!

Welcome, fellow DevOps enthusiasts and self-proclaimed chair haters! This article is specifically designed for those who have ADHD (or just a restless spirit) and are seeking to create an optimized, efficient, and automation-friendly homelab setup. We’ll guide you through the process of setting up a self-hosted infrastructure tailored to accommodate your unique work style.

Prerequisites

To ensure a smooth experience, we recommend having the following software installed:

  1. Ubuntu 20.04 LTS or later: This is the operating system we’ll be working with for our homelab. You can download it from official Ubuntu website.

  2. Docker CE v5.0.8+: Docker containers will be instrumental in creating and managing our services. Install Docker using the following command: apt install docker-ce=5.0.8.

  3. Docker Compose v1.27.4+: This tool simplifies writing multi-container Docker applications. Run curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose to download the latest Compose version, then make it executable using chmod +x /usr/local/bin/docker-compose.

  4. Git: Git will help us manage our project’s source code. Install Git with this command: apt install git.

  5. Node.js v12.x or later: For any frontend projects and tools like Docker Compose UI, if needed. Install Node.js using the official Node.js installation script according to your system requirements.

Setting Up Your Homelab

Now that you have all the necessary tools installed, let’s dive into creating an efficient and automation-friendly homelab setup.

Step 1: Initialize Your Project

Create a new directory for your project, navigate to it using the command line, and initialize a Git repository with git init.

1
2
mkdir myhomelab && cd myhomelab
git init

Step 2: Create Docker Compose Configuration Files

Next, create two YAML files named docker-compose.yml and docker-compose-dev.yml. These configuration files will define our services’ setup for production and development environments, respectively.

docker-compose.yml

1
2
3
4
5
6
7
8
9
version: '3.8'
services:
  app:
    image: myapp:latest
    environment:
      - NODE_ENV=production
    ports:
      - "80:80"
    restart: always

docker-compose-dev.yml

1
2
3
4
5
6
7
8
9
version: '3.8'
services:
  app:
    image: myapp:latest
    environment:
      - NODE_ENV=development
    ports:
      - "8080:80"
    restart: always

Replace myapp with the name of your application. The Docker images should be built and published using a proper CI/CD pipeline or manually, if needed.

Step 3: Set Up Environment Variables

Create a .env file to store sensitive information like database credentials or API keys. An example .env file could look like this:

1
2
3
DB_USERNAME=mydbuser
DB_PASSWORD=mypassword
API_KEY=myapikey

Be sure to use proper security practices when storing sensitive information and never commit the .env file to version control!

Step 4: Automate Your Homelab

Use a combination of Docker Compose, scripts, and tools like Ansible or Terraform to automate your homelab setup. The exact choice depends on your specific needs and preferences.

For example, create an ansible-playbook.yml file with the following content:

1
2
3
4
5
6
7
8
---
- name: Set up myhomelab
  hosts: localhost
  tasks:
    - name: Install Docker Compose
      pip: pkg=docker_compose
        executable=_binary
        version='2.17.3'

This playbook installs Docker Compose, assuming you have Ansible already installed on your system.

Troubleshooting

Permission Errors

If you encounter permission issues when running commands as a non-root user, use sudo or change the ownership of files and directories using the chown command.

Network Configuration Issues

If your application is unable to connect to external services or databases, ensure that the necessary ports are open in your firewall configuration and adjust them accordingly.

Conclusion

By following this guide, you have taken a significant step towards creating an efficient and automation-friendly homelab setup. With the right tools and practices, even ADHD Devs can thrive in their work environment! Stay tuned for future articles that dive deeper into various aspects of self-hosting infrastructure and automating your DevOps workflow.

Happy coding, and remember to take breaks when needed! 💻🧘‍♂️

This post is licensed under CC BY 4.0 by the author.