0Pricing
Supabase Backend as a Service · Ders

Ortam Yönetimi ve CI/CD

Farklı ortamları (geliştirme, hazırlık, üretim) yönetmeyi ve Supabase’i sürekli tümleştirme/sürekli dağıtım işlem hatlarınıza entegre etmeyi öğrenin

Ortam Yönetimi ve CI/CD, CoddyKit'te ücretsiz bir Supabase Backend as a Service 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, Supabase Backend as a Service öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Supabase Backend as a Service kursu toplamda 4 dersten oluşur.

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

Why Multiple Environments?

When building applications, it's crucial to manage different stages of development. These stages are called environments.

Typically, you'll work with three main environments:

  • Development (Dev): Where developers write and test new features.
  • Staging: A pre-production environment for testing by QA or stakeholders.
  • Production (Prod): The live application used by your end-users.

Each environment helps isolate changes and prevent issues in the live app.

Supabase & Your Environments

For effective environment management, it's best practice to have separate Supabase projects for each major environment.

This means you'd have:

  • One Supabase project for your development database, auth, storage.
  • Another Supabase project for staging.
  • A final, distinct Supabase project for production.

This isolation prevents accidental data loss or breaking changes from affecting your live application.

Managing Configuration

Each environment often requires different configurations, such as database connection strings, API keys, or external service URLs.

These sensitive details should never be hardcoded directly into your application's source code.

Instead, we use environment variables. These variables are loaded at runtime and provide the necessary configuration specific to the environment your application is running in.

Local Dev Setup with .env

During local development, you'll often use a .env file to manage your environment variables. This file stores key-value pairs specific to your local setup.

Tools like the Supabase client libraries can automatically load these variables, making it easy to switch between local and deployed environments.

Remember to add .env to your .gitignore to prevent accidentally committing sensitive information!

SUPABASE_URL="http://localhost:54321"
SUPABASE_ANON_KEY="YOUR_LOCAL_ANON_KEY"
DATABASE_URL="postgresql://postgres:password@localhost:54322/db"

Introduction to CI/CD

CI/CD stands for Continuous Integration and Continuous Deployment (or Delivery). It's a set of practices that automate the building, testing, and deployment of software.

For Supabase, CI/CD helps you:

  • Automatically apply database schema changes.
  • Deploy Edge Functions.
  • Ensure consistent deployments across environments.

This automation reduces manual errors and speeds up your development cycle.

Database Migrations

As your application evolves, your database schema will change. Database migrations are version-controlled scripts that track and apply these changes.

The Supabase CLI provides powerful tools for managing migrations:

  • supabase migration new <name>: Creates a new migration file.
  • supabase db diff: Generates a migration script by comparing your local schema to your Supabase project.
  • supabase db push: Applies local migrations to your Supabase project.

These commands are essential for safely evolving your database schema.

# Create a new migration file
supabase migration new create_users_table

# Generate migration from local changes
supabase db diff -f new_feature_migration

# Apply all pending migrations
supabase db push

CI/CD Workflow Overview

A typical CI/CD pipeline for a Supabase project might involve these steps:

  • Build: Compile your application code (e.g., client-side app, Edge Functions).
  • Test: Run unit and integration tests against a development or staging Supabase project.
  • Deploy Schema: Apply pending database migrations to the target Supabase project.
  • Deploy Functions: Deploy updated Supabase Edge Functions.
  • Deploy Application: Deploy your client-side application (e.g., to Vercel, Netlify).

Each step ensures your changes are validated before reaching production.

Automating Deployments

You can use CI/CD platforms like GitHub Actions, GitLab CI, or CircleCI to automate these steps. For Supabase, a common task is to automate database migrations.

Here's a conceptual snippet of a GitHub Actions step that could apply migrations to a Supabase project. It uses the Supabase CLI and environment variables for authentication.

# This is a conceptual snippet for a CI/CD pipeline.
# It assumes SUPABASE_ACCESS_TOKEN and SUPABASE_PROJECT_REF
# are set as secrets in your CI/CD environment.

- name: Apply Supabase Migrations
  run: |
    # Install Supabase CLI
    npm i -g supabase

    # Link to your Supabase project (e.g., staging)
    supabase link --project-ref ${{ secrets.SUPABASE_PROJECT_REF_STAGING }}

    # Apply migrations
    supabase db push
  env:
    SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}

Quick Check

Which of the following are good practices when managing Supabase projects across different environments?

Recap: Secure & Streamlined

In this lesson, we explored how to effectively manage different environments (development, staging, production) for your Supabase projects. We also introduced the power of CI/CD.

  • Separate Projects: Essential for isolating environments.
  • Environment Variables: Securely manage configuration.
  • Supabase CLI Migrations: Automate database schema changes.
  • CI/CD: Streamline deployments and reduce errors.

By adopting these practices, you can build more robust, secure, and scalable applications with Supabase.

Sıkça Sorulan Sorular

“Ortam Yönetimi ve CI/CD” dersi ücretsiz mi?

Evet — “Ortam Yönetimi ve CI/CD” 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 Supabase Backend as a Service kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Supabase Backend as a Service kursu toplamda 4 dersten oluşur.

“Ortam Yönetimi ve CI/CD” dersinde ne öğreneceğim?

Farklı ortamları (geliştirme, hazırlık, üretim) yönetmeyi ve Supabase’i sürekli tümleştirme/sürekli dağıtım işlem hatlarınıza entegre etmeyi öğrenin Supabase Backend as a Service 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.

Supabase Backend as a Service öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Supabase Backend as a Service, 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.

“Ortam Yönetimi ve CI/CD” 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 Supabase Backend as a Service dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Supabase Backend as a Service 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. Ortam Yönetimi ve CI/CD
  2. Yedekleme, Geri Yükleme ve Felaket Kurtarma
  3. Güvenlik Denetimi ve En İyi Uygulamalar
  4. İzleme, Günlükleme ve Gözlemlenebilirlik
← Supabase Backend as a Service Sayfasına Dön