[英]How to deploy a streamlit app to Heroku within a Docker container?
I recently started using streamlit
, which is definitely an awesome library for Dashboarding and visualizing Machine Learning applications.我最近开始使用
streamlit
,这绝对是一个很棒的用于仪表板和可视化机器学习应用程序的库。
However, my deployment workflow is currently Docker and Heroku.但是,我的部署工作流程目前是 Docker 和 Heroku。 I can't find simple documentation on how to easily deploy a
streamlit
app hosted within a Docker container onto Heroku.我找不到有关如何轻松地将托管在 Docker 容器中的
streamlit
式应用程序部署到 Heroku 的简单文档。 Therefore, I wanted to document something simple I found here.因此,我想记录一些我在这里找到的简单内容。
After a little bit of research and play around with the code, this is the simplest way that seems to be working:经过一些研究并使用代码,这似乎是最简单的方法:
.streamlit
folder where a config.toml
will live.streamlit
文件夹,其中config.toml
将存在config.toml
write the following code:config.toml
中编写以下代码:[browser]
serverAddress = '0.0.0.0'
CMD streamlit run --server.port $PORT app.py
For example, here is my complete Dockerfile based on the code example that streamlit currently provides比如这里是我基于streamlit目前提供的代码示例完整的Dockerfile
FROM continuumio/miniconda3
WORKDIR /home/app
RUN apt-get update
RUN apt-get install nano unzip
RUN apt install curl -y
RUN curl -fsSL https://get.deta.dev/cli.sh | sh
RUN pip install boto3 pandas gunicorn streamlit
COPY . /home/app
CMD streamlit run --server.port $PORT app.py
In development, simply run your container with a PORT
environment variable and a port mapping like this:在开发中,只需使用
PORT
环境变量和端口映射来运行容器,如下所示:
docker run -it MY_DOCKER_IMAGE -p HOST_PORT:CONTAINER_PORT -e PORT=CONTAINER_PORT
If everything works correctly locally, then you can follow this tutorial to deploy your container to Heroku:如果在本地一切正常,那么您可以按照本教程将您的容器部署到 Heroku:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.