# Manual w/ docker run

{% hint style="warning" %}
We strongly recommend not to use this installation option, unless you don't have any other option. In most of cases, you should go with [docker compose](https://docs.uibakery.io/on-premise/install-and-update/installing-on-premise-version/manual-w-docker-compose) installation option since it is much easier for initial setup and further maintenance.
{% endhint %}

## Prerequisites

* Install [docker](https://docs.docker.com/engine/install/) 20.10.11 version or higher
* Create a directory for on-premise configuration files and download setup script:

  <pre class="language-bash"><code class="lang-bash"><strong>mkdir ui-bakery-on-premise &#x26;&#x26; cd ui-bakery-on-premise &#x26;&#x26; curl -k -L -o setup.sh https://raw.githubusercontent.com/uibakery/self-hosted/main/setup.sh
  </strong></code></pre>
* Run the setup.sh script to create .env file with required environmental variables:\
  `./setup.sh`

## Installation

### Pulling container images

First of all, pull all the docker images from UI Bakery's Docker container repository.

```bash
docker pull cruibakeryonprem.azurecr.io/cloud/gateway:latest &&\
docker pull cruibakeryonprem.azurecr.io/cloud/bakery-front:latest &&\
docker pull cruibakeryonprem.azurecr.io/cloud/workbench-front:latest &&\
docker pull cruibakeryonprem.azurecr.io/cloud/datasource:latest &&\
docker pull cruibakeryonprem.azurecr.io/cloud/python-runtime:latest &&\
docker pull cruibakeryonprem.azurecr.io/cloud/bakery-back:latest &&\
docker pull cruibakeryonprem.azurecr.io/cloud/automation:latest &&\
docker pull postgres:16.1 &&\
docker pull mysql:8.0
```

Note, that you might not need Mysql image in case you are using an external database.

### Creating a Docker network for images

```bash
docker network create ui-bakery-on-premise
```

This network will be later used by containers to communicate with each other.

### Starting containers one by one

In order to start the UI Bakery containers and run them one by one, use the following commands.

#### db (Internal UI Bakery database)

Used for storing user accounts and project metadata (not needed if an external database is used):

```bash
docker run -d \
  --name db \
  --restart always \
  --platform linux/amd64 \
  --cap-add SYS_NICE \
  --env-file .env \
  -e MYSQL_DATABASE=bakery \
  -e MYSQL_USER=bakery \
  -e MYSQL_PASSWORD=bakery \
  -e MYSQL_ROOT_PASSWORD=root \
  -v my-db:/var/lib/mysql \
  --health-cmd 'mysql -h localhost -u bakery --password=bakery -e "select 1"' \
  --health-timeout 1s \
  --health-interval 10s \
  --health-retries 10 \
  --network=ui-bakery-on-premise \
  mysql:8.0 --default-authentication-plugin=mysql_native_password
```

#### bakery-back

Bakery backend which is responsible for storing user accounts, project metadata, etc.

```bash
docker run -d \
  --name bakery-back \
  --env-file .env \
  --restart always \
  --network ui-bakery-on-premise \
  cruibakeryonprem.azurecr.io/cloud/bakery-back:latest
```

#### workbench-front

UI Bakery end-user frontend:

```bash
docker run -d \
  --name workbench-front \
  --env-file .env \
  --restart always \
  --network ui-bakery-on-premise \
  cruibakeryonprem.azurecr.io/cloud/workbench-front:latest
```

#### bakery-front

UI Bakery developer and workspace frontend:

```bash
docker run -d \
  --name bakery-front \
  --env-file .env \
  --restart always \
  --network ui-bakery-on-premise \
  cruibakeryonprem.azurecr.io/cloud/bakery-front:latest
```

#### datasource

UI Bakery data source connection middleware:

```bash
docker run -d \
  --name datasource \
  --env-file .env \
  --restart always \
  --network ui-bakery-on-premise \
  cruibakeryonprem.azurecr.io/cloud/datasource:latest
```

#### python-runtime

UI Bakery python backend code middleware:

```bash
docker run -d \
  --name python-runtime \
  --env-file .env \
  --restart always \
  --network ui-bakery-on-premise \
  cruibakeryonprem.azurecr.io/cloud/python-runtime:latest
```

#### **automation**

UI Bakery module for creating scheduled jobs and webhooks:

```bash
docker run -d \
  --name automation \
  --env-file .env \
  --restart always \
  --network ui-bakery-on-premise \
  cruibakeryonprem.azurecr.io/cloud/automation:latest
```

#### **gateway**

An entry point for all UI Bakery client requests:

```bash
docker run -d \
  --name gateway \
  --env-file .env \
  -p ${UI_BAKERY_PORT:-3030}:3030 \
  --restart always \
  --network ui-bakery-on-premise \
  cruibakeryonprem.azurecr.io/cloud/gateway:latest
```

#### bakery-db

Built-in [PostgreSQL](https://docs.uibakery.io/on-premise/additional-configurations/ui-bakery-postgres), available as [data source](https://docs.uibakery.io/extras/ui-bakery-postgres) in UI Bakery:

```bash
docker run -d \
  --name bakery-db \
  --restart always \
  --health-cmd "pg_isready -U bakery" \
  --health-interval 1s \
  --health-timeout 5s \
  --health-retries 10 \
  --env-file .env \
  -e POSTGRES_USER="bakery" \
  -e POSTGRES_PASSWORD="bakery" \
  -e POSTGRES_DB="bakery" \
  -v internal-db:/var/lib/postgresql/data \
  --network ui-bakery-on-premise \
  postgres:16.1
```

## Updating to the newer version

Pull the new container versions using[ the command specified above](#pulling-container-images). You can also pull a specific version by changing the `:latest` tag to the version that you need.

Stop running containers:

```bash
docker stop gateway automation datasource python-runtime bakery-front workbench-front bakery-back
```

Remove the containers:

```bash
docker rm gateway automation datasource python-runtime bakery-front workbench-front bakery-back
```

Restart all the containers except MySQL (db) and PostgreSQL (bakery-db) as defined in the [section above](#starting-containers-one-by-one).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/on-premise/install-and-update/installing-on-premise-version/manual-w-docker-run.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
