1

I am trying to deploy a web app developed using Streamlit on Google App Engine. When the deployment process is close to completion. I got the following error:

ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error! Code: APP_CONTAINER_CRASHED

  You can now view your Streamlit app in your browser.

  Network URL: http://172.17.0.6:8080
  External URL: http://34.67.15.189:8080

Killed

I am unable to understand the root cause of this error. Any suggestion and/or help would be highly appreciated.

EDIT:

I am using flexible environment. The app.yaml is as follows:

runtime: custom
env: flex

runtime_config:
  python_version: 3

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 5
  disk_size_gb: 25

Dockerfile is as follows:

FROM python:3.7

# Copy local code to the container image.
WORKDIR /app
COPY requirements.txt ./requirements.txt

# Install dependencies.
RUN pip3 install -r requirements.txt

EXPOSE 8080

COPY . /app

# Run the web service on container startup.
CMD streamlit run --server.port 8080 --server.enableCORS false app.py

And, the requirements are:

pandas==0.24.2
scikit_learn==0.23.1
streamlit==0.62.1
Dhanya
  • 15
  • 1
  • 1
  • 6
  • Is your application working locally? Share a [minimum reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of your application, app.yaml file and if you are using App Engine Flexible with Custom Runtime the Docker image you are using. – Daniel Ocando Jul 10 '20 at 19:04
  • @DanielOcando: Thank you for you quick response. I have edited the question with `app.yaml`, `Dockerfile` and `requirements.txt` . Could you please redirect me to any reference or document for checking it locally (using Dockerfile file)? – Dhanya Jul 10 '20 at 19:19
  • First of all, test the app locally and see if it's working accordingly. I understand that your application makes use of streamlit. So you should test if the [application itself works locally](https://docs.streamlit.io/en/stable/main_concepts.html). Afterwards you should [build the image locally](https://docs.docker.com/get-started/part2/#run-your-image-as-a-container) and [run `docker exec` on the running container](https://docs.docker.com/engine/reference/commandline/exec/#run-docker-exec-on-a-running-container) to check for logs and see if there are any issues. – Daniel Ocando Jul 10 '20 at 19:31
  • Notice that using streamlit will require your Dockerfile to have an additional configuration as explained [here](https://discuss.streamlit.io/t/how-to-use-streamlit-in-docker/1067). – Daniel Ocando Jul 10 '20 at 19:31
  • If the app works locally and then it works at the container level, then you can consider running `gcloud app deploy --verbosity=debug` to check additional issues during the deployment. – Daniel Ocando Jul 10 '20 at 19:33
  • @DanielOcando: I followed the suggestions: (1) application works locally - no issues here, (2) build the image locally - here, when I tried to view the web page (localhost:8000) - I got connection error after few minutes (Probably this is causing the container crash issue?), (3) run docker exec - worked; tested using echo function, (4) added the additional configuration for Streamlit. – Dhanya Jul 11 '20 at 05:01
  • One more thing I wanted to mention was - my web app uses a csv file (size close to 4.2 GB). I have placed the file in the same folder structure as shown in the answer below. Is it ok to place it there or do you have any suggestions? – Dhanya Jul 11 '20 at 05:03
  • I could see an App Engine deployment failing due to a big image size, because App Engine applications use Cloud Build under the hood and it has a default 10 minutes timeout. If your Docker image takes too much time to build I could see this happening. In order to increase the timeout use the gcloud command explained [here](https://stackoverflow.com/questions/50046545/google-app-engine-build-timed-out-during-deployment) (units are in seconds). – Daniel Ocando Jul 11 '20 at 09:00
  • I faced this issue at the beginning itself. I was able to fix that and later came to the issue I have posted in the question. When I checked the build locally and checked the web app on `localhost:8000`, I got connection timed out [ref](https://drive.google.com/file/d/1N8RzATIsbnU_YkXuLonI4xlVY8SSZqDA/view?usp=sharing).So, I was wondering whether there is way to avoid or increase the time for connection time out error. – Dhanya Jul 11 '20 at 14:56
  • If you get a connection error testing locally it will most likely translate on issues with App Engine. The connection timeout error seems pretty generic. Have you tried following one of this [troubleshooting steps](https://docs.streamlit.io/en/stable/troubleshooting/index.html#troubleshooting) as this is most likely a problem as to how streamlit is working at the container level. – Daniel Ocando Jul 12 '20 at 11:05

1 Answers1

2

I used the streamlit example app and your configuration files I noticed that you are defining runtime_config, this is not necessary since you choosed generic python docker image in your Dockerfile, this only applies for the App Engine's Python image.

For more information about Custom runtimes, please check this document

After some modifications on your files, all is running by using the example app, feel free to use these files as staring point.

this is my folder structure

./
├── app.py
├── app.yaml
├── Dockerfile
└── requirements.txt

this is my app.yaml

runtime: custom
env: flex

manual_scaling:
  instances: 1

resources:
  cpu: 4
  memory_gb: 5
  disk_size_gb: 25

this is my Dockerfile

FROM python:3.7

# Copy local code to the container image.
WORKDIR /app
COPY requirements.txt ./requirements.txt

# Install dependencies.
RUN pip3 install -r requirements.txt

EXPOSE 8080

COPY . /app

# Run the web service on container startup.
CMD streamlit run --server.port 8080 --server.enableCORS false /app/app.py

Jan Hernandez
  • 4,414
  • 2
  • 12
  • 18
  • Thank you :) My app has a csv file that needs to be accessed during the execution, which I have placed in the same folder. Is it alright? – Dhanya Jul 11 '20 at 01:08
  • @Dhanya if it is accessible by your python app, it is fine – Jan Hernandez Jul 12 '20 at 13:46
  • Is there a limitation on the size of the file for docker on Google App Engine. I was trying to recreate the same for another app. It consists of a file with a size of ~1GB. – Dhanya Feb 21 '21 at 16:49