{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Shawhin Talebi",
  "title_listed": "How to Deploy ML Solutions with FastAPI, Docker, and GCP",
  "keywords": "部署,FastAPI,Docker",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "部分免费/会员墙",
  "url": "https://towardsdatascience.com/how-to-deploy-ml-solutions-with-fastapi-docker-and-gcp-de1bb8bfc59a/",
  "publish_date": "2024-06",
  "corpus_stage": "预训练/SFT",
  "notes": "",
  "id": "09a450e09a69",
  "collected_at": "2026-10-01T22:42:11",
  "title": "How to Deploy ML Solutions with FastAPI, Docker, and GCP | Towards Data Science",
  "body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# How to Deploy ML Solutions with FastAPI, Docker, and GCP\nA hands-on guide with Python example code\n[Shaw Talebi](https://towardsdatascience.com/author/shawhin/)\nJune 5, 202410 min read\nThis is the 5th article in a [larger series](https://shawhin.medium.com/list/full-stack-data-science-f0910c75d006) on Full Stack Data Science. In this article, I walk through the deployment of an ML-based search API. While we could do this in countless ways, here I discuss a simple 3-step approach that can be applied to almost any machine learning solution. The example code is freely available on the [GitHub repository](https://github.com/ShawhinT/deploy-api-example).\n![Photo by Andy Hermawan on Unsplash](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/0TWS9ExWrdfZYVHk3-scaled.jpg)\nPhoto by [Andy Hermawan](https://unsplash.com/@kolamdigital?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\n* * *\nAlthough it may seem that machine learning is all about training fancy models, in the real world, **a model (by itself) does not generate value**. To turn an ML model into an ML solution (i.e., something valuable), we must \"deploy it.\"\nThis can take many different forms. For example, creating a web interface where users can interact with the model, integrating the model into an existing software system, or even simply setting up an API for developers to access the model (think of OpenAI and the like).\nThe **3-step strategy** I describe here is compatible with all of these examples. It consists of:\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\n  1. Creating an inference API (with FastAPI)\n  2. Containerizing the API (via Docker)\n  3. Running the container on a cloud platform (I use GCP here)\n\n\nPlease accept cookies to access this content\n## **FastAPI**\nThe first step of this deployment strategy is to wrap our model in an API (i.e. application programming interface). Put simply, **an** **API** **allows you to interact with an application programmatically**.\nOne way to do this first step is via FastAPI, a Python library that provides a super easy way to turn Python functions into API endpoints. The code below provides a concrete example.\n## **Docker**\nAlthough we could deploy our inference API directly to the cloud, it's often a good idea to first \"containerize\" it. This is where Docker comes in.\n**Docker** allows you to create a **lightweight wrapper that captures all our API's dependencies** , making it (much) easier to spin up on new machines.\nIt works via a 2-step process. **First** , we create a Docker image. This is essentially a recipe that tells a system how to spin up the API from scratch (don't worry, it's super easy to make). **Second** , we can run the image on any system with Docker installed. The running image is called a container, which is like a little virtual machine sitting on the larger system.\n## **Google Cloud Run**\nFinally, we need computing resources to run our Docker image. Of course, one could do this on a laptop (probably not a good idea), via an on-premise server or a cloud provider.\nHere, I use **Google Cloud Run** , a GCP **service specifically for running Docker containers**. It also has a free tier, so you can deploy projects without incurring unnecessary costs.\n## **Example Code: Deploying Semantic Search API**\nNow that we have a basic understanding of key concepts let's see what this process looks like in code. The example below builds on previous articles in this series, which pulled titles and transcripts from all my YouTube videos and turned them into [text embeddings](https://towardsdatascience.com/text-embeddings-classification-and-semantic-search-8291746220be).\nBriefly, **text embeddings** are **semantically meaningful numerical representations of text** that enable a new kind of search (often called [semantic search](https://towardsdatascience.com/text-embeddings-classification-and-semantic-search-8291746220be#185f)).\nHere, we'll build and deploy an API for a semantic search system over all my YouTube videos. This API is the backend for a live [search application](https://huggingface.co/spaces/shawhin/yt-search-ui) running on Hugging Face spaces.\nThe code repos for both the [backend](https://github.com/ShawhinT/deploy-api-example) and [frontend](https://huggingface.co/spaces/shawhin/yt-search-ui/tree/main) of this app are freely available.\n* * *\n### **Step 1: Create API**\nFastAPI makes it super easy to take an existing Python script and turn it into an API with a few additional lines of code. Here's what that looks like.\nWe'll first import some handy libraries.\npython\n\n```\nfrom fastapi import FastAPI\nimport polars as pl\nfrom sentence_transformers import SentenceTransformer\nfrom sklearn.metrics import DistanceMetric\nimport numpy as np\nfrom app.functions import returnSearchResultIndexes\n```\n\nNext, we'll define the building blocks of our semantic search function. Namely, the text embedding model, the title and transcript embeddings of the videos we want to search over, and a distance metric to evaluate which videos are most relevant to a user query. If you want a deeper dive into semantic search, I discussed it in a [past article](https://towardsdatascience.com/text-embeddings-classification-and-semantic-search-8291746220be#185f).\npython\n\n```\n# define model info\nmodel_name = 'all-MiniLM-L6-v2'\n\n# load model\nmodel = SentenceTransformer(model_name)\n\n# load video index\ndf = pl.scan_parquet('app/data/video-index.parquet')\n\n# create distance metric object\ndist_name = 'manhattan'\ndist = DistanceMetric.get_metric(dist_name)\n```\n\nNow, we define our API operations. Here, we will create 3 GET requests. The first one is shown in the code block below.\npython\n\n```\n# create FastAPI object\napp = FastAPI()\n\n# API operations\n@app.get(\"/\")\ndef health_check():\n    return {'health_check': 'OK'}\n```\n\nIn the block above, we initialize a new FastAPI application using the _FastAPI()_ class and then create a \"health check\" endpoint.\nTo do this, we define a Python function that takes in no inputs but returns a dictionary with the key \"health_check\" and a value of \"OK.\" To turn this function into an API endpoint, we simply add a decorator to it and specify the path of our endpoint. Here, we use the root, i.e., \"/\".\nLet's see another example. Here, we'll have an endpoint called _info_ that returns more information about the API.\npython\n\n```\n@app.get(\"/info\")\ndef info():\n    return {'name': 'yt-search', 'description': \"Search API for Shaw Talebi's YouTube videos.\"}\n```\n\nWe can see that this endpoint is very similar to the health check. This one, however, lives at the \"/info\" endpoint.\nFinally, let's make the search endpoint, which, given a user query, will return the titles and IDs of the most relevant videos.\npython\n\n```\n@app.get(\"/search\")\ndef search(query: str):\n    idx_result = returnSearchResultIndexes(query, df, model, dist)\n    return df.select(['title', 'video_id']).collect()[idx_result].to_dict(as_series=False)\n```\n\nFor this endpoint, we require an input: the user's query. This then gets passed to another Python function defined in another script that does all the math behind the search. While I won't get into the details here, the curious reader can see the code on [GitHub](https://github.com/ShawhinT/deploy-api-example/tree/main/app) or the code walkthrough of the search function on [YouTube](https://youtu.be/6qCrvlHRhcM).\nSince this function only returns the row numbers of the search results in the _df_ dataframe, we need to use this output to grab the titles and video IDs we care about and then return them as a Python dictionary. It's important that **all the outputs of our API endpoints be dictionaries** because they adhere to the standard JSON format for APIs.\nNotice that the code blocks above referenced two external files: _app/functions.py_ and _app/data/video-index.parquet_ , which implies the following directory structure.\n![The directory structure of FastAPI API. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1cv8DI4NrM4c4pj98D53E5Q-1.png)\nThe directory structure of FastAPI API. Image by author.\nTo run this API locally, we can navigate to the root directory and run the following command.\nbash\n\n```\nuvicorn app.main:app --host 0.0.0.0 --port 8080\n```\n\n**uvicorn** is a **Python library that lets us run web applications** like the one we created using FastAPI. This command will run the API locally at <http://0.0.0.0:8080>. The reason we used this host and port will be apparent later when we deploy on Google Cloud Run.\n### **Step 2: Create Docker Image**\nYay, our API runs locally! Let's take the next step toward running it in the cloud.\nWe do this by creating a Docker image for our API. This will require us to make 3 additional files: _Dockerfile_ , _requirements.txt_ , and _app/__**init**_ _.py_. Here's what our directory should look like.\n![The directory structure for Docker image creation. Image by author \\(no pun intended\\).](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/10XGe0wRjGiz3y8w1Esavyg-1.png)\nThe directory structure for Docker image creation. Image by author (no pun intended).\nThe _Dockerfile_ contains the step by step instructions for running our Docker image. _requirements.txt_ specifies the Python libraries (with versions) needed to run our API. Finally, _app/__**init**_ _.py_ marks the _app_ folder as a Python package, ensuring that Python can find and properly import our API code when running in the container.\nHere's what the inside of the _Dockerfile_ looks like.\nbash\n\n```\n# start from python base image\nFROM python:3.10-slim\n\n# change working directory\nWORKDIR /code\n\n# add requirements file to image\nCOPY ./requirements.txt /code/requirements.txt\n\n# install python libraries\nRUN pip install --no-cache-dir --upgrade -r /code/requirements.txt\n\n# add python code\nCOPY ./app/ /code/app/\n\n# specify default commands\nCMD [\"uvicorn\", \"app.main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"8080\"]\n```\n\nThe first line bootstraps our image on top of an existing image that has Python 3.10 installed. Next, we change our working directory from the _root_ to _/code_.\nWe then copy the _requirements.txt_ file from our codebase to the Docker image. With this in place, we can install our requirements using pip.\nNext, we copy over all the code for our API.\n_Note: we copied and installed the Python packages before everything else because this allows us to cache the installation of the requirements. This is helpful because it avoids waiting a few minutes for the dependencies to install when running our Docker image rapidly during development._\nFinally, we specify the default command which is the same thing we ran locally to run our API.\n### **Step 3: Deploy to Google Cloud**\nAt this point, we can build our Docker image and push it to the [Docker Hub](https://hub.docker.com/), which we can readily deploy to many different cloud services. However, I'll follow an alternative strategy here.\nInstead, I will push all our code to GitHub, from which we can directly deploy the container to Google Cloud Run. This has two key benefits.\n**First** , it avoids resolving system architecture discrepancies between your local system and what Google Cloud Run uses (this was specifically an issue for me because Mac runs on ARM64). **Second** , deploying from a GitHub repo allows for continuous deployment, so if we want to update our API, we can simply push new code to our repo, and a new container will be spun up automatically.\nWe start by creating a new GitHub repo.\n![Creating GitHub repo. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1Nim7uiSqqEKuntKA-7GFCg-1.png)\nCreating GitHub repo. Image by author.\nThen, we clone the repo, add our code, and push it back to GitHub. Here's what the directory structure looks like after adding the code.\n![GitHub repo directory structure. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1kAkEejCVSKC_6ogx-2Sfbw-1.png)\nGitHub repo directory structure. Image by author.\nWith the code in place, we can create a new Google Cloud Platform project. We do this by going to the [GCP console](https://console.cloud.google.com/welcome), clicking on our project lists, and selecting \"NEW PROJECT\".\n![Creating a new GCP project. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1xUteNNVFTNIHl5NDrTCETw-1.png)\nCreating a new GCP project. Image by author.\nOnce our project has been created, we can open it and type \"cloud run\" into the search bar.\n![Searching for Cloud Run service. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/12CgtMtkpZhFwKrrWS_VSgA-1.png)\nSearching for Cloud Run service. Image by author.\nWhen that opens, we will click \"CREATE SERVICE\". This will open up a page for us to configure our service.\nFirst, we select the option to deploy our service from GitHub. Then click \"SET UP WITH CLOUD BUILD\".\n![Setting up continuous deployment of Cloud Run service from GitHub. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1pOm88bk59oUb6OACAHLo7w-1.png)\nSetting up continuous deployment of Cloud Run service from GitHub. Image by author.\nFor the repository source, we will select GitHub and choose the repo we just made.\n![Choosing our repository source. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1sRLFoNraHFDVy0fbTRguDA-1.png)\nChoosing our repository source. Image by author.\nWe will leave the branch as _^main$_ and select the \"Build Type\" as Dockerfile.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1nsSsPkFGRhPYtCW8gQgTYg-1.png)\nNext, we return to the service configuration screen. We can name the service whatever we like (I leave it as the automatically generated one). For the region, I leave it as _us-central1_ because it's a Tier 1, which offers the cheapest computing options (basically free for this example).\nTo keep things simple, I'll \"Allow unauthenticated invocations\". Of course, **you will want to require authentication for most systems.** Then, leave everything else as the default.\n![Configuring service. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1_2t1_SNGSMEgy-o4qFxG3g-1.png)\nConfiguring service. Image by author.\nFinally, under \"_Container(s), Volumes, Networking, Security_ \", edit the container to have 1 GiB of memory. We must leave the PORT as 8080 because that's what we configured in our Dockerfile.\n![Editing container. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1htsRKAHpKYwTozwULp8LAg-1.png)\nEditing container. Image by author.\nWe can leave everything else as default and hit \"CREATE\" at the bottom of the screen. After a few minutes, the container will be live!\n![Service running on Cloud Run. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/14sBCt4Isswk0I_nGNkg9wA-1.png)\nService running on Cloud Run. Image by author.\nWe can then access the API using the URL specified near the top of the page. Clicking the link will open up the root endpoint, which was our health check.\n![Health check endpoint. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/158ciDKJjHK-VLVyvTOPahg-1.png)\nHealth check endpoint. Image by author.\nWe can manually run a GET request to the search API using the following URL: _[your-app-url-here]/search?query=LLMs_. This will search for videos relevant to LLMs.\n![Making GET request to search API endpoint. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1amPwDSQ__bf8D2sGrurxUg-1.png)\nMaking GET request to search API endpoint. Image by author.\n### **Bonus: integrating into UI**\nOnce our API backend is set up, we can connect it to a user-friendly interface. I do that via **Hugging Face Spaces** , which **hosts ML apps completely for free**.\nHere's what that same search looks like through a UI. You can play around with the UI [[here](https://huggingface.co/spaces/shawhin/yt-search-ui/tree/main)](https://huggingface.co/spaces/shawhin/yt-search-ui) and see the code here.\n![Search UI on HF Spaces. Gif by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1St0OCAxBpqORc95WDpq4Pg-1.gif)\nSearch UI on HF Spaces. Gif by author.\n## **Conclusion**\nData science is more than just training fancy models. It's about solving problems and generating value. Often, this requires us to deploy models into settings where they can make the most impact. Here, we walked through a simple 3-step strategy for deploying ML models using FastAPI, Docker, and GCP.\nWhile this concludes the [Full Stack Data Science](https://shawhin.medium.com/list/full-stack-data-science-f0910c75d006) series, these articles are accompanied by a [YouTube playlist](https://youtube.com/playlist?list=PLz-ep5RbHosWmAt-AMK0MBgh3GeSvbCmL&si=q0G3YUXwiSpyqgQS) with a [bonus video](https://youtu.be/6qCrvlHRhcM) on the experimentation involved in creating this search tool.\nMore on Full Stack Data Science 👇\n> [**Full Stack Data Science**](https://shawhin.medium.com/list/f0910c75d006)\n* * *\n## Resources\n**Connect** : [My website](https://shawhintalebi.com/) | [Book a call](https://calendly.com/shawhintalebi)\n**Socials** : [YouTube 🎥 ](https://www.youtube.com/channel/UCa9gErQ9AE5jT2DZLjXBIdA) | [LinkedIn](https://www.linkedin.com/in/shawhintalebi/) | [Twitter](https://twitter.com/ShawhinT)\n**Support** : [Buy me a coffee](https://www.buymeacoffee.com/shawhint) ☕️\n> [**Get FREE access to every new story I write**](https://shawhin.medium.com/subscribe)\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657074748_utev3i.jpeg)\nWritten By\n## [Shaw Talebi](https://towardsdatascience.com/author/shawhin/)\n[See all from Shaw Talebi](https://towardsdatascience.com/author/shawhin/)\n[Data Science](https://towardsdatascience.com/tag/data-science/)[Docker](https://towardsdatascience.com/tag/docker/)[Fastapi](https://towardsdatascience.com/tag/fastapi/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[ML Engineering](https://towardsdatascience.com/tag/ml-engineering/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fhow-to-deploy-ml-solutions-with-fastapi-docker-and-gcp-de1bb8bfc59a%2F&title=How%20to%20Deploy%20ML%20Solutions%20with%20FastAPI%2C%20Docker%2C%20and%20GCP)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fhow-to-deploy-ml-solutions-with-fastapi-docker-and-gcp-de1bb8bfc59a%2F&title=How%20to%20Deploy%20ML%20Solutions%20with%20FastAPI%2C%20Docker%2C%20and%20GCP)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fhow-to-deploy-ml-solutions-with-fastapi-docker-and-gcp-de1bb8bfc59a%2F&text=How%20to%20Deploy%20ML%20Solutions%20with%20FastAPI%2C%20Docker%2C%20and%20GCP)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/1d5lA6-gZmGfEuDf0r6_0Sg-scaled.jpeg)](https://towardsdatascience.com/did-facebook-prophet-make-time-series-modeling-too-easy-7d22a2bbf5dd/)\n## [Did Facebook Prophet Make Time Series Modeling Too Easy?](https://towardsdatascience.com/did-facebook-prophet-make-time-series-modeling-too-easy-7d22a2bbf5dd/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nA Capstone Project Dilemma\n[Jessica Forrest-Baldini](https://towardsdatascience.com/author/jessicaforrestbaldini/)\nNovember 4, 20203 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/08/0VEnLOPlvfa7QZoDn-scaled.jpg)](https://towardsdatascience.com/your-answer-to-these-5-questions-will-highlight-areas-to-invest-in-as-an-aspiring-data-scientist-ff5bc74afc56/)\n## [Your Answer to These 5 Questions Will Highlight Areas to Invest in as an Aspiring Data Scientist](https://towardsdatascience.com/your-answer-to-these-5-questions-will-highlight-areas-to-invest-in-as-an-aspiring-data-scientist-ff5bc74afc56/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUnderstanding where to invest your time is the first step to becoming a better data scientist\n[Madison Hunter](https://towardsdatascience.com/author/madison13/)\nAugust 24, 202213 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/0v_kP1Z9oVaTea8pV-scaled.jpg)](https://towardsdatascience.com/women-in-data-science-wids-datathon-on-kaggle-a3cda3085a7a/)\n## [Women in Data Science (WiDS) Datathon on Kaggle](https://towardsdatascience.com/women-in-data-science-wids-datathon-on-kaggle-a3cda3085a7a/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nMy experience of participation in WiDS and the promising attempt to predict diabetes.\n[Anna Pastushko](https://towardsdatascience.com/author/annpastushko/)\nFebruary 26, 20216 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/04/0MOV3rHUnikN7fMo7-scaled.jpg)](https://towardsdatascience.com/top-5-apps-for-data-scientists-dc8b66886560/)\n## [Top 5 apps for Data Scientists](https://towardsdatascience.com/top-5-apps-for-data-scientists-dc8b66886560/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nHow do I stay up to date with the latest research? How do I remember complex concepts from the field? With the help of these 5 free apps!\n[Roman Orac](https://towardsdatascience.com/author/romanorac/)\nApril 13, 20204 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/1Na41VawWc3fo2gwA7HsEsw-scaled.jpeg)](https://towardsdatascience.com/how-to-write-better-data-science-articles-in-2021-a34210badb37/)\n## [How to Write Better Data Science Articles in 2021](https://towardsdatascience.com/how-to-write-better-data-science-articles-in-2021-a34210badb37/)\n[Programming](https://towardsdatascience.com/category/programming/)\nNew year, same you, better articles.\n[Madison Hunter](https://towardsdatascience.com/author/madison13/)\nJanuary 3, 20219 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/03/18pnu_-fFu3Wi12SN3RC7MA-scaled.jpeg)](https://towardsdatascience.com/you-should-probably-know-this-about-tree-based-feature-importances-7afc450726f5/)\n## [5 Facts they don't tell you about random forest feature importances](https://towardsdatascience.com/you-should-probably-know-this-about-tree-based-feature-importances-7afc450726f5/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\n5 Key facts to know before interpreting tree-based feature importances\n[Ali S](https://towardsdatascience.com/author/ali.soleymani.co/)\nMarch 17, 20224 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/09/0laeHRDxTJv9bS_gN-scaled.jpg)](https://towardsdatascience.com/predict-time-stamped-sales-in-python-1914292461ad/)\n## [Predict Time-Stamped Sales in Python](https://towardsdatascience.com/predict-time-stamped-sales-in-python-1914292461ad/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nObjective: To predict forthcoming monthly sales using Autoregressive Models (ARIMA) in Python.\n[Sree](https://towardsdatascience.com/author/srees1988/)\nSeptember 27, 202022 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/08/1OVO2q580GWA7d83FQLrbqw.png)](https://towardsdatascience.com/how-ai-could-fuel-global-warming-8f6e1dda6711/)\n## [How AI could fuel global warming](https://towardsdatascience.com/how-ai-could-fuel-global-warming-8f6e1dda6711/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nNew large models are energy intensive. How much CO2 is needed for their training?\n[Salvatore Raieli](https://towardsdatascience.com/author/salvatore-raieli/)\nAugust 11, 20227 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1oJRql0rQoP5tdJs_vdYPww.jpeg)](https://towardsdatascience.com/a-minimal-guide-to-understanding-and-creating-python-virtual-environments-38ba3eac1bc7/)\n## [A Minimal Guide to Understanding and Creating Python Virtual Environments](https://towardsdatascience.com/a-minimal-guide-to-understanding-and-creating-python-virtual-environments-38ba3eac1bc7/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nMost serious data science projects should take place in a Docker container or a virtual environment. Whether for testing or dependency...\n[Brayton Hall](https://towardsdatascience.com/author/braytonhall/)\nAugust 28, 20205 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607631/image?etag=1781543525510&width=500&height=500) Critical Mistakes Companies Make When Integrating AI/ML into Their Processes ](https://towardsdatascience.com/critical-mistakes-companies-make-when-integrating-ai-ml-into-their-processes/ \"Critical Mistakes Companies Make When Integrating AI/ML into Their Processes\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n\n\n",
  "metadata": {
    "title": "How to Deploy ML Solutions with FastAPI, Docker, and GCP | Towards Data Science",
    "description": "A hands-on guide with Python example code",
    "keywords": null,
    "author": "Shaw Talebi",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "How to Deploy ML Solutions with FastAPI, Docker, and GCP",
    "og:description": "A hands-on guide with Python example code",
    "og:url": "https://towardsdatascience.com/how-to-deploy-ml-solutions-with-fastapi-docker-and-gcp-de1bb8bfc59a/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/0TWS9ExWrdfZYVHk3-scaled.jpg",
    "og:image:width": "2560",
    "og:image:height": "1440",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Shaw Talebi",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "10 min read",
    "article:published_time": "2024-06-05T05:34:48.000Z",
    "article:modified_time": "2024-06-05T05:34:48.000Z",
    "article:author": "https://towardsdatascience.com/author/shawhin/"
  },
  "paywall": {
    "listed_paid": true,
    "detected": false,
    "marker": "",
    "public_only": true,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/09a450e09a69/code/block_000.txt",
      "chars": 216
    },
    {
      "language": "txt",
      "file": "attachments/09a450e09a69/code/block_001.txt",
      "chars": 280
    },
    {
      "language": "txt",
      "file": "attachments/09a450e09a69/code/block_002.txt",
      "chars": 126
    },
    {
      "language": "txt",
      "file": "attachments/09a450e09a69/code/block_003.txt",
      "chars": 126
    },
    {
      "language": "txt",
      "file": "attachments/09a450e09a69/code/block_004.txt",
      "chars": 202
    },
    {
      "language": "txt",
      "file": "attachments/09a450e09a69/code/block_005.txt",
      "chars": 48
    },
    {
      "language": "txt",
      "file": "attachments/09a450e09a69/code/block_006.txt",
      "chars": 412
    }
  ],
  "images": [
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/0TWS9ExWrdfZYVHk3-scaled.jpg",
      "alt": "Photo by Andy Hermawan on Unsplash",
      "local_path": "attachments/09a450e09a69/images/000.jpg",
      "bytes": 96059,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1cv8DI4NrM4c4pj98D53E5Q-1.png",
      "alt": "The directory structure of FastAPI API. Image by author.",
      "local_path": "attachments/09a450e09a69/images/001.png",
      "bytes": 4103,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/10XGe0wRjGiz3y8w1Esavyg-1.png",
      "alt": "The directory structure for Docker image creation. Image by author (no pun intended).",
      "local_path": "attachments/09a450e09a69/images/002.png",
      "bytes": 6511,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1Nim7uiSqqEKuntKA-7GFCg-1.png",
      "alt": "Creating GitHub repo. Image by author.",
      "local_path": "attachments/09a450e09a69/images/003.png",
      "bytes": 86371,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1kAkEejCVSKC_6ogx-2Sfbw-1.png",
      "alt": "GitHub repo directory structure. Image by author.",
      "local_path": "attachments/09a450e09a69/images/004.png",
      "bytes": 9795,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1xUteNNVFTNIHl5NDrTCETw-1.png",
      "alt": "Creating a new GCP project. Image by author.",
      "local_path": "attachments/09a450e09a69/images/005.png",
      "bytes": 37220,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/12CgtMtkpZhFwKrrWS_VSgA-1.png",
      "alt": "Searching for Cloud Run service. Image by author.",
      "local_path": "attachments/09a450e09a69/images/006.png",
      "bytes": 13343,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1pOm88bk59oUb6OACAHLo7w-1.png",
      "alt": "Setting up continuous deployment of Cloud Run service from GitHub. Image by author.",
      "local_path": "attachments/09a450e09a69/images/007.png",
      "bytes": 27716,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1sRLFoNraHFDVy0fbTRguDA-1.png",
      "alt": "Choosing our repository source. Image by author.",
      "local_path": "attachments/09a450e09a69/images/008.png",
      "bytes": 46467,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1_2t1_SNGSMEgy-o4qFxG3g-1.png",
      "alt": "Configuring service. Image by author.",
      "local_path": "attachments/09a450e09a69/images/009.png",
      "bytes": 55632,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1htsRKAHpKYwTozwULp8LAg-1.png",
      "alt": "Editing container. Image by author.",
      "local_path": "attachments/09a450e09a69/images/010.png",
      "bytes": 45451,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/14sBCt4Isswk0I_nGNkg9wA-1.png",
      "alt": "Service running on Cloud Run. Image by author.",
      "local_path": "attachments/09a450e09a69/images/011.png",
      "bytes": 128730,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/158ciDKJjHK-VLVyvTOPahg-1.png",
      "alt": "Health check endpoint. Image by author.",
      "local_path": "attachments/09a450e09a69/images/012.png",
      "bytes": 3802,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/1d5lA6-gZmGfEuDf0r6_0Sg-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/013.jpeg",
      "bytes": 264520,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/08/0VEnLOPlvfa7QZoDn-scaled.jpg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/014.jpg",
      "bytes": 755506,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/0v_kP1Z9oVaTea8pV-scaled.jpg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/015.jpg",
      "bytes": 577327,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/04/0MOV3rHUnikN7fMo7-scaled.jpg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/016.jpg",
      "bytes": 482606,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/1Na41VawWc3fo2gwA7HsEsw-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/017.jpeg",
      "bytes": 467776,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/03/18pnu_-fFu3Wi12SN3RC7MA-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/018.jpeg",
      "bytes": 112335,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/09/0laeHRDxTJv9bS_gN-scaled.jpg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/019.jpg",
      "bytes": 341401,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/08/1OVO2q580GWA7d83FQLrbqw.png",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/020.png",
      "bytes": 1459313,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1oJRql0rQoP5tdJs_vdYPww.jpeg",
      "alt": "",
      "local_path": "attachments/09a450e09a69/images/021.jpeg",
      "bytes": 88899,
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [
    {
      "src": "https://youtu.be/6qCrvlHRhcM",
      "quality": "unavailable",
      "local_path": "",
      "note": "无1080p且无720p，未交付更低清晰度"
    },
    {
      "src": "https://youtube.com/playlist?list=PLz-ep5RbHosWmAt-AMK0MBgh3GeSvbCmL&si=q0G3YUXwiSpyqgQS",
      "quality": "unavailable",
      "local_path": "",
      "note": "无1080p且无720p，未交付更低清晰度"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/shawhin/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/text-embeddings-classification-and-semantic-search-8291746220be"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/docker/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/fastapi/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/ml-engineering/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/did-facebook-prophet-make-time-series-modeling-too-easy-7d22a2bbf5dd/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/jessicaforrestbaldini/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/your-answer-to-these-5-questions-will-highlight-areas-to-invest-in-as-an-aspiring-data-scientist-ff5bc74afc56/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/madison13/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/women-in-data-science-wids-datathon-on-kaggle-a3cda3085a7a/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://shawhin.medium.com/list/full-stack-data-science-f0910c75d006"
    },
    {
      "type": "external",
      "href": "https://github.com/ShawhinT/deploy-api-example"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/@kolamdigital"
    },
    {
      "type": "external",
      "href": "https://unsplash.com"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/spaces/shawhin/yt-search-ui"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/spaces/shawhin/yt-search-ui/tree/main"
    },
    {
      "type": "external",
      "href": "https://github.com/ShawhinT/deploy-api-example/tree/main/app"
    },
    {
      "type": "external",
      "href": "https://youtu.be/6qCrvlHRhcM"
    },
    {
      "type": "external",
      "href": "http://0.0.0.0:8080"
    },
    {
      "type": "external",
      "href": "https://hub.docker.com/"
    },
    {
      "type": "external",
      "href": "https://console.cloud.google.com/welcome"
    },
    {
      "type": "external",
      "href": "https://youtube.com/playlist?list=PLz-ep5RbHosWmAt-AMK0MBgh3GeSvbCmL&si=q0G3YUXwiSpyqgQS"
    },
    {
      "type": "external",
      "href": "https://shawhin.medium.com/list/f0910c75d006"
    },
    {
      "type": "external",
      "href": "https://shawhintalebi.com/"
    },
    {
      "type": "external",
      "href": "https://calendly.com/shawhintalebi"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:11:49Z",
  "source_url": "https://towardsdatascience.com/how-to-deploy-ml-solutions-with-fastapi-docker-and-gcp-de1bb8bfc59a/",
  "delivery_status": "excluded_paid",
  "discovery_status": "excluded_paid",
  "missing_reason": "按原约定排除付费/会员全文"
}