Publish a Dash App

Dash is a popular Python framework for building interactive web applications. This guide shows how to run Dash apps in Domino, without diving into how Dash itself works. If you’re new to Dash or want examples of what’s possible, visit the Dash Gallery or the Dash documentation.

What you’ll do

  • Set up a custom Domino environment that includes Dash

  • Create a project and configure it for app publishing

  • Add and run Dash sample code that works with Domino routing

  • Publish and share your app using the Domino Launchpad interface

Step 1: Set up a compute environment

First, create a Domino compute environment that includes Dash:

  1. In Domino, go to Govern > Environments > Create Environment.

  2. Provide a name and description.

  3. Select the Domino Standard Environment as the base image.

  4. Click Create Environment.

  5. To add Dash, click Edit Definition and append the following lines to the Dockerfile:

    USER root
    RUN pip install dash==3.0.4
    USER ubuntu
  6. Then, click Build and wait for the process to complete.

This sets up a custom environment that supports Dash apps.

Step 2: Create a Project

Now you’ll create a project in Domino to hold your Dash app:

  1. From Domino, go to Develop > Projects > Create Project.

  2. Name your Project and click Create.

  3. In the sidebar, go to Settings > Compute environment and select the environment you just built.

  4. Go to Code > Add File, name the file app.py, and click Save.

Your project is now configured with the correct environment and is ready for app development.

Step 3: Add app code

You’ll now add the Python code for your Dash app. Domino requires a few lines of setup to handle routing correctly, but you can use any Dash app layout or logic you like. This basic app confirms that Dash is working in Domino. It renders a static Plotly chart with no data dependencies or interactivity.

To make your Dash app work in Domino, you must set routing using Domino environment variables and serve the app from 0.0.0.0 on port 8888.

  1. Open the app.py file you created earlier.

  2. Paste in the following code and save the file:

    import os
    import plotly.express as px
    from dash import Dash, dcc, html
    
    # Domino-specific routing
    runurl = os.environ.get("DOMINO_RUN_HOST_PATH")
    
    # Create app with routing config
    app = Dash(__name__,
                routes_pathname_prefix='/',
                requests_pathname_prefix=runurl)
    
    # Basic static chart
    fig = px.scatter(x=[1, 2, 3], y=[4, 1, 6], title="Sample Scatter Plot")
    
    # App layout
    app.layout = html.Div([
        html.H1("Minimal Dash App"),
        dcc.Graph(figure=fig)
    ])
    
    # Launch on Domino-compatible host and port
    if __name__ == '__main__':
        app.run(port=8888, host='0.0.0.0', debug=True)

Step 4: Add a startup script

Domino runs your app using a startup script. Create it like this:

  1. In the project sidebar, go to Code > Add File.

  2. Name the file app.sh and add python app.py to the file.

  3. Click Save.

This tells Domino how to launch your app during publishing.

Step 5: Publish the App

To make the app available through a browser:

  1. Go to Deployments > App in the sidebar.

  2. Add a title and description for your app.

  3. Set Permissions to Anyone can access to share the app broadly.

  4. Leave Make globally discoverable checked. If needed, you can disable this later.

  5. Click Publish. You may need to refresh your browser to view it.

Once the app is Running, click View App to open it in a new tab. This will launch your Dash app with a Domino toolbar and shareable link.

Step 6: Share the App

To share your app:

  1. Go to Deployments > App, and click Copy App Link.

  2. Open the link in an incognito or private browser window to test how the app appears to external users.

  3. Share the URL with collaborators.

  4. To browse other published apps, go to Deploy > Apps in the top nav.

Your Dash app is now hosted, versioned, and accessible in Domino. To explore more app designs or features, visit the Dash Gallery or the Dash documentation. These resources offer a wide range of examples you can experiment with and adapt to your own needs.

Next Steps