# Setup

### 1. Installing Docker, Docker Compose and Node.js <a href="#installing-docker-docker-compose-and-node-js" id="installing-docker-docker-compose-and-node-js"></a>

We will use Docker to run all the services needed, except for Node.js which we will run locally.

1. [Install Docker and Docker Compose](https://docs.docker.com/engine/installation/).
2. [Install Node.js](https://nodejs.org/en/download/) (14.16.1 or newer, can be installed with Homebrew on OS/X)
3. Install Yarn (1.22.10 or newer): `npm install --global yarn@1.22.10`SetupSetup

### 2. Setup&#x20;

#### i. Clone the Git repository

First you will need to clone the Git repository:

```docker
git clone https://github.com/getredash/redash.git
cd redash/
```

#### ii. Set up environment variables

Create a `.env` file at the root and set any environment variables you need.

```docker
$ touch .env
```

{% hint style="info" %}
An environment variable named `REDASH_COOKIE_SECRET` is required to run the application. Read more why Redash uses secret keys [here](https://redash.io/help/open-source/admin-guide/secrets)
{% endhint %}

You should include any relevant [environment variables](https://redash.io/help/open-source/admin-guide/env-vars-settings) in this file.

#### iii. Create Docker Services

Once you have the above setup, you need to create the Docker services:

```docker
docker-compose up -d
```

This will build the Docker images and fetch some prebuilt images and then start the services (Redash web server, worker, PostgreSQL and Redis). You can refer to the `docker-compose.yml` file to see the full configuration.

If you hit an `errno 137` or `errno 134` particularly at `RUN yarn build`, make sure you give your Docker VM enough memory (4GB or more).

#### vi. Install Node Packages

```docker
yarn --frozen-lockfile
```

#### v. Create Database

```docker
# Create tables
docker-compose run --rm server create_db

# Create database for tests
docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests"
```

#### vi. Health Check for Installation

{% hint style="warning" %}
After your installation is complete, you can do the healthcheck by calling `/ping` API endpoint.
{% endhint %}

```docker
RESPONSE

PONG.
```

### 3. Usage

#### i. Run webpack Dev Server

Once all Docker services are running (can be started either by `docker-compose up` or `docker-compose start`), Redash is available at `http://localhost:5000/`.

While we will use webpack’s dev server, we still need to build the frontend assets at least once, as some of them used for static pages (login page and such):

```docker
yarn build
```

To work on the frontend code, you need to use the webpack dev server, which you start with:

```docker
yarn start
```

Now the dev server is available at `http://localhost:8080`. It rebuilds the frontend code when you change it and refreshes the browser. All the API calls are proxied to `localhost:5000` (the server running in Docker).

#### ii. Installing new Python packages (requirements.txt)

If you pulled a new version with new packages or added some yourself, you will need to rebuild the `server` and `worker` images:

```docker
docker-compose build worker
docker-compose build server
```

#### iii. Running Tests

```docker
docker-compose run --rm server tests
```

Before running tests for the first time, you need to create a database for tests:

```docker
docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests;"
```

#### vi. Debugging

See [Debugging a Redash Server on Docker Using Visual Studio Code](https://redash.io/help/open-source/dev-guide/debugging)


---

# 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.inverse.watch/admin-and-dev-guide/setup.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.
