> For the complete documentation index, see [llms.txt](https://docs.spaceoperator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spaceoperator.com/self-hosting/docker-compose.md).

# Docker Compose

Self-hosting with docker-compose.

## Prerequisites

* Install git, zip
* [Install docker and docker-compose](https://docs.docker.com/engine/install/)
* [Install Deno](https://deno.com/)
* [Install Supabase CLI (optional)](https://supabase.com/docs/guides/cli/getting-started?queryGroups=platform\&platform=linux#installing-the-supabase-cli)

Instructions for Linux OSes:

{% tabs %}
{% tab title="Fedora/CentOS" %}

```sh
sudo yum install -y git zip yum-utils

# Install and setup Docker for non-root user
yes | sudo  yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yes | sudo  yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
newgrp docker

# Install Deno
curl -fsSL https://deno.land/install.sh > /tmp/install.sh
chmod +x /tmp/install.sh
sudo env DENO_INSTALL=/usr/local /tmp/install.sh
rm /tmp/install.sh
```

{% endtab %}

{% tab title="Ubuntu" %}

```sh
TODO
```

{% endtab %}
{% endtabs %}

## Self-hosting with Docker Compose

### Download source code

Clone the code using git:

```sh
git clone https://github.com/space-operator/flow-backend
```

Go to `docker` folder:

```sh
cd flow-backend/docker
```

Every commands in this tutorial must be run in `flow-backend/docker` folder.

## Generate secrets and configurations

Our Docker Compose setup needs 2 configuration files, both are located in `flow-backend/docker` folder:

* `.env` : dotenv file containing environment variables
* `.config.toml`: configuration file used by flow-server.

Template for these files are in `env.example` and `flow-server-config.toml` .

Generate secrets and config files for your server:

```sh
./gen-secrets.ts
```

Generated secrets are saved in `.env` and `.config.toml` files.

The script use `env.example` and `flow-server-config.toml` as templates, you can edit them before running the script to customize values.

Start and wait for containers to be ready:

```sh
docker compose up -d --wait
```

Port binding:

* Supabase: port 8000
* Flow server: port 8080
* PostgreSQL: port 5432

To see Supabase Dashboard:

* Open `.env` file to see `DASHBOARD_USERNAME` and `DASHBOARD_PASSWORD` values:

```sh
cat .env | grep DASHBOARD
```

* Visit <http://localhost:8000/> .

## Export your data and use them in self-hosted server

Follow steps from [here](/self-hosting/export-data-to-your-instance.md)

## Stop and clean up

To stop services:

```
docker compose down
```

Stop and clean up all data:

```
docker compose down -v
```
