# 3: Setting Up Your Foundation

Before you can install your first application, we need to set up the basic infrastructure that Infinity Tools needs to work properly. Don't worry - Infinity Tools will handle most of this automatically!

This chapter also covers **foundational apps** that most Infinity Tools require—the most essential of them is [Traefik](https://docs.speedbits.io/books/2-beginner-path/page/4-traefik-reverse-proxy-essential "4: Installing Traefik - Your Reverse Proxy (Essential)"), on which many other apps rely. You do not strictly *need* the back-tool [Borgmatic](https://docs.speedbits.io/books/2-beginner-path/page/6-borgmatic-backup-system-optional-but-you-should-have-backup "6: Installing Borgmatic - Your Backup System"), however, we **highly recommend** that you install it to automatically create **backups** of your data. And to use Borgmatic, you have to install [Apprise](https://docs.speedbits.io/books/2-beginner-path/page/5-apprise-notifications-optional-but-essential-for-backups-with-borgmatic "5 Installing Apprise - Notifications"), a notification system, which is why we also cover it in this chapter.

## What We'll Set Up

In this chapter, we'll prepare:

- ✅ **Docker** - The system that runs all your applications
- ✅ **Docker Network** - How applications talk to each other
- ✅ **System Requirements** - Making sure everything is ready
- ✅ **Basic Security** - Simple firewall setup (optional)

**Time needed:** About 10-15 minutes

## What is Docker? (Simple Explanation)

**Docker** is like a shipping container system for software. Just like how shipping containers make it easy to move goods around the world, Docker makes it easy to run applications on any computer.

**Why we need it:**

- Applications run in isolated "containers" - they can't interfere with each other
- Everything is pre-configured and ready to go
- If something goes wrong, you can easily restart or replace just that application
- It's the standard way modern applications are deployed

**Think of it like this:** Instead of installing WordPress directly on your server (which can be complicated), Docker runs WordPress in a container that has everything it needs already set up. If you install [Portainer](https://docs.speedbits.io/books/2-beginner-path/page/7-portainer-docker-management-made-easy-optional-but-convenient "7: Portainer –  Docker Management Made Easy (optional but convenient)"), you get a convenient web app to see what's going on with your Docker containers and administrate them.

## Step 1: Run the Readiness Check

Infinity Tools has a built-in system that checks if everything is ready and installs what's missing. Let's run it!

### Start Infinity Tools

First, make sure you're connected to your server via SSH, then start Infinity Tools:

```
sudo infinity-tools
```

### What You'll See in the GUI

When you start Infinity Tools, you'll see a beautiful, modern interface with:

- ✅ **Colorful headers** - Easy to identify different sections
- ✅ **Progress indicators** - Shows what's happening during installation
- ✅ **Status messages** - Tells you if things are working or if there are problems
- ✅ **Interactive prompts** - Asks you questions when needed

**Don't worry if it looks complex!** The GUI is designed to guide you through everything step by step.

### What Happens Next

Infinity Tools will automatically run a "readiness check" that:

- Checks if Docker is installed
- Installs Docker if it's missing
- Sets up the Docker network
- Installs other required tools
- Verifies everything is working

**You'll see messages like:**

```
♾️  INFINITY TOOLS READINESS CHECK

Ensuring all prerequisites are met...

This will check and install:
• Docker & Docker Compose
• Docker Network for services
• GUM for modern UI
• Dialog for compatibility
• System requirements
```

### If Docker Needs to be Installed

If Docker isn't installed yet, you'll see a message asking if you want to install it:

```
🐳 DOCKER INSTALLATION REQUIRED

Infinity Tools requires Docker to run containerized services.

Docker will be installed and configured automatically.
This includes Docker Engine and Docker Compose.

⚠️  This requires internet connection and may take a few minutes.

Install Docker now?
```

**Answer "Yes"** to continue. The installation will take a few minutes.

### Docker Network Setup

After Docker is installed, you'll be asked about setting up a network:

```
🌐 DOCKER NETWORK SETUP

Infinity Tools services need a Docker network to communicate.

This network allows containers to find each other by name
and enables features like Traefik reverse proxy.

Default network name: proxy
```

**Press Enter** to use the default network name "proxy" (recommended).

## Step 2: Verify Everything is Working

After the readiness check completes, you should see:

```
✅ READINESS CHECK COMPLETE

All prerequisites are satisfied!
Infinity Tools is ready to use.
```

### What Was Installed

If everything went well, you now have:

- ✅ **Docker Engine** - The main Docker system
- ✅ **Docker Compose** - Tool for managing multiple containers
- ✅ **Docker Network** - A network called "proxy" for your services
- ✅ **GUM** - The modern interface you're using
- ✅ **Dialog** - Backup interface (just in case)

## Step 3: Understanding What Happened

### Docker Installation

Docker was installed and configured to:

- Start automatically when your server boots
- Run containers securely
- Manage storage for your applications
- Handle networking between containers

### Docker Network

The "proxy" network was created to:

- Allow applications to find each other by name
- Enable Traefik (our reverse proxy) to route traffic
- Keep your applications isolated from the internet
- Make it easy to add new services later

## Step 4: Optional - Basic Security Setup

Now that the basics are ready, you can optionally set up basic security. This is recommended but not required to get started.

### What is a Firewall?

A **firewall** is like a security guard for your server. It controls which connections are allowed in and out.

**Why it's important:** Without a firewall, your server is like a house with all doors unlocked - anyone can try to access it.

### Setting Up the Firewall

In the Infinity Tools menu, you'll see a "Security &amp; Networking" section. You can set up the firewall later, but here's what it does:

- Allows SSH connections (so you can still connect)
- Allows HTTP and HTTPS traffic (for websites)
- Blocks other unwanted connections
- Protects against common attacks

**For now:** You can skip this and set it up later. Your server is reasonably safe as long as you keep your passwords strong.

## Step 5: Understanding Your System

### What's Running Now

Right now, your server has:

- ✅ **Infinity Tools** - The management system
- ✅ **Docker** - Ready to run applications
- ✅ **Docker Network** - Ready for services
- ❌ **No Applications Yet** - This is what we'll install next!

### What's Next

You're now ready to install your first application! The most important one to install first is **Traefik** - it handles secure connections and routing for all your other applications.

## Troubleshooting

### Docker Installation Failed

If Docker installation fails:

- Check your internet connection
- Make sure you have enough disk space (at least 1GB free)
- Try running the readiness check again
- If it keeps failing, contact support with the error message

### Network Creation Failed

If the Docker network creation fails:

- Make sure Docker is running: `sudo systemctl status docker`
- Try restarting Docker: `sudo systemctl restart docker`
- Run the readiness check again

### Can't Connect to Server

If you lose connection during setup:

- Reconnect via SSH
- Run `sudo infinity-tools` again
- The readiness check will continue where it left off

## Quick Reference

**Check if Docker is running:**

```
sudo systemctl status docker
```

**Check Docker networks:**

```
docker network ls
```

**View Docker containers:**

```
docker ps
```

**Restart Docker if needed:**

```
sudo systemctl restart docker
```

## You're Ready!

Congratulations! You now have:

- ✅ A working Docker system
- ✅ A network for your applications
- ✅ All the tools Infinity Tools needs
- ✅ A solid foundation for your applications

**Next step:** Install Traefik - the reverse proxy that will handle secure connections and routing for all your applications.

## What You Learned

- **Docker** - A system for running applications in containers
- **Docker Network** - How applications communicate with each other
- **Readiness Check** - Infinity Tools' automatic setup system
- **Infrastructure** - The foundation that makes everything else possible

You're now ready to install your first application! In the next chapter, we'll install Traefik, which is essential for running other applications securely.

---

*Next: Installing Traefik - Your Reverse Proxy (Chapter 4)*