[Feature] Add support for docker in fullstack app (#1134)

This commit is contained in:
Deshraj Yadav
2024-01-07 23:49:20 +05:30
committed by GitHub
parent 4dfce44c1a
commit 0c45020d81
2 changed files with 49 additions and 15 deletions

View File

@@ -2,36 +2,61 @@
title: '💻 Full stack' title: '💻 Full stack'
--- ---
Embedchain provides a clean and simple cli utility that lets you create full-stack RAG applications locally with a single command. Get started with full-stack RAG applications using Embedchain's easy-to-use CLI tool. Set up everything with just a few commands, whether you prefer Docker or not.
## Prerequisite ## Prerequisites
Choose your setup method:
### Without Docker
Ensure these are installed:
Make sure that you have installed the following:
- Embedchain python package (`pip install embedchain`) - Embedchain python package (`pip install embedchain`)
- [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) and [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/) - [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) and [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/)
## Get started ### With Docker
Install Docker from [Docker's official website](https://docs.docker.com/engine/install/).
## Quick Start Guide
### Setting Up
For the purpose of the demo, you have to set `OPENAI_API_KEY` to start with but you can choose any llm by changing the configuration easily. For the purpose of the demo, you have to set `OPENAI_API_KEY` to start with but you can choose any llm by changing the configuration easily.
Now run the following commands: ### Installation Commands
```bash <CodeGroup>
```bash without docker
ec create-app my-app ec create-app my-app
cd my-app cd my-app
ec start ec start
``` ```
Once you run this command, Embedchain does the following: ```bash with docker
ec create-app my-app --docker
cd my-app
ec start --docker
```
1. Fetch full stack template that uses FastAPI for backend, and Next.JS template for frontend </CodeGroup>
2. Install necessary requirements
3. Launch the frontend and backend server for you to interact with
Once you are done, visit `http://localhost:3000` and you will see a chat UI as shown below. ### What Happens Next?
1. Embedchain fetches a full stack template (FastAPI backend, Next.JS frontend).
2. Installs required components.
3. Launches both frontend and backend servers.
### See It In Action
Open http://localhost:3000 to view the chat UI.
![full stack example](/images/fullstack.png) ![full stack example](/images/fullstack.png)
You can navigate to [Embedchain admin panel] where you can see the chunks created for your documents that you ingested for your RAG application. Below is a screenshot for the same: ### Admin Panel
Check out the Embedchain admin panel to see the document chunks for your RAG application.
![full stack chunks](/images/fullstack-chunks.png) ![full stack chunks](/images/fullstack-chunks.png)

View File

@@ -49,8 +49,9 @@ def cli():
@cli.command() @cli.command()
@click.argument("app_name") @click.argument("app_name")
@click.option("--docker", is_flag=True, help="Use docker to create the app.")
@click.pass_context @click.pass_context
def create_app(ctx, app_name): def create_app(ctx, app_name, docker):
if Path(app_name).exists(): if Path(app_name).exists():
console.print( console.print(
f"❌ [red]Directory '{app_name}' already exists. Try using a new directory name, or remove it.[/red]" f"❌ [red]Directory '{app_name}' already exists. Try using a new directory name, or remove it.[/red]"
@@ -98,7 +99,10 @@ def create_app(ctx, app_name):
anonymous_telemetry.capture(event_name="ec_create_app", properties={"success": False}) anonymous_telemetry.capture(event_name="ec_create_app", properties={"success": False})
return return
ctx.invoke(install_reqs) if docker:
subprocess.run(["docker-compose", "build"], check=True)
else:
ctx.invoke(install_reqs)
@cli.command() @cli.command()
@@ -126,7 +130,12 @@ def install_reqs():
@cli.command() @cli.command()
def start(): @click.option("--docker", is_flag=True, help="Run inside docker.")
def start(docker):
if docker:
subprocess.run(["docker-compose", "up"], check=True)
return
# Set up signal handling # Set up signal handling
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGTERM, signal_handler)