Merge pull request #60 from Oloodi/59-infra-update-makefile-to-support-data-connect-full-setup-sdk-workflow
59 infra update makefile to support data connect full setup sdk workflow
This commit is contained in:
98
Makefile
98
Makefile
@@ -4,7 +4,7 @@
|
||||
# It is designed to be the main entry point for developers.
|
||||
|
||||
# Use .PHONY to declare targets that are not files, to avoid conflicts.
|
||||
.PHONY: help install dev build integrate-export prepare-export deploy-launchpad deploy-launchpad-full deploy-app admin-install admin-dev admin-build deploy-admin deploy-admin-full configure-iap-launchpad configure-iap-admin list-iap-users remove-iap-user setup-labels export-issues create-issues-from-file install-git-hooks mobile-client-install mobile-client-dev mobile-client-build mobile-staff-install mobile-staff-dev mobile-staff-build
|
||||
.PHONY: help install dev build integrate-export prepare-export deploy-launchpad deploy-launchpad-full deploy-app admin-install admin-dev admin-build deploy-admin deploy-admin-full configure-iap-launchpad configure-iap-admin list-iap-users remove-iap-user setup-labels export-issues create-issues-from-file install-git-hooks mobile-client-install mobile-client-dev mobile-client-build mobile-staff-install mobile-staff-dev mobile-staff-build dataconnect-enable-apis dataconnect-init dataconnect-deploy dataconnect-sql-migrate dataconnect-generate-sdk dataconnect-sync dataconnect-bootstrap-db
|
||||
|
||||
# The default command to run if no target is specified (e.g., just 'make').
|
||||
.DEFAULT_GOAL := help
|
||||
@@ -38,10 +38,12 @@ ifeq ($(ENV),staging)
|
||||
GCP_PROJECT_ID := $(GCP_STAGING_PROJECT_ID)
|
||||
FIREBASE_ALIAS := staging
|
||||
HOSTING_TARGET := app-staging
|
||||
SQL_TIER := db-n1-standard-1
|
||||
else
|
||||
GCP_PROJECT_ID := $(GCP_DEV_PROJECT_ID)
|
||||
FIREBASE_ALIAS := dev
|
||||
HOSTING_TARGET := app-dev
|
||||
SQL_TIER := db-g1-small
|
||||
endif
|
||||
|
||||
# --- Conditional Variables by Service for IAP commands ---
|
||||
@@ -95,6 +97,11 @@ help:
|
||||
@echo " make dataconnect-enable-apis - Enables required GCP APIs for Data Connect."
|
||||
@echo " make dataconnect-init - Initializes Firebase Data Connect (interactive wizard)."
|
||||
@echo " make dataconnect-deploy - Deploys Data Connect schemas (GraphQL -> Cloud SQL)."
|
||||
@echo " make dataconnect-sql-migrate - Applies Data Connect SQL migrations to Cloud SQL."
|
||||
@echo " make dataconnect-generate-sdk - Regenerates the Data Connect SDK (frontend-web + internal-api-harness)."
|
||||
@echo " make dataconnect-sync - Runs sql:migrate + deploy + sdk:generate in order."
|
||||
@echo " make dataconnect-bootstrap-db - ONE-TIME: creates krow-sql, krow_db, links Data Connect, deploys, and generates initial SDK."
|
||||
@echo " make check-gcloud-beta - Validates gcloud + gcloud beta group availability."
|
||||
@echo ""
|
||||
@echo " --- BASE44 EXPORT WORKFLOW ---"
|
||||
@echo " make integrate-export - Integrates a new Base44 export from '../krow-workforce-export-latest'."
|
||||
@@ -331,6 +338,7 @@ dataconnect-enable-apis:
|
||||
@gcloud services enable sqladmin.googleapis.com --project=$(GCP_PROJECT_ID)
|
||||
@gcloud services enable iam.googleapis.com --project=$(GCP_PROJECT_ID)
|
||||
@gcloud services enable cloudresourcemanager.googleapis.com --project=$(GCP_PROJECT_ID)
|
||||
@gcloud services enable secretmanager.googleapis.com --project=$(GCP_PROJECT_ID)
|
||||
@echo "✅ APIs enabled for project [$(GCP_PROJECT_ID)]."
|
||||
|
||||
# Initialize Firebase Data Connect (interactive wizard).
|
||||
@@ -346,6 +354,94 @@ dataconnect-deploy:
|
||||
@firebase deploy --only dataconnect --project=$(FIREBASE_ALIAS)
|
||||
@echo "✅ Data Connect deployment completed for [$(ENV)]."
|
||||
|
||||
# Apply pending SQL migrations for Firebase Data Connect
|
||||
dataconnect-sql-migrate:
|
||||
@echo "--> Applying Firebase Data Connect SQL migrations to [$(ENV)] (project: $(FIREBASE_ALIAS))..."
|
||||
@firebase dataconnect:sql:migrate --project=$(FIREBASE_ALIAS)
|
||||
@echo "✅ Data Connect SQL migration completed for [$(ENV)]."
|
||||
|
||||
# Generate Data Connect client SDK for frontend-web and internal-api-harness
|
||||
dataconnect-generate-sdk:
|
||||
@echo "--> Generating Firebase Data Connect SDK for web frontend and API harness..."
|
||||
@firebase dataconnect:sdk:generate --project=$(FIREBASE_ALIAS)
|
||||
@echo "✅ Data Connect SDK generation completed for [$(ENV)]."
|
||||
|
||||
# Unified backend schema update workflow (schema -> deploy -> SDK)
|
||||
dataconnect-sync:
|
||||
@echo "--> [1/3] Applying SQL migrations..."
|
||||
@firebase dataconnect:sql:migrate --project=$(FIREBASE_ALIAS)
|
||||
@echo "--> [2/3] Deploying Data Connect..."
|
||||
@firebase deploy --only dataconnect --project=$(FIREBASE_ALIAS)
|
||||
@echo "--> [3/3] Regenerating SDK..."
|
||||
@firebase dataconnect:sdk:generate --project=$(FIREBASE_ALIAS)
|
||||
@echo "✅ Data Connect SQL, deploy, and SDK generation completed for [$(ENV)]."
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# ONE-TIME FULL SETUP FOR CLOUD SQL + DATA CONNECT
|
||||
# -------------------------------------------------------------------
|
||||
# ⚠️ WARNING:
|
||||
# This should only be executed when setting up a brand new environment
|
||||
# (e.g., first-time dev setup or new GCP project).
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
# Comprueba que gcloud y el grupo beta están disponibles
|
||||
check-gcloud-beta:
|
||||
@command -v gcloud >/dev/null 2>&1 || { \
|
||||
echo "❌ gcloud CLI not found. Please install it: https://cloud.google.com/sdk/docs/install"; \
|
||||
exit 1; \
|
||||
}
|
||||
@gcloud beta --help >/dev/null 2>&1 || { \
|
||||
echo "❌ 'gcloud beta' is not available. Run 'gcloud components update' or reinstall the SDK."; \
|
||||
exit 1; \
|
||||
}
|
||||
@echo "✅ gcloud CLI and 'gcloud beta' are available."
|
||||
|
||||
dataconnect-bootstrap-db: check-gcloud-beta
|
||||
@echo "🔍 Checking if Cloud SQL instance krow-sql already exists in [$(GCP_PROJECT_ID)]..."
|
||||
@if gcloud sql instances describe krow-sql --project=$(GCP_PROJECT_ID) >/dev/null 2>&1; then \
|
||||
echo "⚠️ Cloud SQL instance 'krow-sql' already exists in project $(GCP_PROJECT_ID)."; \
|
||||
echo " If you really need to recreate it, delete the instance manually first."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
@echo "⚠️ Creating Cloud SQL instance krow-sql (tier: $(SQL_TIER)) (ONLY RUN THIS ONCE PER PROJECT)..."
|
||||
gcloud sql instances create krow-sql \
|
||||
--database-version=POSTGRES_15 \
|
||||
--tier=$(SQL_TIER) \
|
||||
--region=us-central1 \
|
||||
--storage-size=10 \
|
||||
--storage-auto-increase \
|
||||
--availability-type=zonal \
|
||||
--backup-start-time=03:00 \
|
||||
--project=$(GCP_PROJECT_ID)
|
||||
|
||||
@echo "⚠️ Creating Cloud SQL database krow_db..."
|
||||
gcloud sql databases create krow_db \
|
||||
--instance=krow-sql \
|
||||
--project=$(GCP_PROJECT_ID)
|
||||
|
||||
@echo "⚠️ Creating Firebase Data Connect service identity..."
|
||||
gcloud beta services identity create \
|
||||
--service=firebasedataconnect.googleapis.com \
|
||||
--project=$(GCP_PROJECT_ID)
|
||||
|
||||
@echo "⚠️ Enabling IAM authentication on Cloud SQL instance krow-sql..."
|
||||
gcloud sql instances patch krow-sql \
|
||||
--project=$(GCP_PROJECT_ID) \
|
||||
--database-flags=cloudsql.iam_authentication=on \
|
||||
--quiet
|
||||
|
||||
@echo "⚠️ Linking Data Connect service (krow-workforce-db) with Cloud SQL..."
|
||||
firebase dataconnect:sql:setup krow-workforce-db --project=$(FIREBASE_ALIAS)
|
||||
|
||||
@echo "⚠️ Deploying initial Data Connect configuration..."
|
||||
@firebase deploy --only dataconnect --project=$(FIREBASE_ALIAS)
|
||||
|
||||
@echo "⚠️ Generating initial Data Connect SDK..."
|
||||
@firebase dataconnect:sdk:generate --project=$(FIREBASE_ALIAS)
|
||||
|
||||
@echo "🎉 Cloud SQL + Data Connect bootstrap completed successfully!"
|
||||
|
||||
# --- Mobile App Development ---
|
||||
FLAVOR :=
|
||||
ifeq ($(ENV),dev)
|
||||
|
||||
Reference in New Issue
Block a user