Careeroza
Deploying to the Cloud
Options
| Option | Good for | You manage |
|---|---|---|
| Linux VM (AWS EC2, GCP Compute Engine) | learning, small apps, full control | OS, Java, Nginx, TLS, restarts |
| Render / Railway | student projects, demos | almost nothing (connect GitHub) |
| AWS Elastic Beanstalk / App Runner, Google Cloud Run | production without Kubernetes | container image, config |
| Kubernetes (EKS, GKE) | many services, big teams | cluster, manifests (see Microservices) |
On a Linux VM with systemd
Example
/etc/systemd/system/shopease.service
[Unit]
Description=ShopEase API
After=network.target
[Service]
User=shopease
WorkingDirectory=/opt/shopease
EnvironmentFile=/etc/shopease/shopease.env
ExecStart=/usr/bin/java -XX:MaxRAMPercentage=75 -jar /opt/shopease/shopease.jar
SuccessExitStatus=143
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetExample
scp target/shopease-1.0.0.jar deploy@shopease-vm:/opt/shopease/shopease.jar
ssh deploy@shopease-vm "sudo systemctl daemon-reload && sudo systemctl restart shopease && systemctl is-active shopease"
curl -s https://api.shopease.in/actuator/healthExample output
active
{"status":"UP"}Tip: Put Nginx (or Caddy) in front for HTTPS with a free Let's Encrypt certificate and proxy to localhost:8080. Set server.forward-headers-strategy=framework so Spring sees the real client IP and https scheme.
On Render (Free Tier Demo)
- Push the project with the Dockerfile to GitHub.
- Render → New → Web Service → pick the repo; it detects the Dockerfile.
- Add environment variables:
SPRING_PROFILES_ACTIVE=prod,SPRING_DATASOURCE_URL, user, password (use a managed PostgreSQL or MySQL). - Render passes
PORT: setserver.port=${PORT:8080}. - Each push to
mainredeploys automatically.
On AWS
Example
A common simple setup: image in ECR, run on App Runner, database on RDS:
aws ecr create-repository --repository-name shopease
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.ap-south-1.amazonaws.com
docker tag shopease:1.0.0 123456789012.dkr.ecr.ap-south-1.amazonaws.com/shopease:1.0.0
docker push 123456789012.dkr.ecr.ap-south-1.amazonaws.com/shopease:1.0.0Example output
Login Succeeded 1.0.0: digest: sha256:4f7a...c21e size: 2412
Note: Store the database password in AWS Secrets Manager (or GCP Secret Manager) and inject it as an environment variable. Never commit it to Git.