I am using VS Code with the Cloud Code extension to try to deploy a Python script to GCP Cloud Run. I am able to run the "hello, world" python flask app locally with the Cloud Run emulator and am also able to move it to deploy it to Cloud Run successfully, but the minute that I try to add any external libraries via the requirements.txt file and import in the app.py file, I get the following build failure error message:
Update failed with error code BUILD_DOCKER_UNKNOWN
app.py file:
"""
A sample Hello World server.
"""
import os
from flask import Flask, render_template
import pandas as pd
# pylint: disable=C0103
app = Flask(__name__)
@app.route('/')
def hello():
"""Return a friendly HTTP greeting."""
message = "It's running!"
"""Get Cloud Run environment variables."""
service = os.environ.get('K_SERVICE', 'Unknown service')
revision = os.environ.get('K_REVISION', 'Unknown revision')
return render_template('index.html',
message=message,
Service=service,
Revision=revision)
if __name__ == '__main__':
server_port = os.environ.get('PORT', '8080')
app.run(debug=False, port=server_port, host='0.0.0.0')
requirements.txt
Flask==2.2.2
requests==2.28.1
ptvsd==4.3.2 # Required for debugging.
pandas==1.5.0
Dockerfile:
# Python image to use.
FROM python:3.10-alpine
# Set the working directory to /app
WORKDIR /app
# copy the requirements file used for dependencies
COPY requirements.txt .
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Copy the rest of the working directory contents into the container at /app
COPY . .
# Run app.py when the container launches
ENTRYPOINT ["python", "app.py"]
Is that not how I'm supposed to add library dependencies? Please let me know what else I can provide to help troubleshoot this.