Below is a complete beginner-friendly guide to deploy a React (UI) + Java (backend) app on Google Cloud Platform (GCP) and point your GoDaddy domain (mywebsite.com) so that when someone visits your site, it loads from GCP.
Goal (what we’re building)
You already bought mywebsite.com on GoDaddy. You want:
-
React UI hosted on GCP
-
Java backend API hosted on GCP
-
Domain routing:
-
Secure HTTPS with Google-managed certificates
-
Production-ready and beginner-friendly
This guide uses Cloud Run (easiest modern way). It runs containers, scales automatically, and works great for Java.
What you need before starting
-
A GCP account + billing enabled
-
Your project created in GCP
-
GoDaddy access (DNS settings)
-
Installed tools on your machine:
-
Google Cloud SDK (gcloud)
-
Docker
-
Node.js (for React build)
-
Java + Maven/Gradle (for backend build)
Architecture options (choose one)
Option A (recommended): Cloud Run for backend + Cloud Storage/CDN for UI
Option B: Cloud Run for both UI and backend
I’ll explain Option A fully (best practice), and at the end I’ll include Option B quickly.
Part 1 — GCP project setup
1) Create/select a GCP project
In GCP Console:
2) Enable required APIs
Go to APIs & Services → Library and enable:
-
Cloud Run API
-
Artifact Registry API
-
Cloud Build API
-
Certificate Manager API (or “Cloud Managed Certificates” depending on UI)
-
Cloud DNS API (optional, not required if using GoDaddy DNS)
-
Cloud Storage API
-
(Optional but recommended) Cloud CDN, Load Balancing APIs
Part 2 — Deploy Java backend to Cloud Run
Cloud Run deploys containers, so we’ll containerize your Java backend.
3) Containerize your Java backend
In your Java backend project root, create a Dockerfile.
If you’re using Spring Boot (common)
Important: Cloud Run expects your app to listen on PORT (usually 8080), so in Spring Boot make sure it runs on 8080 (default is fine).
4) Create an Artifact Registry repo (once)
In Cloud Console:
5) Build and push image (easy way: Cloud Build)
Open terminal and run:
Build + push using Cloud Build:
Example:
us-central1-docker.pkg.dev/mywebsite-prod/mywebsite-repo/mybackend:1.0
6) Deploy backend to Cloud Run
After deploy, Cloud Run gives you a URL like:
https://mybackend-xxxxx-uc.a.run.app
Test:
7) Configure CORS (important for React calling backend)
If your UI will be mywebsite.com and API will be api.mywebsite.com, allow that origin.
Spring example (conceptually):
This step depends on your Java framework. Do it now so browser requests don’t fail.
Part 3 — Deploy React UI (static hosting on GCP)
React is best hosted as static files.
8) Build your React app
Inside your React project:
This produces a build/ folder.
9) Create a Cloud Storage bucket for website hosting
Go to Cloud Storage → Buckets → Create
-
Name: mywebsite-ui-bucket (must be globally unique)
-
Location: same region or multi-region
-
Public access: we will handle properly via LB/CDN (recommended), but for simplest beginner approach you can make it public.
Simple beginner approach (public bucket hosting)
In the bucket:
SPA routing tip: React apps need unknown routes to return index.html (so /about works). We’ll handle that better with Load Balancer later.
Part 4 — Connect domain in GoDaddy (DNS) to GCP
You want mywebsite.com to go to GCP.
To support HTTPS and clean routing, best practice is:
This sounds scary, but it’s the most “real production” setup.
10) Create a Load Balancer (UI + API under one domain)
What we want the load balancer to do
-
Requests to mywebsite.com/* → Cloud Storage (React UI)
-
Requests to api.mywebsite.com/* → Cloud Run (Java backend)
-
Google-managed SSL certificates for both
Steps (high-level)
In GCP Console:
-
Go to Network Services → Load balancing
-
Create HTTP(S) Load Balancer
-
Create Frontend
-
Create Backend
-
URL Maps / Routing:
-
Host rule mywebsite.com → UI backend
-
Host rule www.mywebsite.com → UI backend
-
Host rule api.mywebsite.com → API backend
-
Reserve a static external IP for the LB (recommended)
After creation, GCP gives you an IP like: 34.xxx.xxx.xxx
11) Update GoDaddy DNS
Now go to GoDaddy → Domain → DNS
Add/Update records:
Root domain (mywebsite.com)
GoDaddy often supports an A record:
www subdomain (www.mywebsite.com)
-
Type: CNAME
-
Name: www
-
Value: mywebsite.com
API subdomain (api.mywebsite.com)
If using same LB IP (recommended with host-based routing):
12) Wait for DNS + SSL to become active
DNS can take minutes to hours to propagate.
SSL certificate provisioning may take some time too (commonly 15–60 minutes, sometimes longer).
Once active:
Part 5 — Connect React UI to Java API
13) Use environment variables in React
In React, create .env.production:
Then in code:
Rebuild:
Re-upload build files to the bucket.
Part 6 — Recommended production improvements
14) Enable Cloud CDN for UI
If you front the bucket with Load Balancer, you can enable Cloud CDN for fast global caching.
15) Add backend environment config securely
Use Cloud Run environment variables:
16) Logging + monitoring
Cloud Run logs automatically appear in:
-
Cloud Logging
-
Cloud Monitoring
Common beginner mistakes (and fixes)
1) React routes return 404
Fix: configure LB / bucket website to serve index.html for unknown paths (SPA fallback). The Load Balancer URL map can do this cleanly.
2) CORS errors
Fix: allow origin https://mywebsite.com in Java backend.
3) Backend works by URL but not by custom domain
Fix: ensure:
-
api.mywebsite.com DNS points to LB IP
-
LB host rule routes api.mywebsite.com to Cloud Run backend
-
SSL cert includes api.mywebsite.com
4) SSL stuck in “Provisioning”
Fix checklist:
-
DNS must already point correctly to LB IP
-
No conflicting records
-
Wait a bit; if still stuck, re-check domain ownership / DNS
Option B (simpler): Host both React and Java on Cloud Run
If you don’t want load balancers/buckets yet:
But: mapping a custom domain directly to Cloud Run is possible; however routing mywebsite.com and api.mywebsite.com becomes slightly less flexible than the LB approach.