Skip to content

Commit 29938e3

Browse files
committed
feat: Fix letterpress AI functionality
1 parent babff15 commit 29938e3

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ RUN npm ci --ignore-scripts
1313
# Copy source code (excluding server directory)
1414
COPY . .
1515

16+
# Accept backend URL as build argument
17+
ARG VITE_API_BASE_URL
18+
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
19+
1620
# Build the frontend
1721
RUN npm run build
1822

cloudbuild.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,24 @@ steps:
1212
- './server'
1313
id: 'build-backend-image'
1414

15-
# Build the frontend container image
15+
# Get backend URL for frontend build
16+
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
17+
entrypoint: 'bash'
18+
args:
19+
- '-c'
20+
- |
21+
# Try to get existing backend URL, fallback to default
22+
BACKEND_URL=$$(gcloud run services describe craftscape-backend --region us-central1 --format="value(status.url)" 2>/dev/null || echo "https://craftscape-backend-998275462099.us-central1.run.app")
23+
echo "$$BACKEND_URL" > /workspace/backend_url.txt
24+
echo "Backend URL for frontend: $$BACKEND_URL"
25+
id: 'get-backend-url'
26+
27+
# Build the frontend container image with backend URL
1628
- name: 'gcr.io/cloud-builders/docker'
1729
args:
1830
- 'build'
31+
- '--build-arg'
32+
- 'VITE_API_BASE_URL=$$(cat /workspace/backend_url.txt)'
1933
- '-t'
2034
- 'gcr.io/$PROJECT_ID/craftscape-frontend:$COMMIT_SHA'
2135
- '-t'
@@ -24,6 +38,7 @@ steps:
2438
- 'Dockerfile'
2539
- '.'
2640
id: 'build-frontend-image'
41+
waitFor: ['get-backend-url']
2742

2843
# Push the backend container image to Container Registry
2944
- name: 'gcr.io/cloud-builders/docker'

deploy-frontend-to-cloudrun.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,24 @@ gcloud services enable run.googleapis.com
3636
gcloud services enable containerregistry.googleapis.com
3737
gcloud services enable cloudbuild.googleapis.com
3838

39+
# Get backend URL
40+
Write-Host ""
41+
Write-Host "Getting backend service URL..." -ForegroundColor Yellow
42+
$BACKEND_URL = gcloud run services describe craftscape-backend --region $REGION --format="value(status.url)" 2>$null
43+
44+
if ([string]::IsNullOrEmpty($BACKEND_URL)) {
45+
Write-Host "⚠ Backend service not found. Using default URL." -ForegroundColor Yellow
46+
$BACKEND_URL = "https://craftscape-backend-998275462099.us-central1.run.app"
47+
}
48+
49+
Write-Host "Backend URL: $BACKEND_URL" -ForegroundColor Cyan
50+
3951
# Build the Docker image
4052
Write-Host ""
4153
Write-Host "Building Docker image..." -ForegroundColor Yellow
4254
Write-Host "Image: $IMAGE_NAME" -ForegroundColor Cyan
4355

44-
docker build -t $IMAGE_NAME .
56+
docker build -t $IMAGE_NAME --build-arg VITE_API_BASE_URL=$BACKEND_URL .
4557

4658
if ($LASTEXITCODE -ne 0) {
4759
Write-Host "✗ Docker build failed!" -ForegroundColor Red

0 commit comments

Comments
 (0)