This repository contains the configuration needed to run StackAI locally using docker compose.
- At least 64GB of RAM
- At least 16 CPU cores
- 1TB of disk space
- Ubuntu 24.04 LTS
- Python 3.10 or higher.
- You will need internet access during the setup process.
- Docker and Docker Compose (compose version v2.26 or higher). Follow instructions below to install them if needed.
Check the steps below for instructions on how to check if you meet this requirement.
- You will need access to stackai's container image registry on Azure.
- Depending on how you configure the containers, different ports should be exposed, if you follow the default settings, the following ports need to be exposed:
- Port 3000: TCP port used for the StackAI frontend HTTP
- Port 8000: TCP port used for the StackAI backend HTTP
- Port 8800: TCP port used for the Kong API Gateway HTTP
- Port 8443: TCP port used for the Kong API Gateway HTTPS
- Port 9000: TCP port used for the MinIO service.
If you set up the Caddy reverse proxy (See steps below), you may change the ports above for the ports 80 or/and 443.
.
├── caddy
├── mongodb
├── scripts
├── supabase
├── stackend
├── stackrepl
├── stackweb
...Each of the folders in the project contains the configuration for one of the services needed to run StackAI.
After running the environment variables initialization script (see below), each folder will contain a .env file with the environment variables needed to run the service. This, along the docker-compose.yml files, are the most important configuration files that may need to be edited.
Follow the instructions in the order they are presented.
Note: Throughout this setup guide, when you see cd /path/to/stackai-onprem, replace /path/to/stackai-onprem with the actual path to where you have cloned or downloaded this repository on your system.
sudo apt install makeMake sure that make is installed correctly by running:
make --versionYou will need docker and docker compose installed in your machine.
To install them, open a terminal and navigate to the root folder of the project by running:
cd /path/to/stackai-onpremThen execute the following command, log in again after it finishes:
:WARNING: The script will log you out from your current session. Log in again and verify successful setup running the following command:
make setup-docker-in-ubuntuThe commands needed to install python, pip and virtualenv may change depending on your specific distribution.
The following commands should work for most Ubuntu based distributions:
Update the package index:
sudo apt updateInstall python3, pip and virtualenv:
sudo apt install python3-pip python3-venvEnsure that python is installed and working correctly. Start by making sure that the python version is >= 3.10:
python3 --versionThen, make sure that virtualenv is installed and working by running:
python3 -m venv .venvAs a result, you should see a new folder named .venv in your current directory.
Then, make sure that you can source the virtual environment by running:
source .venv/bin/activateLast, make sure that pip is working correctly in the virtual environment by running:
python3 -m pip install pymongoAnd then:
python3 -c "import pymongo; print('pymongo imported successfully')"You can remove the virtual environment by running:
deactivate
rm -rf .venvYou will need to log in to StackAI's container registry on Azure to pull the images we provided you with.
docker login -u <the_username_we_provided_you_with> -p <the_password_we_provided_you_with> stackai.azurecr.ioEach of the services has a series of environment variables that need to be configured in order to run it. In this step of the set up process, we will create the .env files for all the services. After the script finishes, you should be able to go to find the following files in each service's folder:
supabase/.env
weaviate/.env
unstructured/.env
stackend/.env
stackrepl/.env
stackweb/.env
...The script will initialize the environment variables with random secrets and a valid default configuration. It is encouraged that you manually review the generated values after the script finishes and make any adjustments needed, specially to the networking related configuration.
a) Read the section above.
b) Open a new terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremc) Run the script that will initialize the environment variables:
The script will prompt you to input the public ip/ url where the services will be exposed.
make install-environment-variables-
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen run:
make start-supabase
This will start the supabase containers and show you the running logs. Once the supabase containers start running, they will start the internal process of setting up the database. This will take about 2-3 minutes.
-
Verify the installation by navigating to the url configured in the file
supabase/.envnamed asSUPABASE_PUBLIC_URLvariable. This will take you to the supabase dashboard, which is enabled by default (you may disable it manually in thesupabase/docker-compose.ymlfile if you want). To log in, you will need to use theDASHBOARD_USERNAMEandDASHBOARD_PASSWORDvariables values that can be found in thesupabase/.envfile.You can check the
SERVICE_ROLE_KEYcreated by running the following script:scripts/environment_variables/retrieve_anon_supabase.sh
-
You may stop the containers by doing a
Ctrl+Cin the terminal where you ran themake start-supabasecommand, or by opening a new terminal, navigating to the project root, and running:cd /path/to/stackai-onprem docker compose down
-
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen initialize the mongodb container:
docker compose up mongodb
Have a look at the logs and make sure everything is running smoothly.
This will start the mongodb container. Wait a minute to make sure it has been properly initialized. After that, continue with the next step without stopping the container.
-
Initialize the database
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen run:
make initialize_mongodb
-
After the initialization, you can run
docker compose downto stop mongodb.
-
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen initialize the unstructured container:
docker compose up unstructured
Have a look at the logs and make sure everything is running smoothly.
-
After the initialization, you can run
docker compose downto stop unstructured.
-
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen initialize the weaviate container:
docker compose up weaviate
Have a look at the logs and make sure everything is running smoothly.
-
Wait for about two minutes. After the initialization, you can run
docker compose downto stop weaviate.
The stackweb docker container requires some of the environment variables here defined to be built. This is why we need to source the .env file before building the image.
-
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen initialize the stackweb container:
a) Source the stackweb environment variables:
source stackweb/.envb) Build the docker image for stackweb:
docker compose build stackweb
The build process may take about 5 minutes depending on your internet connection and hardware.
-
Navigate to the
stackendfolder. -
Configure the embedding models you want to use in the
stackend/embeddings_config.tomlfile. -
Configure the local LLM models you want to use in the
stackend/llm_local_config.tomlfile and thestackend/llm_config.tomlfiles. -
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen pull the backend containers:
docker compose pull stackend celery_worker redis
-
Start the stackend service and run migrations:
The database services need to be started first se we can run the migrations against them
make start-supabase
Then, open another terminal and start the stackend service:
docker compose up stackend
Wait for the stackend container to start. Then, on a new terminal, execute the following command to run the migrations:
docker compose exec stackend bash -c "cd infra/migrations/postgres && alembic upgrade head"
-
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen build the stackrepl container:
docker compose build stackrepl
-
Open a terminal and navigate to the root folder of the project:
cd /path/to/stackai-onpremThen launch all services:
docker compose up
-
Wait for about 2 minutes for everything to start. Then navigate to the url configured in the file
stackweb/.envnamed asNEXT_PUBLIC_URLvariable. You should see the StackAI landing page.
- If you need to use SSL, configure the Caddyfile to use your certificates and keys.
You can configure custom domains for the three main services: the frontend application, the API, and the Supabase backend. We recommend using a primary domain and two subdomains.
For example:
- APP URL:
https://stackai.onprem.com - API URL:
https://api.stackai.onprem.com - SUPABASE URL:
https://db.stackai.onprem.com
There are two steps to configure your domains:
Run the following command and enter your domains when prompted. This command will update all the necessary .env files across the services.
make configure-domainsYou also need to update the Caddyfile to reflect your new domains. Replace the placeholder domains in the file with the ones you have configured.
In order to update the services, you will need to follow the instructions below:
- Stop all the services with
docker compose stop - Update the
imagefield of the docker-compose.yml file of the service you want to update.
Example, to update the stackend service from d3f54d3 to f4c8aa0
Usually you don't need to do this cause you use the latest version.
This line
stackend:
image: stackai.azurecr.io/stackai/stackend-backend:d3f54d3Should be updated to:
stackend:
image: stackai.azurecr.io/stackai/stackend-backend:f4c8aa0- Pull the new images with
docker compose pullIn the case of the frontend (stackweb), you will need to rebuild the image with
docker compose build stackweb- Run database migrations if needed (instructions should be provided in the update README of the update)
docker compose up stackend
make run-postgres-migrations- Start all containers again with
docker compose up