[PYTHON] How to deploy a Streamlit application to GCP (GAE)

0. Folder structure

application_directory └Dockerfile └app.py └app.yaml └requirements.txt

1. Create a Dockerfile

Create the following Dockerfile

FROM python:3.7
EXPOSE 8080
WORKDIR /app
COPY requirements.txt ./requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD streamlit run app.py --server.port 8080

2. Create requirements.txt

Create the following file.

streamlit

3. Create app.yaml

app.yaml


runtime: custom
env: flex

4. Deploy

Create any project on GCP.

Go to "App Engine" from the navigation menu on the home page of the created project and create an App Engine application. Select "Python" for Language and "Flexible" for Environment.

If you don't have the Google Cloud SDK installed, download and install it. Now you can use the glow command.

Perform the following operations in application_directory.

First, initialize the SDK if necessary.

$gcloud init

Then deploy to App Engine.

$gcloud app deploy

reference

https://stackoverflow.com/questions/59052104/how-do-you-deploy-a-streamlit-app-on-app-engine-gcp

Recommended Posts

How to deploy a Streamlit application to GCP (GAE)
How to deploy a Go application to an ECS instance
How to deploy a web application on Alibaba Cloud as a freelancer
How to automatically start a GCP preemptible VM
Deploy a web app created with Streamlit to Heroku
How to call a function
How to hack a terminal
How to deploy a web app made with Flask to Heroku
How to convert an array to a dictionary with Python [Application]
How to make a Japanese-English translation
How to put a symbolic link
Deploy a Django application with Docker
How to make a slack bot
How to create a Conda package
How to make a crawler --Advanced
How to make a recursive function
How to make a deadman's switch
How to create a Dockerfile (basic)
[Blender] How to make a Blender plugin
How to delete a Docker container
How to make a crawler --Basic
How to create a config file
Deploy Django + React from scratch to GKE (3) Create a GCP project
How to deploy a Django app on heroku in just 5 minutes
How to create a clone from Github
How to build a sphinx translation environment
How to create a git clone folder
Qiita (1) How to write a code name
How to draw a graph using Matplotlib
[Python] How to convert a 2D list to a 1D list
Java --Deploy Spring Boot project to GAE
[Colab] How to copy a huge dataset
How to install a package using a repository
[Ubuntu] How to execute a shell script
How to get a stacktrace in python
Creating a data analysis application using Streamlit
How to create a repository from media
How to make a Backtrader custom indicator
How to choose a Seaborn color palette
How to test on a Django-authenticated page
How to make a Pelican site map
How to run a Maya Python script
Go beginner tried to create a cloud native web application using Datastore / GAE
How to run a Django application on a Docker container (development and production environment)
How to calculate the volatility of a brand
How to write urlfetch unittest on GAE / P
How to read a CSV file with Python 2/3
How to disguise a ZIP file as a PNG file
How to use GCP trace with open Telemetry
A simple example of how to use ArgumentParser
How to share a virtual environment [About requirements.txt]
How to send a message to LINE with curl
How to create a Python virtual environment (venv)
How to code a drone using image recognition
How to open a web browser from python
How to clear tuples in a list (Python)
[Introduction to Udemy Python3 + Application] 23. How to use tuples
How to hold a competition at Coda Lab
How to draw a 2-axis graph with pyplot
How to embed a variable in a python string
How to create a function object from a string