---
title: "Local Deployment"
description: "Local deployment for Embedchain examples leverages Docker Compose to orchestrate multi-container applications. This approach provides a consistent and isolated environment for running various compo..."
last_updated: "2026-05-07T04:45:15.949151+00:00"
canonical_url: "https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/technical/section-7/local-deployment"
---

<details>
<summary>Relevant source files</summary>

The following files were used as context for generating this wiki page:

- [embedchain/examples/full_stack/docker-compose.yml](https://github.com/blade47/mem0/blob/main/embedchain/examples/full_stack/docker-compose.yml)
- [embedchain/examples/api_server/docker-compose.yml](https://github.com/blade47/mem0/blob/main/embedchain/examples/api_server/docker-compose.yml)
- [embedchain/examples/discord_bot/docker-compose.yml](https://github.com/blade47/mem0/blob/main/embedchain/examples/discord_bot/docker-compose.yml)
</details>

Local deployment for Embedchain examples leverages Docker Compose to orchestrate multi-container applications. This approach provides a consistent and isolated environment for running various components, such as backend APIs, frontend user interfaces, and specialized bots, without interfering with the host system's dependencies. By defining services, networks, and volumes in a `docker-compose.yml` file, developers can easily set up and manage complex application stacks locally.

This document outlines the local deployment strategies for several Embedchain examples, including a full-stack application, a standalone API server, and a Discord bot, all based on their respective Docker Compose configurations.

<Callout title="Prerequisites" variant="info">
To deploy these examples locally, you must have Docker and Docker Compose installed on your system.
</Callout>

## Common Deployment Principles

All provided Docker Compose configurations adhere to a common structure and utilize similar principles for service definition:

*   **Docker Compose Version**: All examples use `version: "3.9"`, indicating compatibility with Docker Compose file format version 3.9.
*   **Service Definition**: Each component of an application (e.g., backend, frontend) is defined as a `service`.
*   **Container Naming**: A `container_name` is explicitly set for each service to provide a human-readable identifier for the running container.
*   **Restart Policy**: The `restart: unless-stopped` policy ensures that containers automatically restart if they stop for any reason, unless explicitly stopped by the user.
*   **Build Context**: Services are built from a `Dockerfile` located within a specified `context` directory.
Sources: [embedchain/examples/full_stack/docker-compose.yml:1-19](https://github.com/blade47/mem0/blob/main/embedchain/examples/full_stack/docker-compose.yml#L1-L19), [embedchain/examples/api_server/docker-compose.yml:1-13](https://github.com/blade47/mem0/blob/main/embedchain/examples/api_server/docker-compose.yml#L1-L13), [embedchain/examples/discord_bot/docker-compose.yml:1-9](https://github.com/blade47/mem0/blob/main/embedchain/examples/discord_bot/docker-compose.yml#L1-L9)

## Full-Stack Application Deployment

The full-stack example demonstrates a complete web application with a separate backend API and a frontend user interface.

### Architecture

This deployment consists of two primary services: `backend` and `frontend`. The `frontend` service is configured to depend on the `backend` service, ensuring the backend is available before the frontend attempts to start. Both services expose specific ports to the host machine, allowing external access.

```mermaid
sequenceDiagram
    participant User
    participant Frontend as "embedchain-frontend:3000"
    participant Backend as "embedchain-backend:8000"

    User->>Frontend: Access Web App (localhost:3000)
    Frontend->>Backend: API Request (e.g., /query)
    Backend-->>Frontend: API Response
    Frontend-->>User: Render UI
```

### Service Details

*   **`backend` service**:
    *   `container_name`: `embedchain-backend`
    *   `build`: Uses `backend/Dockerfile` within the `backend` context.
    *   `image`: `embedchain/backend`
    *   `ports`: Maps host port `8000` to container port `8000`.
*   **`frontend` service**:
    *   `container_name`: `embedchain-frontend`
    *   `build`: Uses `frontend/Dockerfile` within the `frontend` context.
    *   `image`: `embedchain/frontend`
    *   `ports`: Maps host port `3000` to container port `3000`.
    *   `depends_on`: Ensures the `backend` service starts before the `frontend`.
Sources: [embedchain/examples/full_stack/docker-compose.yml:3-19](https://github.com/blade47/mem0/blob/main/embedchain/examples/full_stack/docker-compose.yml#L3-L19)

## API Server Deployment

The API server example focuses on deploying a standalone backend API.

### Architecture

This deployment consists of a single `backend` service that acts as the API server. It exposes a specific port, mounts a local directory as a volume for development or configuration, and loads environment variables from a dedicated file.



### Service Details

*   **`backend` service**:
    *   `container_name`: `embedchain_api`
    *   `build`: Uses `Dockerfile` within the current directory (`.`) context.
    *   `env_file`: Loads environment variables from `variables.env`.
    *   `ports`: Maps host port `5000` to container port `5000`.
    *   `volumes`: Mounts the current host directory (`.`) to `/usr/src/api` inside the container. This is useful for hot-reloading code changes during development.
Sources: [embedchain/examples/api_server/docker-compose.yml:3-13](https://github.com/blade47/mem0/blob/main/embedchain/examples/api_server/docker-compose.yml#L3-L13)

## Discord Bot Deployment

The Discord bot example demonstrates deploying a bot application.

### Architecture

This deployment consists of a single `backend` service responsible for running the Discord bot logic. It builds from a local Dockerfile and relies on an environment file for sensitive configurations like API tokens.



### Service Details

*   **`backend` service**:
    *   `container_name`: `embedchain_discord_bot`
    *   `build`: Uses `Dockerfile` within the current directory (`.`) context.
    *   `env_file`: Loads environment variables from `variables.env`. This file would typically contain the Discord bot token and other necessary credentials.
Sources: [embedchain/examples/discord_bot/docker-compose.yml:3-9](https://github.com/blade47/mem0/blob/main/embedchain/examples/discord_bot/docker-compose.yml#L3-L9)

<Accordions>
<Accordion title="Using `variables.env` files">
The `env_file` directive in Docker Compose allows you to pass environment variables from a file directly into your container. This is crucial for managing sensitive information (like API keys or tokens) separately from your `docker-compose.yml` file, preventing them from being hardcoded or committed to version control. Ensure you create a `variables.env` file in the specified location with the required key-value pairs before starting the services.
</Accordion>
</Accordions>

## Deployment Steps

<Steps>
<Step>
### Navigate to the example directory
Change your current directory to the specific Embedchain example you wish to deploy (e.g., `embedchain/examples/full_stack`).
</Step>
<Step>
### Prepare environment variables (if applicable)
If the example uses an `env_file` (like `api_server` or `discord_bot`), create a `variables.env` file in the root of that example directory and populate it with the necessary environment variables (e.g., API keys, tokens).
</Step>
<Step>
### Start the services
Run the following command in your terminal from the example directory:
```bash
docker compose up -d
```
The `-d` flag runs the containers in detached mode, allowing them to run in the background.
</Step>
<Step>
### Access the application
*   **Full-Stack**: Open your web browser and navigate to `http://localhost:3000`.
*   **API Server**: The API will be accessible on `http://localhost:5000`. You can use tools like `curl` or Postman to interact with it.
*   **Discord Bot**: The bot will connect to Discord. Check your Discord server for its online status and functionality.
</Step>
<Step>
### Stop the services
To stop and remove the containers, networks, and volumes created by `docker compose up`, run:
```bash
docker compose down
```
</Step>
</Steps>

## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/llms.txt) for all pages in this wiki.
