ItzCrazyKns / Perplexica

Perplexica is an AI-powered search engine. It is an Open source alternative to Perplexity AI
MIT License
13.4k stars 1.26k forks source link

custom install each container separately #363

Open warlordattack opened 3 days ago

warlordattack commented 3 days ago

Hello,

It would be nice to have option to install in docker without SearXNG, because some already have it installed.

So i try to do some custon docker compose from the original files. I am pretty close but i have infinite loading screen when i launch UI. Please help to make it run :)

I run this in rocky linux VM and podman.

What i did :

1/ cloned the repo

2/ edited config.toml created API keys and pasted them in the file

[GENERAL]
PORT = 3001 # Port to run the server on
SIMILARITY_MEASURE = "cosine" # "cosine" or "dot"

[API_KEYS]
OPENAI = "sk-proj-somekey" # OpenAI API key - sk-1234567890abcdef1234567890abcdef
GROQ = "gsk_somekey" # Groq API key - gsk_1234567890abcdef1234567890abcdef
ANTHROPIC = "sk-somekey" # Anthropic API key - sk-ant-1234567890abcdef1234567890abcdef

[API_ENDPOINTS]
SEARXNG = "http://sxng:8080" # SearxNG API URL
OLLAMA = "http:192.168.50.54:11434" # Ollama API URL - http://host.docker.internal:11434

3/ created custom docker-compose.yml

docker-compose.yml :

version: "3.2"
services:

  back:
    build:
      context: .
      dockerfile: backend.dockerfile
      args:
        - SEARXNG_API_URL=http://${C_SXN_HOST}:${C_SXN_8080_L}
    container_name: ${C_PPKB}
    user: ${PUID}:${PGID}
    restart: ${C_ALL_RESTART}
    hostname: ${C_PPKB_HOST}
    ports:
      - ${C_PPKB_3001}:3001
    volumes:
      - ${REP_APPDATA}/${C_SXN}:/etc/searxng
      - ${REP_APPDATA}/${C_PPK}/data:/home/perplexica/data
      - ${REP_APPDATA}/${C_PPK}/config.toml:/home/perplexica/config.toml
    networks:
      web:
        ipv4_address: ${C_PPKB_IP_WEB}

  front:
    depends_on:
      - back
    build:
      context: .
      dockerfile: app.dockerfile
      args:
        - NEXT_PUBLIC_API_URL=http://${C_PPKB_HOST}:3001/api
        - NEXT_PUBLIC_WS_URL=ws://${C_PPKB_HOST}:3001
    container_name: ${C_PPKF}
    user: ${PUID}:${PGID}
    restart: ${C_ALL_RESTART}
    hostname: ${C_PPKF_HOST}
    ports:
      - ${C_PPKF_3000}:3000
    networks:
      web:
        ipv4_address: ${C_PPKF_IP_WEB}

networks: 
  web: 
    external: true

d.env :

# MISC
C_ALL_RESTART=no
PUID=1000
PGID=1000
REP_APPDATA=/mnt/mydocker/appdata 

# searxng - search engine
C_SXN=net-searxng
C_SXN_HOST=sxng
C_SXN_IP_WEB=192.168.10.63
C_SXN_8080=2080
C_SXN_8080_L=8080

# perplexica
C_PPK=net-perplexica
C_PPKF=net-perplexica-f
C_PPKB=net-perplexica-b
C_PPKB_HOST=ppkb
C_PPKB_3001=53001
C_PPKB_IP_WEB=192.168.10.73
C_PPKF_HOST=ppkf
C_PPKF_3000=53002
C_PPKF_IP_WEB=192.168.10.74

RUN TEST : sudo bash /mnt/mydocker/code/go-one.sh

#!/bin/bash
export TERM=xterm
source $(dirname "$0")/v.env
source $(dirname "$0")/d.env
source $(dirname "$0")/fx.sh

# --- VARS ------------------------------------
rCode="/mnt/mydocker/code"
rAppData="/mnt/mydocker/appdata"
fEnv="/mnt/mydocker/code/d.env"
start=$1

clear

# --- LIGNE DE COMMANDE ----------------------
run='SRPU' # FR SRPU SRP DPU DU
if [ "$start" == "START" ] 
then
    echo "---- CMDLINE=$start ---------------"
    run="FR" # start
fi

# --- VERSION ----------------------------------
#podVersion
#podPruneImages
#exit

# --- GO ---------------------------------------
podNetInit

# --- TEST -------------------------------------
#podCompose $run 'net-searxng'          # 63 : db-valkey, traefik
#cd /mnt/mydocker/code/net-perplexica
#ls -la
podCompose 'DOWN' 'net-perplexica'
podCompose 'SR' 'net-perplexica-f'
podCompose 'SR' 'net-perplexica-b'
podCompose 'UP' 'net-perplexica'
dkPruneImages
exit

