So, I wanted to try GCloud since you can deploy serverless stuff pretty easily. I've made a simple Flask app to test it out, this is the entire code for the app:
from flask import (
Flask
)
from flask_cors import CORS
app = Flask(__name__)
cors = CORS(app)
@app.route('/ping', methods=['GET'])
def ping():
return 'It works!', 200
def create_app():
return app
if __name__ == '__main__':
app.run()
Here is the Dockerfile:
FROM python:3.7-slim
COPY . ./home/gcloud-test
WORKDIR /home/gcloud-test
RUN pip install -r requirements.txt
EXPOSE 5000
CMD python3 main.py
I've also tried using gunicorn and waitress to start the server, the same thing happens.
Commands I run to deploy to gcloud:
gcloud builds submit --tag gcr.io/PROJECT_ID/PROJECT_NAME
gcloud run deploy --image gcr.io/PROJECT_ID/PROJECT_NAME --platform managed --verbosity=debug
Here is the stack trace from the console:
Deploying container to Cloud Run service [PROJECT_NAME] in project [PROJECT_ID] region [europe-west1]
Deploying...
Creating Revision... 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....failed
Deployment failed
DEBUG: (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.
Traceback (most recent call last):
resources = calliope_command.Run(cli=self, args=args)
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 808, in Run
resources = command_instance.Run(args)
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\surface\run\deploy.py", line 219, in Run
build_log_url=build_log_url)
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\run\serverless_operations.py", line 1087, in ReleaseService
self.WaitForCondition(poller)
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\run\serverless_operations.py", line 594, in WaitForCondition
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\util\waiter.py", line 326, in PollUntilDone
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\core\util\retry.py", line 219, in RetryOnResult
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\run\serverless_operations.py", line 251, in Poll
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\run\serverless_operations.py", line 230, in _PollTerminalSubconditions
self._PossiblyFailStage(condition, message)
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\run\serverless_operations.py", line 349, in _PossiblyFailStage
message)
File "C:\Users\aleks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\core\console\progress_tracker.py", line 915, in FailStage
raise failure_exception # pylint: disable=raising-bad-type
googlecloudsdk.command_lib.run.exceptions.DeploymentFailedError: 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.
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.
When I go to see the logs online, I'm seeing that the app has been started, and a couple of minutes later health check fails, screenshot attached:

Any kind of help would be appreciated.