# Installing Docker for PUQcloud modules

# **Installing Docker on Debian 12**

The **WHMCS Docker n8n module** requires a **Debian 12 server** with **Docker installed** to function properly. This guide provides **step-by-step instructions** for setting up **Docker** and configuring the necessary environment.

- - - - - -

## **📌 Prerequisites**

✔️ A **physical** or **virtual machine** running **Debian 12**  
✔️ A **public IP address** for the server  
✔️ A **domain** for web applications managed by the module  
✔️ **DNS Configuration:** Create an **A record** pointing all subdomains to the server's IP:

```bash
*.your_domain A server_ip
```

- - - - - -

## **🚀 Installation Steps**

### **1️⃣ Install Required Utilities**

Before installing Docker, update the system and install essential tools:

```bash
sudo apt-get update  
sudo apt-get install sudo sqlite3 apache2-utils jq -y  
```

### **2️⃣ Configure Sudo Access**

Allow passwordless **sudo access** for the user connecting to the Docker server:

Edit the **sudoers** file:

```bash
sudo nano /etc/sudoers
```

Add the following line (replace `your_username` with your actual username):

```
your_username ALL=(ALL:ALL) NOPASSWD: ALL
```

### **3️⃣ Install Docker**

```bash
# Update package index
sudo apt update  

# Install dependencies
sudo apt install apt-transport-https ca-certificates curl software-properties-common  

# Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg  

# Add Docker repository
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null  

# Update package list
sudo apt update  

# Install Docker
sudo apt install docker-ce  

# Verify Docker status
sudo systemctl status docker

# Install Docker compose
sudo apt install docker-compose-plugin

```

### **4️⃣ Deploy Required Containers**

Create a **Docker Compose file** for **nginx-proxy** and **Let's Encrypt companion**:

```bash
sudo mkdir -p /opt/docker/nginx-proxy
sudo mkdir -p /opt/docker/nginx-proxy/certs
sudo mkdir -p /opt/docker/nginx-proxy/nginx
sudo mkdir -p /opt/docker/nginx-proxy/html
sudo mkdir -p /opt/docker/nginx-proxy/vhost.d
cd /opt/docker/nginx-proxy
nano docker-compose.yml
```

Paste the following content:

```yaml
version: "3"

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /opt/docker/nginx-proxy/certs:/etc/nginx/certs:ro
      - /opt/docker/nginx-proxy/nginx/vhost.d:/etc/nginx/vhost.d
      - /opt/docker/nginx-proxy/nginx/html:/usr/share/nginx/html
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - web

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    restart: always
    container_name: letsencrypt-nginx-proxy-companion
    volumes:
      - /opt/docker/nginx-proxy/certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    volumes_from:
      - nginx-proxy
    networks:
      - web

networks:
  web:
    driver: bridge

```

Save and exit (`CTRL + X`, then `Y`, then `ENTER`).

Run the containers:

```bash
docker-compose up -d
```

This setup provides:  
✔️ **nginx-proxy** – Automatic HTTP/HTTPS proxy for container web interfaces  
✔️ **Let's Encrypt Companion** – Automatic SSL certificate generation for subdomains

- - - - - -

## **✅ Final Checks**

1. **Confirm Docker is running:**```bash
    docker ps
    
    ```
2. **Verify nginx-proxy logs:**```bash
    docker logs nginx-proxy
    
    ```
3. **Ensure Let's Encrypt certificates are being generated correctly:**```bash
    docker logs letsencrypt-nginx-proxy-companion
    
    ```