2025-05-06 00:39:02 +03:00
2025-05-06 00:39:02 +03:00

How to Set Up and Self-Host Perplexica Using Docker

1. Preparing Your Development Environment

Updating Dependencies

Before you start, it's essential to ensure your system has the necessary dependencies installed:

sudo apt update && sudo apt upgrade -y

This command updates your package lists and installs any new required packages.

Installing Docker

Docker is crucial for containerizing and running Perplexica. Install Docker CE (for development) or Docker Hub (for production):

apt install docker.io docker-compose git -y

This will install Docker CE on your system, allowing you to create and run Docker containers.

2. Cloning the Perplexica Repository

To get access to the Perplexica codebase:

git clone https://github.com/ItzCrazyKns/Perplexica
cd Perplexica

3. Configuring the Docker Compose File

Understanding the Docker Compose File

The following YAML file configures a multi-service application:

version: '3.8'

services:
  searxng:
    image: searxng/searxng:latest
    container_name: searxng
    ports:
      - "8080:8080"
    volumes:
      - ./searxng:/etc/searxng:rw
    environment:
      - BASE_URL=http://localhost:8080/
      - SEARXNG_ENABLE_METRICS=true
      - SEARXNG_UI_DEFAULT_THEME=simple
      - SEARXNG_AUTOCOMPLETE=google
      - SEARXNG_ENABLE_HTTPS=false
      - SEARXNG_DEFAULT_LANG=en
      - SEARXNG_SEARCH_FORMAT=html,json
    restart: unless-stopped
    networks:
      - perplexica-network

  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    ports:
      - "11434:11434"
    volumes:
      - ./ollama_data:/root/.ollama
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    environment:
      - OLLAMA_HOST=0.0.0.0:11434
    restart: unless-stopped
    networks:
      - perplexica-network

  openweb-ui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: openweb-ui
    ports:
      - "3000:8080"
    environment:
      - OLLAMA_API_BASE_URL=http://ollama:11434
      - ENABLE_RAG_WEB_SEARCH=True
      - RAG_WEB_SEARCH_ENGINE=searxng
      - RAG_WEB_SEARCH_RESULT_COUNT=5  # Adjust the number of search results returned
      - RAG_WEB_SEARCH_CONCURRENT_REQUESTS=10  # Adjust concurrent requests for performance tuning
      - SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>
    volumes:
      - ./open-web-ui-data:/app/backend/data
    depends_on:
      - ollama
      - searxng
    restart: unless-stopped
    networks:
      - perplexica-network

  perplexica:
    image: itzcrazykns1337/perplexica:main
    container_name: perplexica
    build:
      context: .
      dockerfile: app.dockerfile
    environment:
      - SEARXNG_API_URL=http://searxng:8080
      - OLLAMA_API_URL=http://ollama:11434  # Added Ollama API URL
    ports:
      - "3001:3000"
    networks:
      - perplexica-network
    volumes:
      - backend-dbstore:/home/perplexica/data
      - uploads:/home/perplexica/uploads
      - ./config.toml:/home/perplexica/config.toml  # Bind mount for config.toml
    depends_on:
      - ollama  # Ensure ollama is started first
      - searxng  # Ensure searxng is started first
    restart: unless-stopped

networks:
  perplexica-network:

volumes:
  backend-dbstore:
  uploads:

Explanation of Each Service

  1. searxng:

    • Uses the official docker.io/searxng/searxng:latest image.
    • Listens on port 4000 and maps to Perplexica's 8080 endpoint.
  2. ollama:

    • Uses the Ollama image with CUDA support for GPU acceleration.
    • Exposes port 11434, which is used by Perplexica for API communication.
  3. app (Perplexica Service):

    • Runs in a custom Docker image (itzcrazykns1337/perplexica:main).
    • Exposes the application on port 3000.
    • Maps local development files to host volumes for data persistence.

Volume Configuration

Volumes ensure that data remains accessible after deployment:

  • backend-dbstore: Stores the database used by Perplexica.
  • uploads: Stores uploaded content (e.g., PDFs).
  • config.toml: Stores configuration settings.

4. Building and Running the Application

After setting up the Docker Compose file, run these commands to deploy:

docker-compose down && docker-compose up --build -d

This command:

  1. Removes existing containers (docker-compose down).
  2. Builds and starts a new deployment (docker-compose up --build -d).

5. What If It Fails?

If the setup fails, clean all containers and volumes:

docker rm -v -f $(docker ps -qa)
docker rmi -f $(docker images -aq)
docker volume prune
docker system prune
sudo systemctl restart docker

Then, repeat the deployment steps.

6. Conclusion

By following these steps, you'll have a fully functional Perplexica application running on your local machine. The Docker setup ensures consistency across development environments and simplifies deployment to production.false

Description
Introduction on how to install perplexica on proxmox lxc -> docker
Readme 38 KiB