GCP Deployment
Deploy Karrio on Google Cloud Platform (GCP).
Prerequisites
- Google Cloud Platform account
- GCP project with billing enabled
- Basic knowledge of Docker and Docker Compose
Step 1: Create a Compute Engine VM Instance
- Log into Google Cloud Console
- Navigate to âCompute Engineâ > âVM Instancesâ
- Click âCreate Instanceâ
- Configure:
- Name:
karrio-server - Machine Type:
e2-medium(production) ore2-small(development) - Boot Disk: Ubuntu 22.04 LTS, 20 GB SSD
- Firewall: Allow HTTP and HTTPS traffic
- Name:
- Click âCreateâ
Step 2: Set Up Firewall Rules
- Navigate to âVPC Networkâ > âFirewallâ
- Create rules for:
- Allow HTTP (port 80)
- Allow HTTPS (port 443)
- Allow SSH (port 22)
Step 3: Connect to Your VM
1gcloud compute ssh karrio-server --zone=your-zone
Or use the SSH button in the Google Cloud Console.
Step 4: Install Docker and Docker Compose
1sudo apt update && sudo apt upgrade -y 2sudo apt install -y apt-transport-https ca-certificates curl software-properties-common 3curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 4sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" 5sudo apt update 6sudo apt install -y docker-ce 7sudo systemctl enable docker 8sudo systemctl start docker 9sudo usermod -aG docker $USER 10sudo curl -L "https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 11sudo chmod +x /usr/local/bin/docker-compose 12exit
Step 5: Deploy Karrio
Reconnect to your VM after logging out.
Option 1: One-Click Hobby Deployment
1/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/karrioapi/karrio/HEAD/bin/deploy-hobby)"
When prompted, enter your domain name.
Option 2: Manual Deployment
1mkdir -p ~/karrio 2cd ~/karrio 3curl -O https://raw.githubusercontent.com/karrioapi/karrio/HEAD/docker/docker-compose.yml 4curl -O https://raw.githubusercontent.com/karrioapi/karrio/HEAD/docker/.env 5docker-compose up -d
Edit .env with your configuration. Set up your preferred webserver for HTTPS and domain routing.
Step 6: Set Up a Static External IP
- Navigate to âVPC Networkâ > âExternal IP addressesâ
- Click âReserve Static Addressâ
- Configure:
- Name:
karrio-static-ip - Network Service Tier: Premium
- IP Version: IPv4
- Type: Regional
- Region: Same as your VM
- Attached To: Your VM instance
- Name:
- Click âReserveâ
Step 7: Configure DNS
Add DNS records:
- Type:
A, Name:api, Value: Your VMâs static IP - Type:
A, Name:app, Value: Your VMâs static IP
Step 8: Access Your Karrio Instance
- Dashboard:
https://app.your-domain.com - API:
https://api.your-domain.com
Default login: admin@example.com / demo
Setting Up a Load Balancer (Optional)
- Navigate to âNetwork Servicesâ > âLoad Balancingâ
- Click âCreate Load Balancerâ
- Choose âHTTP(S) Load Balancingâ
- Configure:
- Backend: Create backend service pointing to your VM
- Frontend: Set up HTTPS with SSL certificates
- Update DNS records to point to the load balancerâs IP address
Backup and Restore
Automated Backups
1cat > ~/backup_karrio.sh << 'EOL' 2#!/bin/bash 3TIMESTAMP=$(date +%Y%m%d_%H%M%S) 4BACKUP_DIR=~/karrio-backups 5mkdir -p $BACKUP_DIR 6cd ~/karrio 7docker-compose exec -T db pg_dump -U postgres -d db > $BACKUP_DIR/karrio_db_$TIMESTAMP.sql 8cp ~/karrio/.env $BACKUP_DIR/env_$TIMESTAMP 9cp ~/karrio/Caddyfile $BACKUP_DIR/Caddyfile_$TIMESTAMP 10EOL 11chmod +x ~/backup_karrio.sh 12(crontab -l 2>/dev/null; echo "0 2 * * * ~/backup_karrio.sh") | crontab -
Google Cloud Storage (Optional)
- Create Storage Bucket in âStorageâ > âBrowserâ
- Install gsutil:
sudo apt-get install -y google-cloud-sdk-gsutil - Uncomment gsutil commands in backup script
Monitoring
- Google Cloud Monitoring
- Container logs:
cd ~/karrio && docker-compose logs -f
Updating
1cd ~/karrio 2/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/karrioapi/karrio/HEAD/bin/upgrade-hobby)"
Troubleshooting
SSL Certificate Issues
1cd ~/karrio 2docker-compose logs caddy
Check: DNS records, ports 80/443 open in firewall rules
Container Issues
1cd ~/karrio 2docker-compose ps 3docker-compose logs <service_name>
Instance Resources
Check usage with top. Upgrade machine type in Google Cloud Console if needed.
Optimizing Costs
- Use Compute Engine sustained use discounts (automatic)
- Consider preemptible VMs for non-production
- Right-size VM instance based on usage
- Set up budget alerts in Google Cloud Console
