How to start a home lab

Starting a home lab can feel overwhelming. Initial knowledge barriers, hardware requirements and time stand between you and a working home lab. This is one way of starting one on your terms with little to no investments.

How to start a home lab
Photo by Taylor Vick / Unsplash

What would it look like if it were easy?


Having a home lab has been on my radar for a long time for many reasons. Many people swear by the practice, as building one can teach you valuable skills that transfer well into IT or software development. But beyond that, motivations like improved privacy, cost reduction, data ownership, and the sheer joy of building can also be compelling reasons.

For me, the main appeal has always been the opportunity to learn and the joy of exploring while building things. These days, there’s so much you can do if you have the technical knowledge and the willingness to experiment. However, the countless decisions involved can be a major obstacle. The effort and maintenance required for a home lab should be carefully considered, and the solution should be tailored to meet your needs as a hobbyist.

In this article, I will share how I am starting a home lab without needing to spend excessive time and money. My approach is to build an MVP with a narrow scope.

The source code for this project can be found here. Check out the branch dummy-app.


Getting Started

First, take a look at the README.md file.

You will find a project structure that looks like this:

Homelab/
├── .gitignore
├── README.md
├── dummy-app/
│   ├── Dockerfile
│   ├── go.mod
│   └── main.go

Markdown file tree of the home lab repo

The commands we run later depend on these files being created, so that is the first thing we will do.

Either clone the repository or create them manually:

mkdir dummy-app && touch dummy-app/main.go dummy-app/Dockerfile

Initialise the project


The Service

Add this code to main.go:

package main

import (
	"fmt"
	"net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello, World!")
}

func main() {
	http.HandleFunc("/", handler)
	fmt.Println("Starting server on :8080")
	http.ListenAndServe(":8080", nil)
}

Simple Go program

Initialise Go

Inside the dummy-app folder, run:

go mod init main.go

This will create the go.mod file.


A Note on Go

I chose Go for this example because I want to learn more about it. However, any language would work for this setup. Just make sure to update the Dockerfile accordingly to match your build requirements.


Building the Application

The final step is to add the following content to the Dockerfile. I am using golang:1.23, so update this if necessary to match the Go version in your project.

# First stage: build the Go application
FROM golang:1.23 AS builder
WORKDIR /app

# Copy go.mod and download dependencies
COPY go.mod ./
RUN go mod download

# Copy the source code and build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -v -o main .

# Second stage: create a lightweight runtime environment
FROM alpine:latest
RUN apk --no-cache add ca-certificates
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
RUN chown appuser:appgroup /app
USER appuser

# Copy the built binary
COPY --from=builder /app/main .

# Expose the application port
EXPOSE 8080
CMD ["./main"]

Build and run the application in a container


Running the Application

We now have everything we need to run this "home lab." Run the following commands from the README.md. This assumes you have Docker installed. If not, you can follow this guide.

Run these commands from the homelab folder:

Run the Docker container:

docker run -p 8080:8080 dummy-app

Build the Docker image:

docker build -t dummy-app -f ./dummy-app/Dockerfile ./dummy-app

Now, open localhost:8080 in your browser!


Conclusion

This concludes the first iteration of my home lab implementation. To be clear, this is not a full-fledged home lab—it's just a container running a simple application.

However, I value simplicity and plan to keep it that way so I can focus on learning. So, bear with me and join me as I explore the world of home labs. I hope this helps others take the first step in building their own home lab as well!