> ## Documentation Index
> Fetch the complete documentation index at: https://www.diadata.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Compose

## Configure Environment Variables

<Steps>
  <Step>
    Navigate to the docker-compose folder where `docker-compose.yaml` file is located.

    ```bash theme={"system"}
    cd docker-compose
    ```
  </Step>

  <Step>
    Create a `.env` file in the same folder. it should contain the following variables:

    * `NODE_OPERATOR_NAME`: A unique and descriptive name identifying the organization or entity running the node. This name is used for monitoring and should be chosen carefully to ensure it is both meaningful and recognizable (e.g., include your organization name or geographical region). Providing a clear name helps distinguish your node in dashboards and logs.

    * `CHAIN_ID`: set the chain ID value

    * `PRIVATE_KEY`: Your private key for the deployment.

    * `DEPLOYED_CONTRACT`: The contract address. Initially, leave this empty during the first deployment to retrieve the deployed contract.

    <Info>
      The following pushgateway vars are **mandatory** for official DIA node operators. If you're an official operator, please reach out to the team to get these credentials. For developers testing the system, these credentials are **optional** and can be skipped.
    </Info>

    * `PUSHGATEWAY_URL`: The Pushgateway endpoint used for pushing metrics to Prometheus.

    * `PUSHGATEWAY_USER`: to allow decentralized-feeder authenticate towards the monitoring server.

    * `PUSHGATEWAY_PASSWORD`: to allow decentralized-feeder authenticate towards the monitoring server.

    For additional environment variable configurations, refer to [Adding Exchange Pairs](https://github.com/diadata-org/decentral-feeder/wiki/Adding-exchange-pairs) and [Watchdog environment variables](https://github.com/diadata-org/decentral-feeder/wiki/Enabling-watchdogs).

    E.g. Env file:

    ```bash theme={"system"}
    NODE_OPERATOR_NAME=
    CHAIN_ID=
    PRIVATE_KEY=
    DEPLOYED_CONTRACT=
    PUSHGATEWAY_URL=
    PUSHGATEWAY_USER=
    PUSHGATEWAY_PASSWORD=
    ```
  </Step>

  <Step>
    Open a terminal in the `docker-compose` folder and start the deployment by running:

    ```bash theme={"system"}
    docker-compose up
    ```
  </Step>
</Steps>

## Retrieve Deployed Contract

<Steps>
  <Step>
    Once the container is deployed with `DEPLOYED_CONTRACT` env variable empty the logs will display the deployed contract address in the following format:

    ```bash theme={"system"}
    │ time="2024-11-25T11:30:08Z" level=info msg="Contract pending deploy: 0xxxxxxxxxxxxxxxxxxxxxxxxxx."
    ```
  </Step>

  <Step>
    Copy the displayed contract address (e.g., `0xxxxxxxxxxxxxxxxxxxxxxxxxx`) and stop the container with

    ```bash theme={"system"}
    docker rm -f <container_name>
    ```
  </Step>

  <Step>
    Check if the container is running correctly by viewing the logs. Run the following command:

    ```bash theme={"system"}
    docker-compose logs -f
    ```
  </Step>

  <Step>
    Look for logs similar to the example below, which indicate a successful startup:

    ```bash theme={"system"}
    │ time="2024-10-29T13:39:35Z" level=info msg="Processor - Atomic filter value for market Binance:SUSHI-USDT with 20 trades: 0.7095307176575745."                                                                  │
    │ time="2024-10-29T13:39:35Z" level=info msg="Processor - Atomic filter value for market Simulation:UNI-USDC with 1 trades: 8.008539500390082."                                                                   │
    │ time="2024-10-29T13:39:35Z" level=info msg="Processor - Atomic filter value for market Crypto.com:USDT-USD with 5 trades: 0.99948."                                                                             │
    │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for MOVR: 9.864475653518195."                                                                                                             │
    │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for STORJ: 0.4672954012114179."                                                                                                           │
    │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for DIA: 0.9839597410694259."                                                                                                             │
    │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for WETH: 2626.9564003841315."
    ```
  </Step>
</Steps>

## Remove Container (Optional)

<Steps>
  <Step>
    You can optionally cleanup the deployment once you're done by running:

    ```bash theme={"system"}
    docker rm -f <container_name>
    ```
  </Step>

  <Step>
    Verify the container has been removed:

    ```bash theme={"system"}
    docker ps -a
    ```
  </Step>
</Steps>
