Local Node

Jan 26, 2025·7 min read

So you’ve found yourself here. Maybe it’s for fun, or maybe you have to make a living. In either case, I welcome you to the fold. For the past few years, I’ve tried to host everything on machines I have at home. I’m partial to that approach because it keeps me close to the hardware and in full control of my data, you also learn a ton! This small guide is on getting started with running servers and deploying your own applications.

The Machine

The easiest place to start is getting yourself a physical server to play with. Since the server is in your possession, it’s trivial to restart if you make a mistake or hit a wall. The kind of device you get depends on what you’d like to do:

  • General Use (Beginner-Friendly): For a decent all-rounder, I’d recommend a Raspberry Pi 3/4/5 running Ubuntu Server. They have a large community, lots of guides, and extensive documentation.
  • GPUs: For workloads like running LLMs, consider NVIDIA’s Jetson series.
  • Network Attached Storage (NAS): A Synology NAS is a great prebuilt, user-friendly system. It’s perfect for file storage, backups, media streaming, and even running Docker containers. Synology’s DiskStation Manager simplifies many tasks, making it ideal for home or small business use.

If you prefer not to use physical hardware, cloud providers like AWS, Google Cloud, or DigitalOcean offer virtual servers.

Tips:

  • Always check power requirements and form factor before buying.
  • Check second-hand listings for cost-effective older Synology models or Raspberry Pis.
  • Consider a Proxmox setup if you want more flexible virtualization later on (more advanced).

The Software

Choosing an Operating System

Linux is the most widely used operating system for servers. For beginners, Ubuntu Server is a great choice. It’s lightweight, optimized for performance, and command line–oriented, which mirrors most production environments. Other popular Linux distributions include Debian, CentOS Stream, and Alpine Linux for ultra-lightweight setups.

Accessing Your Server

Connecting to your server is the first step to managing and interacting with it. Essentially, you’re setting up a way to communicate with the machine, whether it’s to configure it, run applications, or monitor its performance. Think of it as establishing a line of conversation where you can give commands and receive feedback. Depending on your setup and preferences, there are several ways to achieve this.

Direct Hardware Connection (HDMI and Peripherals)

  • Setup: Plug in a monitor (e.g., HDMI) plus a keyboard and mouse.
  • Use Case: Helpful for first-time configuration or when remote methods fail.
  • Steps: Boot the server, log in locally, and configure basics like networking.

SSH (Secure Shell)

  • Setup:

    sudo apt update && sudo apt install openssh-server
    ip a  # to check your server’s IP
    sudo systemctl enable ssh && sudo systemctl start ssh
    
  • Connecting from Another Machine:

    ssh username@server-ip
    

    Replace username and server-ip with your actual details.

  • Tip (Security): Use SSH key pairs:

    ssh-keygen -t rsa -b 4096
    ssh-copy-id username@server-ip
    

Serial Console

  • Setup: Connect a serial cable to another computer if your server has a serial port.
  • Use Case: Useful for headless servers or deeper troubleshooting.
  • Tools: PuTTY or screen on Linux.

Web-Based Tools

  • Portainer (for Docker): Manage Docker containers via a browser.
  • Synology DiskStation Manager: Comes built-in if using a Synology NAS.
  • Cockpit: Cockpit for a modern, web-based Linux server interface.

Remote Desktop (Optional)

  • Ubuntu Server (No GUI): For a graphical interface, install a lightweight desktop environment plus something like xrdp:

    sudo apt install xrdp
    
  • Ubuntu Desktop (GUI included): If you’re using Ubuntu Desktop, you can enable remote desktop tools directly.

  • Third-Party Tools:

    • Microsoft Remote Desktop: Compatible with RDP.
    • TeamViewer: Good for GUI access and file transfers.

The Service

Now that your server is up and running, you’ll want to deploy applications. This involves:

  1. Transferring Code (or application files) to the server.
  2. Running them in a reliable way.

Transferring Code

Using Git with a Service Token

- Keep your code versioned and pull changes easily.
- Example:

    ```shell
    git clone https://<TOKEN>@github.com/username/repository.git
    ```

SCP (Secure Copy Protocol)

- Transfer files securely:

    ```shell
    scp -r /local/path username@server-ip:/remote/path
    ```

