Deployment fails on Cloud Run

Hi.

I’m using Google Cloud Run to deploy a Streamlit application.
Cloud Build fails to deploy even though Docker is running successfully in local env.

I looked at the build log and found the following message.

ERROR: (gcloud.run.deploy) Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.

I tried to do my own trial and error, but I couldn’t solve the problem.
If you know of a solution or an example repository please help me.

The current code for my application is shown below.

# .streamlit/config.toml
[browser]
serverAddress = "0.0.0.0"

[server]
enableCORS = false
headless = true
# Dockerfile
FROM python:3.8 as builder

WORKDIR /app

COPY . .

RUN pip install poetry
RUN poetry install --no-dev

CMD ["make", "run"]
# Makefile
PORT ?= 8080

run:
	poetry run streamlit run --server.port ${PORT} main.py
# main.py
import streamlit as st


def main():
    st.balloons()


if __name__ == "__main__":
    main()

Thanks.

I solved thid issue myself.
I always thought it was a Streamlit or Docker issue, but Poetry was the cause of the error.

Added RUN poetry config virtualenvs.create false && poetry install --no-dev

1 Like

Glad you found out :slight_smile: and thanks for sharing the solution !