Skip to content

Commit

Permalink
Add Chainlit docker-based example (#235)
Browse files Browse the repository at this point in the history
* remove old dockerfiles

* add docker-based example

* add note to chainlit, reformat others
  • Loading branch information
bryannho authored Jun 10, 2024
1 parent 03de096 commit c000903
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 19 deletions.
5 changes: 5 additions & 0 deletions doc/apps/chainlit.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ To deploy a Chainlit application in Ploomber Cloud you need:
- Your application file (`app.py`)
- A dependencies file (`requirements.txt`)

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/chainlit/docker-based) is a sample Docker-based `Chainlit` application.
```

## Testing locally

To test your app, you can use this command:
Expand Down
5 changes: 4 additions & 1 deletion doc/apps/dash.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ To deploy a [Dash](https://dash.plotly.com/) application you need a [Ploomber Cl
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/dash/docker-based) is a sample Docker-based `Dash` application.
```

## Required files

Expand Down
5 changes: 4 additions & 1 deletion doc/apps/panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ Once you have an account, you need at least two files:
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/panel/docker-based) is a sample Docker-based `Panel` application.
```


## Application file
Expand Down
5 changes: 4 additions & 1 deletion doc/apps/solara.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ To deploy a Solara app you need at least two files zipped up:
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/solara/docker-based) is a sample Docker-based `Solara` application.
```


```{note}
Expand Down
4 changes: 3 additions & 1 deletion doc/apps/streamlit.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ To deploy a Streamlit app you need at least two files:
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/streamlit/docker-based) is a sample Docker-based `Streamlit` application.
```

## Application file

Expand Down
5 changes: 4 additions & 1 deletion doc/apps/voila.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ To deploy an application you need two files:

For information on how to write Voilà applications, [please check the documentation](https://voila.readthedocs.io/en/stable/).

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/voila/docker-based) is a sample Docker-based `Voila` application.
```

## Dependencies

Expand Down
7 changes: 0 additions & 7 deletions examples/chainlit/app-with-auth0/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions examples/chainlit/basic-app/Dockerfile

This file was deleted.

11 changes: 11 additions & 0 deletions examples/chainlit/docker-based/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.11-slim-bookworm

WORKDIR /srv

COPY requirements.txt /srv/
COPY . /srv

RUN pip install chainlit --no-cache-dir
RUN pip install -r requirements.txt --no-cache-dir

ENTRYPOINT ["chainlit", "run", "app.py", "--host=0.0.0.0", "--port=80", "--headless"]
5 changes: 5 additions & 0 deletions examples/chainlit/docker-based/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Basic app

A basic Chainlit application to get started.

![](screenshot.webp)
10 changes: 10 additions & 0 deletions examples/chainlit/docker-based/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import chainlit as cl


@cl.on_message # this function will be called every time a user inputs a message in the UI
async def main(message: str):
# this is an intermediate step
await cl.Message(author="Tool 1", content=f"Response from tool1").send()

# send back the final answer
await cl.Message(content=f"This is a Docker-based Chainlit app.").send()
Binary file added examples/chainlit/docker-based/app.zip
Binary file not shown.
1 change: 1 addition & 0 deletions examples/chainlit/docker-based/chainlit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This app is hosted in [Ploomber Cloud!](https://ploomber.io/)
1 change: 1 addition & 0 deletions examples/chainlit/docker-based/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chainlit

0 comments on commit c000903

Please sign in to comment.