#!/bin/bash
set -e
# Set your project ID
PROJECT_ID="YOUR_GCP_REPO"
GCP_REPO_NAME="STATESMAN_ARTEFACT_NAME"
GCP_REGION="us-central1"
echo "Setting up Artifact Registry for Statesman..."
# Enable all required APIs
echo "Enabling required GCP APIs..."
gcloud services enable artifactregistry.googleapis.com
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com
gcloud services enable containerregistry.googleapis.com
# Check if repository exists, create if it doesn't
if ! gcloud artifacts repositories describe $GCP_REPO_NAME --location=$GCP_REGION >/dev/null 2>&1; then
echo "Creating repository..."
gcloud artifacts repositories create $GCP_REPO_NAME \
--repository-format=docker \
--location=$GCP_REGION \
--description="Repository for OpenTaco Statesman images"
else
echo "Repository already exists $GCP_REPO_NAME, skipping creation..."
fi
# Configure Docker auth
gcloud auth configure-docker $GCP_REGION-docker.pkg.dev
# Pull, tag, and push image
docker pull --platform linux/amd64 ghcr.io/diggerhq/digger/taco-statesman:latest
docker tag ghcr.io/diggerhq/digger/taco-statesman:latest \
$GCP_REGION-docker.pkg.dev/$PROJECT_ID/$GCP_REPO_NAME/taco-statesman:latest
docker push $GCP_REGION-docker.pkg.dev/$PROJECT_ID/$GCP_REPO_NAME/taco-statesman:latest
echo "Deploying to Cloud Run..."
gcloud run deploy statesman \
--image $GCP_REGION-docker.pkg.dev/$PROJECT_ID/$GCP_REPO_NAME/taco-statesman:latest \
--region $GCP_REGION \
--platform managed \
--allow-unauthenticated \
--env-vars-file cloud-run.env.yaml
echo "Artifact Registry and Cloud Run setup complete!"
echo "Your image is now at: $GCP_REGION-docker.pkg.dev/$PROJECT_ID/$GCP_REPO_NAME/taco-statesman:latest"
SERVICE_URL=$(gcloud run services describe statesman --region $GCP_REGION --format="value(status.url)")
echo "Service URL: $SERVICE_URL"
echo "Health check: $SERVICE_URL/readyz"