Docker Registries

- Build and push your Docker image:

    ```shell
    docker build -t username/app-name:tag .
    docker push username/app-name:tag
    ```

- Pull and run it on the server:

    ```shell
    docker pull username/app-name:tag
    docker run -d username/app-name:tag
    ```

Manual File Uploads

- Compress into a `.zip` or `.tar.gz` and upload:

    ```shell
    tar -xvzf project.tar.gz
    ```

Running Applications

It’s often best to use a specialized tool so your app restarts automatically if it crashes and is easy to update. Below are different approaches:

Docker + Portainer (Preferred)

  • Why Docker? Consistent environments with minimal fuss.

  • Set Up Portainer:

    docker volume create portainer_data
    docker run -d -p 9000:9000 --name=portainer --restart=always \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -v portainer_data:/data portainer/portainer-ce
    
  • Docker Compose:

    version: '3.8'
    services:
      app:
        image: username/app-name:tag
        ports:
          - "8080:80"
        environment:
          - ENV_VAR=value
    

    Start it:

    docker-compose up -d
    
  • Portainer gives a web UI to manage containers, logs, and stats.

Process Managers

  • PM2 (Node.js)

    npm install -g pm2
    pm2 start app.js
    

    Auto-restart, monitoring, and logs for Node apps.

  • Supervisor (Python)

    sudo apt install supervisor
    

    Configure in /etc/supervisor/conf.d/myapp.conf:

    [program:myapp]
    command=python3 /path/to/app.py
    autostart=true
    autorestart=true
    stderr_logfile=/var/log/myapp.err.log
    stdout_logfile=/var/log/myapp.out.log
    

    Reload:

    sudo supervisorctl reload
    

Shell Scripts and Cron Jobs

  • Good for simpler tasks. Example script start_app.sh:

    #!/bin/bash
    python3 /path/to/app.py
    
  • Use systemd or cron to start or schedule tasks.

Manual Execution (Not Recommended for Production)

  • Just run your app:

    node app.js
    python3 app.py
    ./app-binary
    

Beginner Tip: Docker Compose or PM2 are often simpler than you think. Start there!

Automating Deployments

Automating deployments ensures consistency and reliability:

  • Infrastructure as Code (IaC): Ansible scripts to configure servers, install dependencies, and manage environments.

  • CI/CD Pipelines:

    • GitLab CI/CD or Jenkins: Automate tests, builds, and deployments.

    • Example with GitLab:

      stages:
        - test
        - build
        - deploy
      
      test:
        stage: test
        script:
          - npm install
          - npm test
      
      build:
        stage: build
        script:
          - docker build -t registry.example.com/myapp:$CI_COMMIT_SHA .
          - docker push registry.example.com/myapp:$CI_COMMIT_SHA
      
      deploy:
        stage: deploy
        script:
          - ssh user@server "docker pull registry.example.com/myapp:$CI_COMMIT_SHA && docker-compose up -d"
      
  • Automated Backup Solutions: Tools like Restic or Duplicati for regular backups.

  • Application Deployment Tools: Capistrano or Fabric for non-containerized apps.

  • Monitoring and Alerting: Prometheus + Alertmanager or Slack/email integrations to stay on top of system health.

Real-Life Example: Use Ansible to spin up a new Ubuntu VM, install Docker, pull your Docker image, and start it automatically with Compose—no manual steps needed.

Resources

Here are some resources to help you learn and grow:

Project Ideas

  • DNS Management: Try running Pi-hole for ad-blocking and DNS insights.
  • Home Automation: Use Home Assistant for a centralized smart home.
  • Load Balancing: Experiment with nginx as a load balancer.
  • Monitoring: Spin up Prometheus + Grafana to visualize your server metrics.
  • Advanced Challenge: Set up a small Kubernetes cluster with k3s to orchestrate multiple containers.

Blogs

YouTube

Books


Remarks

I’m not going to lie, you have to build things. Many things. Random ones that no one uses, and useful things that make at least one person’s life better. It’s from this repeated cycle of building, failing, and trying that you get more confident in what you can and can’t do. Hopefully, if you’re doing it right, it’s only a matter of time before you realize that doing anything is only a matter of time.