0Pricing
MLOps Academy · Ders

Bir Model API'si için Dockerfile Yazın

FastAPI hizmetini adım adım kapsayıcılaştırın.

Bir Model API'si için Dockerfile Yazın, CoddyKit'te ücretsiz bir MLOps Academy dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, MLOps Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. MLOps Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Why a Dockerfile

Your model API runs on your laptop but breaks elsewhere. A Dockerfile is a recipe that builds the exact same environment everywhere.

Pick a Base Image

Every Dockerfile starts FROM a base image. A slim Python image gives you the interpreter without a bloated operating system.

FROM python:3.11-slim

Set a Working Directory

The WORKDIR instruction picks the folder your commands run in. It is created if missing, so later paths stay clean and predictable.

WORKDIR /app

Copy Requirements First

Copy requirements.txt alone before your code. Docker caches this layer, so installs are skipped when only your app changes.

COPY requirements.txt .

Install Dependencies

Run pip install inside the image. The --no-cache-dir flag skips the pip cache and keeps the final image a little smaller.

RUN pip install --no-cache-dir -r requirements.txt

Copy Your Code

Now COPY the rest of your project in. Doing this after the install means code edits do not bust the dependency cache layer.

COPY . .

Document the Port

The EXPOSE instruction declares which port your API listens on. It is documentation for humans and tools, not an actual open.

EXPOSE 8000

Define the Start Command

The CMD sets what runs when the container starts. Here it launches Uvicorn to serve your FastAPI model app.

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]

Bind to All Interfaces

Inside a container you must serve on 0.0.0.0, not 127.0.0.1. Otherwise the host cannot reach your model through the mapped port.

Build the Image

Turn the recipe into an image with docker build. The -t flag tags it with a name you can run and push later.

docker build -t model-api .

Layers Are Cached

Each instruction becomes a cached layer. Order them from least to most frequently changed so rebuilds stay fast.

Quick Check

Let us check the most cache-friendly build order.

Recap

You wrote a Dockerfile: base image, workdir, cached install, copy, expose, and a start command. Your model API now builds the same anywhere. 🐳

Sıkça Sorulan Sorular

“Bir Model API'si için Dockerfile Yazın” dersi ücretsiz mi?

Evet — “Bir Model API'si için Dockerfile Yazın” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve MLOps Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. MLOps Academy kursu toplamda 4 dersten oluşur.

“Bir Model API'si için Dockerfile Yazın” dersinde ne öğreneceğim?

FastAPI hizmetini adım adım kapsayıcılaştırın. MLOps Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

MLOps Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te MLOps Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.

“Bir Model API'si için Dockerfile Yazın” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu MLOps Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her MLOps Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Bir Model API'si için Dockerfile Yazın
  2. Çok Aşamalı Derlemelerle İmajları Küçültün
  3. Yapılandırmayı Ortam Değişkenleriyle Aktarın
  4. Kapsayıcıyı Yerel Olarak Çalıştırın ve Test Edin
← MLOps Academy Sayfasına Dön