helper script : /mnt/mydocker/code/fx.sh

#!/bin/bash

hello() {

    local p1=$1
    local p2=$2
    local p3=$3
echo "--- $p1 - $p2 - $p3 --- "

}

fYml() {

    local c=$1     # 'sys-dozzle' # C_DOZ

    # cd vers dossier du container
    local dirYml=$rCode/$c
    cd "$dirYml"

    # fichier yaml
    local ficYml=$dirYml/docker-compose.yml

    # renvoyer res
    echo $ficYml

}

dkNetInit() {

# https://docs.docker.com/engine/reference/commandline/network_create/

    echo "---- NET : web, noweb --------------"
    sudo docker network rm web noweb # mvlan #nextcloud-aio

    echo "---- +WEB ----"
    sudo docker network create \
    --gateway 192.168.10.1 \
    --subnet 192.168.10.0/24 \
    --opt com.docker.network.driver.mtu=9216 \
    web

    echo "---- +NOWEB ----"
    sudo docker network create \
    --gateway 192.168.20.1 \
    --subnet 192.168.20.0/24 \
    --opt com.docker.network.driver.mtu=9216 \
    --internal \
    noweb

#    sudo docker network create \
#    --gateway 192.168.30.1 \
#    --subnet 192.168.30.0/24 \
#    --opt com.docker.network.driver.mtu=9216 \
#    nextcloud-aio

#    echo "---- +MVLAN ----"
#    # ip-range(29) : 7 adresses 192.168.50.200-207
#    # parent : enp6s18 (ubuntu) / eth0 (autres)
#    sudo docker network create -d macvlan \
#    --gateway=192.168.50.1 \
#    --subnet=192.168.50.0/24 \
#    --ip-range=192.168.50.200/29 \
#    --opt parent=enp6s18 \
#    --opt com.docker.network.driver.mtu=9216 \
#    mvlan

    echo ""
}

podNetInit() {

# https://docs.docker.com/engine/reference/commandline/network_create/

    echo "---- NET : web, noweb, nextcloud-aio --------------"

    #echo "---- liste -------------------------"
    #podman network ls

    echo "---- rm ----------------------------"
    podman network rm web noweb proxy mvlan #nextcloud-aio 

    echo "---- +WEB ----"
    podman network create \
    --gateway 192.168.10.1 \
    --subnet 192.168.10.0/24 \
    --opt com.docker.network.driver.mtu=9216 \
    web

    echo "---- +NOWEB ----"
    podman network create \
    --gateway 192.168.20.1 \
    --subnet 192.168.20.0/24 \
    --opt com.docker.network.driver.mtu=9216 \
    --internal \
    noweb

    #podman network create \
    #--gateway 192.168.30.1 \
    #--subnet 192.168.30.0/24 \
    #--opt com.docker.network.driver.mtu=9216 \
    #nextcloud-aio

    echo "---- +MVLAN ----"
    # ip-range(29) : 7 adresses 192.168.50.200-207
    # parent : enp6s18 (ubuntu) / ens18 (rocky) / eth0 (autres)
    podman network create -d macvlan \
    --gateway=192.168.50.1 \
    --subnet=192.168.50.0/24 \
    --ip-range=192.168.50.200/29 \
    --opt parent=ens18 \
    mvlan
    #--opt com.docker.network.driver.mtu=9216 \

    echo "---- +PROXY ----"
    podman network create \
    --gateway 192.168.60.1 \
    --subnet 192.168.60.0/24 \
    --opt com.docker.network.driver.mtu=9216 \
    proxy

    #echo "---- liste -------------------------"
    #podman network ls

    echo ""
}

podVersion() {

    echo "---- Pv -------------------"
    podman --version
    echo "---- PCv ------------------"
    podman-compose --version
    echo "---- EXIT -----------------"

}

dkVersion() {

    echo "---- Pv -------------------"
    docker --version
    echo "---- PCv ------------------"
    docker-compose --version
    echo "---- EXIT -----------------"

}

dkUidGid() {
    echo "---- MY IDS  --------------"
    id -u
    id -g
}

dkPruneImages() {

    echo "---- PRUNE -------------------------"
    sudo docker image prune -a --force #-f

}

podPruneImages() {

    echo "---- PRUNE -------------------------"
    podman image prune -a --force #-f

}

