Skip to main content
This guide walks you through deploying HelixDB to a DigitalOcean Droplet (virtual machine). We’ll cover two deployment approaches:
  1. Direct Build: Build the Docker image directly on the droplet (simpler, no registry needed)
  2. Container Registry: Build locally and push to DigitalOcean’s Container Registry (more scalable)
Choose the approach that best fits your needs. For most use cases, the Direct Build approach is simpler and sufficient.

Prerequisites

Before you begin, ensure you have:
  • A DigitalOcean account
  • A Helix project ready to deploy
  • Docker installed locally

Method 1: Direct Build

This method builds the Docker image directly on your droplet, eliminating the need for a container registry.

Step 1: Install and Configure doctl

First, create a DigitalOcean API token:
  1. Go to the Applications & API page in the DigitalOcean control panel
  2. Click “Generate New Token”
  3. Give it a name and ensure it has both read and write access
  4. Save the token string immediately - it’s only displayed once
Install the DigitalOcean CLI tool and authenticate:
When prompted during doctl auth init, paste your API token.

Step 2: Create SSH Key

Generate an SSH key pair for secure access to your droplet:
Import the public key to DigitalOcean and note the returned ID:

Step 3: Create Block Storage Volume

Create a persistent volume for your database data. This ensures data persists even if you recreate the droplet:
Choose a region close to your users for better latency. Available regions include nyc3, sfo3, ams3, etc.

Step 4: Create Droplet

Create a droplet with Docker pre-installed:
There are many different droplet sizes and images to choose from. You can find the available sizes and images here.

Step 5: Attach Volume to Droplet

Attach the block storage volume to your droplet:
The volume will be automatically mounted at /mnt/helix-prod-data.

Step 6: Copy Helix Build to Droplet

Build your Helix project and copy it to the droplet:

Step 7: Build Docker Image on Droplet

Build the Docker image directly on the droplet:

Step 8: Deploy Container

Run your Helix container with persistent storage:
Configuration explained:
  • -d: Run in detached mode (background)
  • --name helix: Name the container for easy reference
  • --restart unless-stopped: Automatically restart on system reboot
  • -p 6969:6969: Expose port 6969 (HelixDB default)
  • -v /mnt/helix-prod-data:/data: Mount persistent volume
  • -e HELIX_PORT=6969: Set the port Helix listens on
  • -e HELIX_DATA_DIR=/data: Tell Helix where to store data

Step 9: Configure Firewall

Create a firewall to secure your droplet:
This firewall allows:
  • Inbound: SSH (port 22) and Helix (port 6969) from anywhere
  • Outbound: All traffic (needed for updates and dependencies)
For production, consider restricting SSH access to specific IP addresses.

Step 10: Test Your Deployment

Verify that Helix is running correctly: This is an example of how to create a user and get a user by name, if your queries are different, you can use the same pattern.

Redeployments

When you update your Helix queries or schema:
The data will persist even if you restart the droplet, because we are using a persistent volume.

Method 2: Container Registry

This method uses DigitalOcean’s Container Registry to store your Docker images, enabling easier scaling and rollbacks.

Step 1-2: Prerequisites and SSH Key

Follow Steps 1-2 from Method 1 above.

Step 3: Create Container Registry

Create a private container registry:
You can find the subscription tiers here.

Step 4-6: Volume and Droplet Setup

Follow Steps 3, 4, and 5 from Method 1 to create the volume, droplet, and attach the volume.

Step 7: Build and Push Docker Image

Build your image locally and push to the registry:
The --platform linux/amd64 flag ensures compatibility with DigitalOcean’s Linux droplets.

Step 8: Configure Registry Access on Droplet

Get your registry credentials and log in from the droplet:

Step 9: Deploy Container from Registry

Pull and run your image from the registry:

Step 10-11: Firewall and Testing

Follow Steps 9-10 from Method 1 to configure the firewall and test your deployment.

Redeploying with Registry

When you update your code:

Cleanup and Resource Deletion

If you want to delete all the resources you created, you can use the following commands:
Important: Always backup your data before deleting the volume. Once deleted, data cannot be recovered.

Resources