Deploy Oxy on GCP
This guide walks you through deploying Oxy on Google Cloud Platform using Compute Engine VM instances with direct access. We’ll cover everything from setting up a virtual machine to configuring Oxy with proper data persistence.Prerequisites
Before you begin, make sure you have:- A Google Cloud Platform account
- A domain name (optional, but recommended for production deployments)
- Basic familiarity with Linux command line
Getting a VM Instance
Follow these steps to create a VM instance in Google Cloud Platform:Access Google Cloud Console
Create or Select a Project
Navigate to Compute Engine
Create a VM Instance
- Name: Choose a name for your instance (e.g.,
oxy-server
) - Region & Zone: Select a region close to your users
- Machine Configuration:
- For optimal cost-performance, consider using ARM-based instances (T2A series):
t2a-standard-1
(1 vCPU ARM, 4 GB memory)
- For optimal cost-performance, consider using ARM-based instances (T2A series):
- Boot disk:
- Operating System: Ubuntu
- Version: Latest stable (e.g., Ubuntu 22.04)
- Size: recommended starting point 10 GB
- Firewall:
- Check “Allow HTTP traffic” to allow access on port 3000
- You may also check “Allow HTTPS traffic” if you plan to set up HTTPS later
Note Your External IP
Pointing Your Domain to the VM (Optional)
If you have a domain name you want to use for your Oxy deployment:Access DNS Settings
Add DNS Records
- A Record:
- Host/Name:
@
(represents the root domain) - Value/Points to: Your VM’s External IP address
- TTL: 3600 (or as recommended by your registrar)
- Host/Name:
- A Record for www subdomain:
- Host/Name:
www
- Value/Points to: Your VM’s External IP address
- TTL: 3600 (or as recommended by your registrar)
- Host/Name:
Wait for DNS Propagation
Setting Up the VM
Connect to your VM instance and prepare it for Oxy deployment:Connect to Your VM
Update System and Install Essential Packages
Installing Oxy CLI
Let’s install Oxy directly on the VM:Install Required Dependencies
Install Oxy
Verify the Installation
Setting Up Oxy Workspace
Let’s use the built-inoxy init
command to initialize a new workspace with all the necessary files and configuration:
Create and Navigate to Workspace Directory
Initialize Oxy Project
- Create a
config.yml
file with your database and model configurations - Set up sample project files
- Create necessary directories like
agents
andworkflows
- Database settings (You can start with DuckDB for simplicity)
- Model configuration (e.g., OpenAI with your API key)
Alternative: Set Up Git and Clone Existing Project
oxy init
.Create Data Directory
Configure Environment Variables
.env
file in the workspace directory:OXY_STATE_DIR
, Oxy will use the default location ~/.local/share/oxy/
.
We recommend setting it explicitly for production deployments to make backups and maintenance easier.oxy init
process.Firewall Configuration
To ensure your Oxy deployment is accessible, you need to create a firewall rule that allows traffic on port 3000:Create Firewall Rule
Create Rule for Port 3000
- Name:
allow-oxy-port-3000
- Direction: Ingress
- Action: Allow
- Targets: Specified target tags
- Target tags:
oxy-server
(or the tag you want to use) - Source IP ranges:
0.0.0.0/0
(for public access) or your specific IP range for restricted access - Protocols and ports:
- Check “Specified protocols and ports”
- Select “TCP”
- Enter port
3000
Apply Tag to Your VM
oxy-server
(or whatever tag you used in the firewall rule).Click SAVE.Setting Up and Starting Oxy as a Service
Let’s configure Oxy to run automatically on system startup and restart if it fails:Create a Systemd Service File
ubuntu
user which is standard on GCP instances. If you’re using a different username, adjust accordingly.Save and exit.Enable and Start the Service
Verify the Service
View Logs (if needed)
Test the Connection
Access Your Deployment
Optional Configuration and Management
Everything up to this point completes the core setup of your Oxy deployment. The following sections cover additional aspects of managing your deployment that you may want to explore as needed.Data Persistence
It’s important to understand how Oxy handles data persistence:- Oxy uses SQLite for its internal database by default
- All data is stored in the directory specified by
OXY_STATE_DIR
environment variable (we set it to ~/oxy-data) - If
OXY_STATE_DIR
is not set, Oxy uses~/.local/share/oxy/
by default - This directory contains database files, semantic information, cached query results, and workflow history
Managing Your Deployment
Stopping the Service
Updating Oxy
Backup Data
gcloud
CLI installed and authenticated for the last command.Machine Recommendations
Usage Level | ARM-based (Best Value) | x86-based |
---|---|---|
Small (1-3 users) | t2a-standard-1 (2 vCPU, 4 GB) | e2-medium (1 vCPU, 4 GB) |
Medium (3-5 users) | t2a-standard-2 (2 vCPU, 8 GB) | e2-standard-2 (2 vCPU, 8 GB) |
Large (5-15 users) | t2a-standard-4 (4 vCPU, 16 GB) | e2-standard-4 (4 vCPU, 16 GB) |
Scaling on GCP
As your usage grows, you may need to scale your deployment:Vertical Scaling
- Stop your VM from the GCP Console
- Edit the VM configuration to increase CPU and memory
- Start the VM again
- Reconnect and start your Oxy service:
Storage Scaling
If you need more storage for your Oxy data:- Create a new persistent disk in the GCP Console
-
Connect to your VM and mount the disk:
-
To make the mount persistent across reboots, add it to fstab:
Troubleshooting
Cannot access Oxy through the domain or IP
Cannot access Oxy through the domain or IP
- Check your GCP firewall rules: Go to VPC Network → Firewall in GCP Console and verify port 3000 is allowed
- Verify VM network tags match the firewall rule target tags
- Test local connection:
curl http://localhost:3000
- For domain issues: Run
dig yourdomain.com
to verify DNS is pointing to your VM’s external IP - Check if your VM’s external IP has changed (this can happen after stop/start)
Oxy service won't start
Oxy service won't start
- View detailed logs:
sudo journalctl -u oxy -f
- Verify environment file exists:
cat ~/oxy-workspace/.env
- Check service file:
sudo cat /etc/systemd/system/oxy.service
- Ensure workspace exists:
ls -la ~/oxy-workspace
- Verify Oxy binary is installed:
which oxy
Data not persisting between restarts
Data not persisting between restarts
- Verify data directory exists:
ls -la ~/oxy-data
- Check environment variable is set:
grep OXY_STATE_DIR ~/oxy-workspace/.env
- If you didn’t set
OXY_STATE_DIR
, check the default location:ls -la ~/.local/share/oxy/
- Ensure proper permissions:
sudo chown -R ubuntu:ubuntu ~/oxy-data
Connection refused or timeout errors
Connection refused or timeout errors
- Verify the VM instance is running in the GCP Console
- Check if the firewall rule allows traffic on port 3000
- Ensure Oxy service is running:
sudo systemctl status oxy
- Test if the port is open:
sudo netstat -tlnp | grep :3000
- Verify the VM has the correct network tag applied
Next Steps
Once your GCP deployment is running:- Configure agents and workflows in your workspace
- Set up regular backups for your data
- Consider implementing a CI/CD pipeline for deploying configuration updates
- Monitor your VM’s resource usage and scale as needed