dkCompose() {

    local r=$1      # RUN options : DU, SRPU
    local c=$2      # 'sys-dozzle' # C_DOZ

    echo "-------------------- VM : $c $r --------------------"

    local f=$(fYml $c)
    local e=$fEnv

    #echo "C : $c"
    #echo "F : $f"
    #echo "E : $e"
    #exit

    if [ "$r" == "SRPU" ] 
    then
        #echo "---- STOP RM PULL UP ---------------"
        sudo docker stop $c                                  # stop
        sudo docker rm -f $c                                 # rm 
        sudo docker-compose --file $f --env-file $e pull     # pull
        sudo docker-compose --file $f --env-file $e up -d    # up -d
    fi

    if [ "$r" == "SRP" ] 
    then
        #echo "---- STOP RM PULL ---------------"
        sudo docker stop $c                                  # stop 
        sudo docker rm -f $c                                 # rm 
        sudo docker-compose --file $f --env-file $e pull     # pull
    fi

    if [ "$r" == "DPU" ] 
    then
        #echo "---- DOWN PULL UP ---------------"
        sudo docker-compose --file $f --env-file $e down         # down
        sudo docker-compose --file $f --env-file $e build --pull # pull
        sudo docker-compose --file $f --env-file $e up -d        # up -d
    fi

    if [ "$r" == "DU" ] 
    then
        #echo "---- DOWN UP ---------------"
        sudo docker-compose --file $f --env-file $e down         # down
        sudo docker-compose --file $f --env-file $e up -d        # up -d
    fi

    if [ "$r" == "FR" ] 
    then
        #echo "---- UP D FORCE RC ---------------"
        sudo docker-compose --file $f --env-file $e up -d --force-recreate  # up -d
    fi

}

podCompose() {

    local r=$1      # RUN options : DU, SRPU
    local c=$2      # 'sys-dozzle' # C_DOZ

    echo "-----------------------------------------------------------"
    echo "---- VM : $c $r --------------------"
    echo "-----------------------------------------------------------"

    local f=$(fYml $c)
    local e=$fEnv

    #echo "C : $c"
    #echo "F : $f"
    #echo "E : $e"
    #exit

    if [ "$r" == "SRPU" ] 
    then
        #echo "---- STOP RM PULL UP ---------------"

        echo "---- STOP ---------------"
        podman stop $c                                  # stop

        echo "---- RM -----------------"
        podman rm -f $c                                 # rm 

        echo "---- PULL ---------------"
        podman-compose --file $f --env-file $e pull     # pull

        echo "---- UP -----------------"
        podman-compose --file $f --env-file $e up -d    # up -d
    fi

    if [ "$r" == "SR" ] 
    then
        echo "---- STOP RM ---------------"
        podman-compose --file $f --env-file $e down     # down
        podman stop $c                                  # stop 
        podman rm -f $c                                 # rm 
    fi

    if [ "$r" == "DOWN" ] 
    then
        echo "---- STOP RM ---------------"
        podman-compose --file $f --env-file $e down     # down
    fi

    if [ "$r" == "SRP" ] 
    then
        #echo "---- STOP RM PULL ---------------"
        podman stop $c                                  # stop 
        podman rm -f $c                                 # rm 
        podman-compose --file $f --env-file $e pull     # pull
    fi

    if [ "$r" == "DPU" ] 
    then
        #echo "---- DOWN PULL UP ---------------"
        podman-compose --file $f --env-file $e down         # down
        podman-compose --file $f --env-file $e build --pull # pull
        podman-compose --file $f --env-file $e up -d        # up -d
    fi

    if [ "$r" == "DU" ] 
    then
        #echo "---- DOWN UP ---------------"
        podman-compose --file $f --env-file $e down         # down
        podman-compose --file $f --env-file $e up -d        # up -d
    fi

    if [ "$r" == "FR" ] 
    then
        #echo "---- UP D FORCE RC ---------------"
        podman-compose --file $f --env-file $e up -d --force-recreate  # up -d
    fi

    if [ "$r" == "UP" ] 
    then
        #echo "---- UP D ---------------"
        cd $dirYml
        podman-compose --file $f --env-file $e up -d # up -d
    fi

}

Code for each container is located in : /mnt/mydocker/code/container-name/docker-compose.yml /mnt/mydocker/code/container-name/... other files

Run files : /mnt/mydocker/code/d.env /mnt/mydocker/code/fx.sh /mnt/mydocker/code/go-one.sh

Perpexica cloned to : /mnt/mydocker/code/net-perplexica /mnt/mydocker/code/net-perplexica/docker-compose.yml # my custom file

When running, data is located in : /mnt/mydocker/appdata/net-perplexica /mnt/mydocker/appdata/net-perplexica/data /mnt/mydocker/appdata/net-perplexica/config.toml

Command to start test on rocky sudo bash /mnt/mydocker/code/go-one.sh

When it starts : I can see web page sayint "Cannot GET /" on this URL : http://192.168.50.118:53001/ So i presume backend API is reachable : LAN : http://192.168.50.118:53001 DOCKER : http://ppkb:3001 or http://192.168.10.73:3001 and frontend : LAN : http://192.168.50.118:53002/ DOCKER : http://ppkf:3000 or http://192.168.10.74:3000

