Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-comics-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

Add fly.io deployment
5 changes: 0 additions & 5 deletions helpers/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,4 @@ export const installPythonTemplate = async ({
if (postInstallAction === "runApp" || postInstallAction === "dependencies") {
installPythonDependencies();
}

// Copy deployment files for python
await copy("**", root, {
cwd: path.join(compPath, "deployments", "python"),
});
};
5 changes: 0 additions & 5 deletions helpers/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ export const installTSTemplate = async ({
) {
await installTSDependencies(packageJson, packageManager, isOnline);
}

// Copy deployment files for typescript
await copy("**", root, {
cwd: path.join(compPath, "deployments", "typescript"),
});
};

async function updatePackageJson({
Expand Down
4 changes: 4 additions & 0 deletions templates/components/agents/python/blog/README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ To start the app optimized for **production**, run:
poetry run prod
```

## Deployments

For production deployments, check the [DEPLOY.md](DEPLOY.md) file.

## Learn More

To learn more about LlamaIndex, take a look at the following resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ To start the app optimized for **production**, run:
poetry run prod
```

## Deployments

For production deployments, check the [DEPLOY.md](DEPLOY.md) file.

## Learn More

To learn more about LlamaIndex, take a look at the following resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ To start the app optimized for **production**, run:
poetry run prod
```

## Deployments

For production deployments, check the [DEPLOY.md](DEPLOY.md) file.

## Learn More

To learn more about LlamaIndex, take a look at the following resources:
Expand Down
73 changes: 73 additions & 0 deletions templates/types/streaming/fastapi/DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## Deployments

### Using [Fly.io](https://fly.io/):

First, install [flyctl](https://fly.io/docs/flyctl/install/) and then authenticate with your Fly.io account:

```shell
fly auth login
```

Then, run this command and follow the prompts to deploy the app.:

```shell
fly launch
```

And to open the app in your browser:

```shell
fly apps open
```

> **Note**: The app will use the values from the `.env` file by default to simplify the deployment. Make sure all the needed environment variables in the [.env](.env) file are set. For production environments, you should not use the `.env` file, but [set the variables in Fly.io](https://fly.io/docs/rails/the-basics/configuration/) instead.

#### Documents

If you're having documents in the `./data` folder, run the following command to generate vector embeddings of the documents:

```
fly console --machine <machine_id> --command "poetry run generate"
```

Where `machine_id` is the ID of the machine where the app is running. You can show the running machines with the `fly machines` command.

> **Note**: Using documents will make the app stateful. As Fly.io is a stateless app, you should use [LlamaCloud](https://docs.cloud.llamaindex.ai/llamacloud/getting_started) or a vector database to store the embeddings of the documents. This applies also for document uploads by the user.

### Using Docker

First, build an image for the app:

```
docker build -t <your_image_name> .
```

Then, start the app by running the image:

```
docker run \
-v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system
-v $(pwd)/config:/app/config \
-v $(pwd)/storage:/app/storage \ # Use your file system to store vector embeddings
-p 8000:8000 \
<your_image_name>
```

Open [http://localhost:8000](http://localhost:8000) with your browser to start the app.

#### Documents

If you're having documents in the `./data` folder, run the following command to generate vector embeddings of the documents:

```
docker run \
--rm \
-v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system
-v $(pwd)/config:/app/config \
-v $(pwd)/data:/app/data \ # Use your local folder to read the data
-v $(pwd)/storage:/app/storage \ # Use your file system to store the vector database
<your_image_name> \
poetry run generate
```

The app will then be able to answer questions about the documents in the `./data` folder.
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
FROM python:3.11 as build
# ====================================
# Build the frontend
# ====================================
FROM node:20 AS frontend

WORKDIR /app/frontend

COPY .frontend /app/frontend

RUN npm install && npm run build


# ====================================
# Backend
# ====================================
FROM python:3.11 AS build

WORKDIR /app

Expand All @@ -19,8 +34,17 @@ COPY ./pyproject.toml ./poetry.lock* /app/
RUN poetry install --no-root --no-cache --only main

# ====================================
FROM build as release
# Release
# ====================================
FROM build AS release

COPY --from=frontend /app/frontend/out /app/static

COPY . .

CMD ["python", "main.py"]
# Remove frontend code
RUN rm -rf .frontend

EXPOSE 8000

CMD ["poetry", "run", "prod"]
34 changes: 2 additions & 32 deletions templates/types/streaming/fastapi/README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,9 @@ To start the app optimized for **production**, run:
poetry run prod
```

## Using Docker
## Deployments

1. Build an image for the FastAPI app:

```
docker build -t <your_backend_image_name> .
```

2. Generate embeddings:

Parse the data and generate the vector embeddings if the `./data` folder exists - otherwise, skip this step:

```
docker run \
--rm \
-v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system
-v $(pwd)/config:/app/config \
-v $(pwd)/data:/app/data \ # Use your local folder to read the data
-v $(pwd)/storage:/app/storage \ # Use your file system to store the vector database
<your_backend_image_name> \
poetry run generate
```

3. Start the API:

```
docker run \
-v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system
-v $(pwd)/config:/app/config \
-v $(pwd)/storage:/app/storage \ # Use your file system to store gea vector database
-p 8000:8000 \
<your_backend_image_name>
```
For production deployments, check the [DEPLOY.md](DEPLOY.md) file.

## Learn More

Expand Down
16 changes: 16 additions & 0 deletions templates/types/streaming/nextjs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20-alpine as build

WORKDIR /app

# Install dependencies
COPY package.json package-lock.* ./
RUN npm install

# Build the application
COPY . .
RUN npm run build

# ====================================
FROM build as release

CMD ["npm", "run", "start"]
Loading