Skip to content

Commit

Permalink
docker and flask docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bryannho committed May 13, 2024
1 parent ef49d01 commit 3981e2e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
8 changes: 4 additions & 4 deletions doc/apps/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ To deploy a Docker-based web application in Ploomber Cloud you need:

## `Dockerfile`

You need to provide a `Dockerfile`, you can use this [flask-based template](https://github.com/ploomber/doc/blob/main/examples/flask/basic-app/Dockerfile) to get started.
You need to provide a `Dockerfile`, you can use this [FastAPI-based template](https://github.com/ploomber/doc/blob/main/examples/fastapi/basic-app/Dockerfile) to get started.

For a successful deployment, you app must run in port 80.

Here's an example using flask:
Here's an example using FastAPI:

```Dockerfile
FROM python:3.11

COPY app.py app.py
RUN pip install flask gunicorn
RUN pip install fastapi uvicorn --no-cache-dir

ENTRYPOINT ["gunicorn", "app:app", "run", "--bind", "0.0.0.0:80"]
ENTRYPOINT ["uvicorn", "app:app", "--host=0.0.0.0", "--port=80"]
```

Once you have all your files, `.zip` them. For example, a simple app will contain two files:
Expand Down
49 changes: 48 additions & 1 deletion doc/apps/flask.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,59 @@ Now, open [http://0.0.0.0:5000/](http://0.0.0.0:5000/) to see your app.

## Deploy

`````{tab-set}
````{tab-item} Web
__Deploy from the menu__
Once you have all your files, create a zip file.
To deploy a Flask app from the deployment menu, follow these instructions:
![](../static/docker.png)
![](../static/flask.png)
````
````{tab-item} Command-line
__Try an example__
To download and deploy an example Flask application start by installing Ploomber Cloud and setting your API key:
```sh
pip install ploomber-cloud
ploomber-cloud key YOUR-KEY
```
```{tip}
If you don't have an API key yet, follow the [instructions here.](../quickstart/apikey.md)
```
Now, download an example. It will prompt you for a location to download the app. To download in the current directory, just press enter.
```sh
ploomber-cloud examples flask/basic-app
```
```{note}
A full list of Flask example apps is available [here.](https://github.com/ploomber/doc/tree/main/examples/flask)
```
You should see a confirmation with instructions on deploying your app. Now, navigate to your application:
```sh
cd location-you-entered/basic-app
```
__Deploy from the CLI__
Initialize and deploy your app with:
```sh
ploomber-cloud init
ploomber-cloud deploy --watch
```
````
`````

```{tip}
To ensure your app doesn't break on re-deployments, pin your [dependencies.](pin-dependencies)
Expand Down
Binary file added doc/static/flask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3981e2e

Please sign in to comment.