Docker Deployment

Deploying Defog with Docker

To deploy Defog with Docker, follow the steps below:

Cloning the repo

Clone the defog-docker (opens in a new tab) repository:

git clone https://github.com/defog-ai/defog-docker
cd defog-docker

Installing docker and docker-compose

Install docker and docker compose, if you have not already. You can find the installation instructions here (opens in a new tab).

Getting your Defog API Key

If you do not yet have a Defog API Key, sign up at https://defog.ai/signup (opens in a new tab) to get a free one. The free key lets you query up to 5 tables with 25 total columns, and up to 1000 queries per month. If you want to query more complex databases, you can upgrade to a paid plan.

Updating the .env file

Update the .env file with your DEFOG_API_KEY and DEFOG_API_KEY_NAMES variables. You can use multiple API keys by providing a comma-separated list of API keys. If you do so, then users will be able to select from multiple databases from a UI dropdown, like below

Multiple API Keys

DEFOG_API_KEY_NAMES is a comma-separated list of human readable API key names that you want to display to users. This is to ensure that end-users can easily select the correct API key when querying the database, without you having to expose the actual API key. These can be any string, but should be unique and easily identifiable.

Here is an example of what the .env file should look like:

With a single API key:

DEFOG_API_KEY=YOUR_API_KEY
DEFOG_API_KEY_NAMES="My Dataset"
...

With multiple API keys

DEFOG_API_KEY=YOUR_API_KEY_1,YOUR_API_KEY_2
DEFOG_API_KEY_NAMES="Dataset 1,Dataset 2"
...

Running the app

To start the app, run the following command:

docker compose up

You can then view Defog's UI in your browser by visiting http://localhost:80, and log in with the default user id admin and password admin.

To stop Defog Docker, press Ctrl+C in the terminal where you ran the docker compose up command.

You might see an error the very first time you run docker compose up. If this happens, simply exit with Ctrl+C, and then run docker compose up again.

If you want to run Defog Docker in the background, you can run the following command:

docker compose up -d

Updating your docker image

To update your docker image to the latest version, run the following command:

# first, stop the running container
docker compose down
 
# make sure you have the latest docker-compose.yaml and .env files from git at https://github.com/defog-ai/defog-docker
git pull
 
# then, remove the existing image
docker compose rm -f
 
# next, pull the latest image
docker compose pull
 
# finally, run the updated image
docker compose up