Deploying Streamlit Apps Intermediate
Once your Streamlit app is ready, you need to deploy it so others can access it. This lesson covers Streamlit Community Cloud (free), Docker, Hugging Face Spaces, and cloud providers like AWS and GCP.
Streamlit Community Cloud
The easiest way to deploy — free hosting directly from your GitHub repository:
-
Push your app to GitHub
Your repository should contain
app.pyandrequirements.txt. -
Go to share.streamlit.io
Sign in with your GitHub account and click "New app."
-
Select your repository
Choose the repo, branch, and main file path (e.g.,
app.py). -
Click Deploy
Your app will be live in minutes at
https://your-app.streamlit.app.
requirements.txt
streamlit==1.37.0 pandas==2.1.0 plotly==5.18.0 scikit-learn==1.3.0
Secrets on Community Cloud: Add secrets through the app settings dashboard (not in your repository). Access them with
st.secrets["KEY"] or via a .streamlit/secrets.toml file locally.
Docker Deployment
Dockerfile
FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . EXPOSE 8501 HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
Terminal
# Build and run docker build -t my-streamlit-app . docker run -p 8501:8501 my-streamlit-app
Hugging Face Spaces
Deploy on HF Spaces for free with the Streamlit SDK:
YAML (README.md)
--- title: My Streamlit App emoji: 📊 sdk: streamlit sdk_version: 1.37.0 app_file: app.py pinned: false ---
Cloud Provider Deployment
| Platform | Method | Cost |
|---|---|---|
| AWS | ECS/Fargate with Docker, or EC2 | Pay per use |
| GCP | Cloud Run (Docker), App Engine, or GCE | Pay per use (free tier available) |
| Azure | Azure Container Apps or App Service | Pay per use |
| Railway | Direct from GitHub, auto-detect | Free tier + pay per use |
| Render | Docker or direct Python deployment | Free tier available |
Google Cloud Run Example
Terminal
# Build and push to Google Container Registry gcloud builds submit --tag gcr.io/MY_PROJECT/my-streamlit-app # Deploy to Cloud Run gcloud run deploy my-streamlit-app \ --image gcr.io/MY_PROJECT/my-streamlit-app \ --port 8501 \ --allow-unauthenticated
App Deployed!
Your Streamlit app is live. In the final lesson, learn best practices for building production-quality Streamlit applications.
Next: Best Practices →
Lilly Tech Systems