Skip to content

Instantly share code, notes, and snippets.

@saviour123
Created November 27, 2025 13:55
Show Gist options
  • Select an option

  • Save saviour123/6b47e351d9e04c44268a30a51b922eeb to your computer and use it in GitHub Desktop.

Select an option

Save saviour123/6b47e351d9e04c44268a30a51b922eeb to your computer and use it in GitHub Desktop.
quickie.js
https://moon.mydream42.com/yelizariev/bceb91664910e5eb5bf225c6b22d5fe9/%E2%98%80/AmonRa.markdown
@saviour123
Copy link
Author

#!/bin/bash

Simple deployment script for Google Cloud Run

Usage: ./deploy.sh

set -e

Configuration - Edit these values

PROJECT_ID="hello"
SERVICE_NAME="hello"
REGION="europe-north1"
IMAGE_NAME="gcr.io/${PROJECT_ID}/${SERVICE_NAME}"

Environment variables - Edit these

NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY="hello"
NEXT_PUBLIC_MEDUSA_BACKEND_URL="https://run.app"

Set the project

echo -e "${YELLOW}πŸ”§ Setting project to ${PROJECT_ID}${NC}"
gcloud config set project ${PROJECT_ID}

Enable required APIs

echo -e "${YELLOW}πŸ”Œ Enabling required APIs...${NC}"
gcloud services enable run.googleapis.com
gcloud services enable containerregistry.googleapis.com

Configure Docker for gcloud

echo -e "${YELLOW}πŸ”§ Configuring Docker authentication...${NC}"
gcloud auth configure-docker

Build the Docker image with buildx for AMD64 platform

echo -e "${YELLOW}πŸ—οΈ Building Docker image for AMD64 platform...${NC}"
docker buildx build --platform linux/amd64
--build-arg NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY="${NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY}"
--build-arg NEXT_PUBLIC_MEDUSA_BACKEND_URL="${NEXT_PUBLIC_MEDUSA_BACKEND_URL}"
--build-arg MEDUSA_BACKEND_URL="${NEXT_PUBLIC_MEDUSA_BACKEND_URL}"
--build-arg NEXT_PUBLIC_BASE_URL="https://hello.run.app"
--build-arg NEXT_PUBLIC_DEFAULT_REGION="dk"
-t gcr.io/theincheshair/medusa-storefront:latest .

Push the image to Google Container Registry

echo -e "${YELLOW}πŸ“€ Pushing image to Google Container Registry...${NC}"
docker push gcr.io/hello/hello-storefront:latest

Deploy to Cloud Run

echo -e "${YELLOW}🚒 Deploying to Cloud Run...${NC}"
gcloud run deploy ${SERVICE_NAME}
--image gcr.io/hello/hello
--platform managed
--region ${REGION}
--allow-unauthenticated
--port 8000
--memory 512Mi
--cpu 1
--max-instances 10
--set-env-vars "NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=${NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY},NEXT_PUBLIC_MEDUSA_BACKEND_URL=${NEXT_PUBLIC_MEDUSA_BACKEND_URL},MEDUSA_BACKEND_URL=https://run.app"

Get the service URL

SERVICE_URL=$(gcloud run services describe ${SERVICE_NAME} --platform managed --region ${REGION} --format 'value(status.url)')

echo ""
echo -e "${GREEN}βœ… Deployment successful!${NC}"
echo -e "${GREEN}🌐 Your app is running at: ${SERVICE_URL}${NC}"
echo ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment