Dash Enterprise Continuous Integration

This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
Jupyter notebooks.
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.

To set up CI/CD with Dash Enterprise, all you need to do is git push your code from your CI system to Dash Enterprise. Dash Enterprise handles creating the builds (Docker containers), deploying those containers, and opening up those containers to network traffic. For more details on how deployment works, go to App Structure, Buildpacks, and Deployment Lifecycle.

This set of instructions demonstrates how to write a script that deploys your code to Dash Enterprise from a CI system. In practice, you can modify these scripts to only run when your code has been merged rather than on every branch and pull request.

To set up a CI pipeline for Dash Enterprise:

  1. Designate a Dash Enterprise user with the admin role that will deploy the apps on behalf of the app owners. This user can be a new or existing one (Creating a new user requires access to Keycloak). You’ll consider this user a service account whose purpose is strictly to deploy apps, while app owners still log in using their individual Dash Enterprise accounts to manage apps outside of deployment.
  2. Create an SSH key pair without a passphrase. See Setting Up SSH Keys for more detailed instructions.
  3. Log in to Dash Enterprise as the service account. Select the username > Personal Settings, then add the SSH public key.
  4. Write a CI script that runs the git push command over SSH. There are many ways to do this. Here is one way:
  5. Encode the SSH private key in base64:

    Mac OS:

    bash cat id_ed25519 | base64 > id_ed25519.base64

    Linux:

    bash cat id_ed25519 | base64 -w 0 > id_ed25519.base64

    Windows:

    bash certutil -encode id_ed25519 id_ed25519.base64

    replacing id_ed25519 with the location of your SSH private key.

    This turns

    bash -----BEGIN OPENSSH PRIVATE KEY----- MIIG4wIBAAKCA [...] GtUlPGZb+Dyu1 -----END OPENSSH PRIVATE KEY-----

    into

    bash LS0tLS1CRUdJTiBP [...] UEVOU1NIIFBSSVZBV=

  6. Encode your SSH configuration file in base64:

    Mac OS:

    bash cat config | base64 > config-base64.txt

    Linux:

    bash cat config | base64 -w 0 > config-base64.txt

    Windows:

    bash certutil -encode config config-base64.txt

    This turns

    bash Host * StrictHostKeyChecking no UserKnownHostsFile=/dev/null

    into

    Vc2VyIGdpdAogHaH [...] ViX3RlbnmlubmdvCg==

  7. Add the following environment variables to your CI tool:

  1. Provide the following script to the CI tool. If the CI tool accepts YAML files that
    run steps one at a time, then you can provide each of these commands on their own line.

    ```bash

    !/bin/sh

    set -x

    echo ‘-----> Project directory’
    pwd
    ls -al

    echo ‘-----> Creating ssh key’
    echo “$SSH_PRIVATE_KEY” | base64 –decode -i > ~/.ssh/id_ed25519
    chmod 600 ~/.ssh/id_ed25519 # permissioning
    eval “$(ssh-agent -s)” # setting ssh environment variable

    echo ‘-----> Adding keys to ssh-agent’
    ssh-add ~/.ssh/id_ed25519

    echo ‘-----> Creating ssh config’
    echo “$SSH_CONFIG” | base64 –decode -i > ~/.ssh/config

    echo ‘-----> Adding git remote’
    git config remote.plotly.url >&- || git remote add plotly git@<your-dash-enterprise-hostname>:<your-dash-app-name>

    echo ‘-----> Deploying app’
    git push plotly HEAD:main
    ```

    You’ll need to make a few changes to this script:

    • Replace &lt;your-dash-enterprise-hostname&gt; with your Dash Enterprise host name.
    • Replace &lt;your-app-name&gt; with the name of your app as initialized on Dash Enterprise.
    • The path of ~/.ssh may be different on your CI system. Consult your CI system’s docs on SSH.
  2. Trigger this CI script when code is merged into main.