My SearXNG is running and is already used with openwebui on this docker URL http://sxng:8080/search?q= My Ollama is runnin on a gaming PC in wsl ubuntu and works well with openwebui too on this URL : http://192.168.50.54:11434

The problem i have is i see my perplexica UI but i have loading page forever : image

image

image

image

image

I probably missed something somewhere, please help.

Best regards :)

warlordattack commented 3 days ago

Ok looks like my AdGuard blocked telemetry.nextjs.org witch is needed to load the start page, once unblocked in AdGuard, it works.

Is telemetry needed ? Please add option to disable this if not needed :)

image

Then you have to change settings to make it work with local ollama : image

image

warlordattack commented 3 days ago

Now trying to get it work over traefik with local ssl :

image

version: "3.2"
services:

  back:
    build:
      context: .
      dockerfile: backend.dockerfile
      args:
        - SEARXNG_API_URL=http://${C_SXN_HOST}:${C_SXN_8080_L}
    container_name: ${C_PPKB}
    user: ${PUID}:${PGID}
    restart: ${C_ALL_RESTART}
    hostname: ${C_PPKB_HOST}
    ports:
      - ${C_PPKB_3001}:3001
    volumes:
      - ${REP_APPDATA}/${C_SXN}:/etc/searxng
      - ${REP_APPDATA}/${C_PPK}/data:/home/perplexica/data
      - ${REP_APPDATA}/${C_PPK}/config.toml:/home/perplexica/config.toml
    networks:
      web:
        ipv4_address: ${C_PPKB_IP_WEB}

  front:
    build:
      context: .
      dockerfile: app.dockerfile
      args:
        #- NEXT_PUBLIC_API_URL=http://${C_PPKB_HOST}:3001/api
        #- NEXT_PUBLIC_WS_URL=ws://${C_PPKB_HOST}:3001
        - NEXT_PUBLIC_API_URL=https://${C_PPKB_HOST}.${DOML}/api
        - NEXT_PUBLIC_WS_URL=wss://${C_PPKB_HOST}.${DOML}
    container_name: ${C_PPKF}
    user: ${PUID}:${PGID}
    restart: ${C_ALL_RESTART}
    hostname: ${C_PPKF_HOST}
    ports:
      - ${C_PPKF_3000}:3000
    networks:
      web:
        ipv4_address: ${C_PPKF_IP_WEB}

networks: 
  web: 
    external: true

traefik :

http:
 #region routers 
  routers:

    ppkb: # perplexica back
      entryPoints:
        - "https"
      rule: "Host(`ppkb.l.d0ge.ovh`)"
      middlewares:
        - default-headers
        - https-redirectscheme
      tls: {}
      service: ppkb
    ppkf: # perplexica front
      entryPoints:
        - "https"
      rule: "Host(`ppk.l.d0ge.ovh`)"
      middlewares:
        - default-headers
        - https-redirectscheme
      tls: {}
      service: ppkf

#region services
  services:
    ppkb: # perplexica back
      loadBalancer:
        servers:
          - url: "http://192.168.50.118:53001/"
        passHostHeader: true
    ppkf: # perplexica front
      loadBalancer:
        servers:
          - url: "http://192.168.50.118:53002/"
        passHostHeader: true

#endregion - services

  middlewares:
    https-redirectscheme:
      redirectScheme:
        scheme: https
        permanent: true

    default-headers:
      headers:
        frameDeny: true
        browserXssFilter: true
        contentTypeNosniff: true
        referrerPolicy: "no-referrer"
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsPreload: true
        stsSeconds: 15552000
        customFrameOptionsValue: SAMEORIGIN
        customRequestHeaders:
          X-Forwarded-Proto: https

    default-whitelist:
      ipWhiteList:
        sourceRange:
        - "10.0.0.0/8"
        - "192.168.50.0/16" # lan
        - "192.168.10.0/16" # web - docker
        - "192.168.60.0/16" # proxy - docker
        - "172.16.0.0/12"

    secured:
      chain:
        middlewares:
        - default-whitelist
        - default-headers

    searxng-headers:
      headers:
        customResponseHeaders:
          X-Robots-Tag: "noindex, noarchive, nofollow"
          Permissions-Policy: "accelerometer=(),ambient-light-sensor=(),autoplay=(),camera=(),encrypted-media=(),focus-without-user-activation=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(),speaker=(),sync-xhr=(),usb=(),vr=()"

With this settings works in http : image

But looks stuck in https : image

Work in progress ...

Looks like it has error 404 on this : https://ppk.l.d0ge.ovh/discover?_rsc=acgkz image

image

What is this request ? ... discover?_rsc=acgkz

:)

warlordattack commented 3 days ago

ok found in other threads that HTTPS is not supported now, so please add it later :) ... found on the discord API is coming, so perhaps HTTPS will follow :)