Run Python Scripts Automatically with Google Cloud Run + Cloud Scheduler
Автор: Mackalyze: Data and Analytics Talk
Загружено: 2025-11-06
Просмотров: 36
Описание:
In this video, I’ll show how I moved my Python scripts to the cloud so they run automatically every day — no laptop needed. ☁️🐍
We’ll use:
Google Cloud Run to run the script
Cloud Scheduler to trigger it on a schedule
Docker to package everything 🐳
This is a useful setup if you work with data, automations, or just want your workflows to run reliably in the background.
What you’ll learn:
Preparing a Python script for serverless execution
Adding a Flask trigger to start the script
Building and deploying with Docker
Scheduling recurring jobs in Cloud Scheduler
If you want more content around analytics, automation, and working smarter — feel free to subscribe. 🙌
----------------------------------------------------------------------------------------------------
Flask trigger - add to bottom of python script:
from flask import Flask
import logging
app = Flask(__name__)
@app.route("/")
def run():
logging.info("Trigger received")
main()
return "Success", 200
if _name_ == "__main__":
app.run(host="0.0.0.0", port=8080)
Dockerfile content:
FROM python:3.11-slim
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8080
CMD ["python", "original_script_cloud.py"]
Command line :
gcloud auth login
gcloud config set project /your-project-id/
gcloud run deploy my-script-name --source . --region europe-west1 --allow-unauthenticated
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: