Skip to content

Commit

Permalink
Update doc, zip, remove Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
94rain committed Feb 28, 2024
1 parent b918f40 commit 3327d46
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 31 deletions.
38 changes: 14 additions & 24 deletions doc/apps/dash.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Dash

To deploy a [Dash](https://dash.plotly.com/) application to Ploomber Cloud you need:
To deploy a [Dash](https://dash.plotly.com/) application to Ploomber Cloud you need at least two files zipped up:

- A `Dockerfile`
- A Dash project
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that your app should exist in an `app.py` file and be initialized in this way:
## Required files

You can use this [template](https://github.com/ploomber/doc/blob/main/examples/dash) to get started.

In the `requirements.txt` file, add all the dependencies that you need for your application to run. The application logic should exist in an `app.py` file and be initialized in this way:

```python
# name your app "app"
Expand All @@ -14,30 +18,16 @@ app = Dash(__name__)
server = app.server
```

## `Dockerfile`

Use this [template](https://github.com/ploomber/doc/blob/main/examples/dash/simple-app/Dockerfile) `Dockerfile`:

```Dockerfile
FROM python:3.11

COPY app.py app.py
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

ENTRYPOINT ["gunicorn", "app:server", "run", "--bind", "0.0.0.0:80"]
```

## Testing locally

To test your app, you can use `docker` locally:
To test the Dash application, you can run the following commands locally:

```sh
# build the docker image
docker build . -t dash-app
pip install -r requirements.txt

# run it
docker run -p 5000:80 dash-app
# Start the dash application
gunicorn app:server run --bind 0.0.0.0:5000
```

Now, open [http://0.0.0.0:5000/](http://0.0.0.0:5000/) to see your app.
Expand All @@ -47,6 +37,6 @@ Now, open [http://0.0.0.0:5000/](http://0.0.0.0:5000/) to see your app.

Once you have all your files, create a zip file.

To deploy a Dash app from the deployment menu, select the Docker option and follow the instructions:
To deploy a Dash app from the deployment menu, select the Dash option and follow the instructions:

![](../static/docker.png)
![](../static/dash.png)
Binary file added doc/static/dash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions examples/dash/simple-app/Dockerfile

This file was deleted.

2 changes: 2 additions & 0 deletions examples/dash/simple-app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
app = Dash(__name__)
server = app.server

app.title = "Population by country - Ploomber Cloud Dash Application"

app.layout = html.Div(
[
html.H1(children="Population by country", style={"textAlign": "center"}),
Expand Down
Binary file modified examples/dash/simple-app/app.zip
Binary file not shown.

0 comments on commit 3327d46

Please sign in to comment.