Skip to content

Commit

Permalink
[Doc] Update Vizro docs and example template (#306)
Browse files Browse the repository at this point in the history
* Update docs and example template

* Apply suggestions from code review
  • Loading branch information
antonymilne authored Jan 17, 2025
1 parent bf0e7f8 commit b7b4080
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
17 changes: 10 additions & 7 deletions doc/apps/vizro.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,29 @@ You can get started quickly using our [template repository](https://github.com/p
Your `app.py` should initialize the Vizro application as follows:

```python
import vizro as vm
import vizro.models as vm
from vizro import Vizro

# Initialize your dashboard
page = vm.Page(...)
dashboard = vm.Dashboard(pages=[page])

# Create the application instance
app = Vizro().build(dashboard)

# Expose the Flask server to Gunicorn
server = app.dash.server

# Development server (optional)
if __name__ == "__main__":
app.run()
```

2. Dependencies File (`requirements.txt`)

List all Python packages required by your application.
List all Python packages required by your application. These should include pinned versions of `vizro` and `gunicorn`:

```
vizro==0.1.29
gunicorn==23.0.0
```

3. `Dockerfile`

Expand All @@ -64,14 +67,14 @@ WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt gunicorn vizro
RUN pip install --no-cache-dir -r requirements.txt

# Copy application files
COPY . .

# Configure the container
EXPOSE 80
ENTRYPOINT ["gunicorn", "app:server", "run", "--bind", "0.0.0.0:80"]
ENTRYPOINT ["gunicorn", "app:app", "--bind", "0.0.0.0:80"]
```

## Testing locally
Expand Down
20 changes: 5 additions & 15 deletions examples/docker/vizro/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
FROM python:3.11-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on

# Set work directory
WORKDIR /app

# Install Python dependencies
RUN pip install gunicorn
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy project files
# Copy application files
COPY . .

# Expose the port
EXPOSE 8000

# Run the application using Gunicorn
ENTRYPOINT ["gunicorn", "app:server", "run", "--bind", "0.0.0.0:80"]
# Configure the container
EXPOSE 80
ENTRYPOINT ["gunicorn", "app:app", "--bind", "0.0.0.0:80"]
1 change: 0 additions & 1 deletion examples/docker/vizro/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

dashboard = vm.Dashboard(pages=[page])
app = Vizro().build(dashboard)
server = app.dash.server

if __name__ == "__main__":
app.run()
1 change: 1 addition & 0 deletions examples/docker/vizro/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vizro==0.1.29
gunicorn==23.0.0

0 comments on commit b7b4080

Please sign in to comment.