-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildndeploy.sh
executable file
·46 lines (39 loc) · 1.16 KB
/
buildndeploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Load environment variables from .env.production file
set -o allexport
source .env.production
set -o allexport
# Define variables
IMAGE_NAME=gcr.io/sonorous-earth-430515-u7/showerthoughts
PROJECT=sonorous-earth-430515-u7
SERVICE_NAME=showerthoughts
REGION=us-central1
PORT=8080
CPU=1
MEMORY=512Mi
CONCURRENCY=80
TIMEOUT=300
SERVICE_ACCOUNT=736870137403-compute@developer.gserviceaccount.com
# Construct the --set-env-vars parameter from the .env.production file
ENV_VARS=$(grep -v '^#' .env.production | xargs | sed 's/ /,/g')
# Step 1: Build the Docker image
echo "Building Docker image..."
docker build -t $IMAGE_NAME .
# Step 2: Push the Docker image to Google Container Registry
echo "Pushing Docker image to Google Container Registry..."
docker push $IMAGE_NAME
# Step 3: Deploy to Google Cloud Run
echo "Deploying to Google Cloud Run..."
gcloud run deploy $SERVICE_NAME \
--project $PROJECT \
--image $IMAGE_NAME \
--platform managed \
--region $REGION \
--port $PORT \
--cpu $CPU \
--memory $MEMORY \
--concurrency $CONCURRENCY \
--timeout $TIMEOUT \
--service-account $SERVICE_ACCOUNT \
--set-env-vars $ENV_VARS
echo "Deployment completed."