|
1 | 1 | # civis-services-streamlit
|
2 |
| -Civis Services Docker Image for Streamlit |
| 2 | + |
| 3 | +This repository provides the following components: |
| 4 | + |
| 5 | +* A Docker image to support Streamlit applications on Civis Platform |
| 6 | +* A demo Streamlit app that's readily deployable on Civis Platform |
| 7 | + |
| 8 | +## Quickstart Using the Demo Application |
| 9 | + |
| 10 | +To get a sense of what a Streamlit app looks like on Civis Platform: |
| 11 | + |
| 12 | +* Log on to Civis Platform. |
| 13 | +* From the top navigation bar, click "Publish". |
| 14 | +* Under "Services", click "Streamlit Demo". |
| 15 | + |
| 16 | +These steps create a new Civis Platform service configured for a Streamlit demo app |
| 17 | +pointing to this GitHub repository. |
| 18 | +The app is now ready to be deployed. |
| 19 | +Please follow [these instructions](https://support.civisanalytics.com/hc/en-us/articles/360001335031-Civis-Service-Deployment#StartaService/PreviewaDeployment) |
| 20 | +for service deployment. |
| 21 | + |
| 22 | +If you would like to start making the demo app your own |
| 23 | +by making code changes, |
| 24 | +you may [fork this GitHub repository](https://github.com/civisanalytics/civis-services-streamlit/fork) |
| 25 | +where the demo app's source code is in the directory [`demo_app/`](demo_app). |
| 26 | +If you would like to host and use your own Docker image, |
| 27 | +[`Dockerfile`](Dockerfile) and [`entrypoint.sh`](entrypoint.sh) from this GitHub repository |
| 28 | +define the `civisanalytics/civis-services-streamlit` image that you may like to modify |
| 29 | +and then host on your own DockerHub account. |
| 30 | + |
| 31 | +## Building and Deploying Your Streamlit Application |
| 32 | + |
| 33 | +If you would like to build your own Streamlit application from scratch |
| 34 | +and deploy it on Civis Platform, |
| 35 | +here are the requirements. |
| 36 | + |
| 37 | +1. Your Streamlit application must have its source code hosted on a GitHub repository. |
| 38 | + The Civis Platform user account that's going to deploy this Streamlit app must have |
| 39 | + access to this GitHub repo. |
| 40 | +2. The following explains the expected files for your app: |
| 41 | + |
| 42 | + * `app.py` |
| 43 | + |
| 44 | + A required file. |
| 45 | + `app.py` is your Streamlit app's entry point. |
| 46 | + For which Python version you should use (e.g., Python 3.12), |
| 47 | + it is determined by which Docker image name and tag you're going to use |
| 48 | + to deploy your app on Civis Platform. |
| 49 | + The Python version is specified by the base image in the file `Dockerfile` |
| 50 | + of this GitHub repo. |
| 51 | + |
| 52 | + * `requirements.txt` |
| 53 | + |
| 54 | + A strongly recommended file, though not strictly required. |
| 55 | + `requirements.txt` specifies the Python dependencies to be installed for your Streamlit app to work. |
| 56 | + Note that `streamlit` itself should be one of the packages specified |
| 57 | + (so that you can pin the specific Streamlit version for your use case). |
| 58 | + If `requirements.txt` is present, |
| 59 | + the command `pip install -r requirements.txt` will be run to install these dependencies. |
| 60 | + |
| 61 | + * `pyproject.toml` |
| 62 | + |
| 63 | + An optional file. |
| 64 | + If a Python package needs to be installed in order for your Streamlit app to work, |
| 65 | + `pyproject.toml` plus the associated package code must be present. |
| 66 | + If `pyproject.toml` is detected, |
| 67 | + `pip install --no-deps -e .` will be run to install your Python package |
| 68 | + (`--no-deps` for not installing dependencies defined in `pyproject.toml`, |
| 69 | + because they should already be specified in `requirements.txt` above). |
| 70 | + |
| 71 | + * `.streamlit/config.toml` |
| 72 | + |
| 73 | + An optional file. |
| 74 | + These are Streamlit options, if you need to configure them. Reference: |
| 75 | + https://docs.streamlit.io/develop/api-reference/configuration/config.toml |
| 76 | + |
| 77 | +3. Once your app code is on a GitHub repo, either create a new service on Civis Platform |
| 78 | + by following [this page](https://support.civisanalytics.com/hc/en-us/articles/360001335031-Civis-Service-Deployment), |
| 79 | + or launch a Streamlit template service from Civis Platform's top navigation bar -> Publish |
| 80 | + -> Services -> Streamlit Demo. |
| 81 | + Specify or adjust the GitHub repo URL as well as the Git tag (or branch, or Git commit hash). |
| 82 | +4. If your code is at a directory in your repo (rather than directly at the root level of your repo), |
| 83 | + specify the directory path that points to where the app code is located. |
| 84 | + (For the demo app in the previous section above, the directory path would be `demo_app` from this current repo.) |
| 85 | +5. For the Docker image, the name is `civisanalytics/civis-services-streamlit`, |
| 86 | + and the tag is one of those [listed on DockerHub](https://hub.docker.com/repository/docker/civisanalytics/civis-services-streamlit/tags). |
| 87 | + Note that the specific Docker image name and tag you've chosen determines which Python version |
| 88 | + your app is going to run on. |
| 89 | + |
| 90 | +## Support |
| 91 | + |
| 92 | +For feature inquiries, bug reports, and other questions, |
| 93 | +Civis client users should reach out to [email protected]. |
| 94 | + |
| 95 | +## Changelog |
| 96 | + |
| 97 | +See [CHANGELOG.md](CHANGELOG.md). |
| 98 | + |
| 99 | +## License |
| 100 | + |
| 101 | +BSD-3 |
| 102 | + |
| 103 | +See [LICENSE.txt](LICENSE.txt). |
0 commit comments