Configuration Digital Ocean Spaces - ashleydavis/photosphere GitHub Wiki

This guide explains how to create a Digital Ocean account, set up Spaces (S3-compatible object storage), and configure Photosphere to use it for storing photos and videos.

Creating a Digital Ocean Account

  1. Sign up for Digital Ocean

  2. Verify your account

    • Check your email for verification
    • Complete any additional verification steps if requested

Setting up Digital Ocean Spaces

Create a Space

  1. Navigate to Spaces

    • In the Digital Ocean control panel, click "Spaces" in the left sidebar
    • Click "Create a Space"
  2. Configure your Space

    • Choose a datacenter region: Select the region closest to your users
      • Common regions: NYC3, SFO3, AMS3, SGP1, FRA1
    • Choose a unique name: e.g., my-photosphere-storage
    • Select project: Choose "default" or create a new project
    • Click "Create a Space"
  3. Configure Space settings

    • File Listing: Keep disabled for security

Generate Access Keys

  1. Navigate to API section

    • Click "API" in the left sidebar
    • Scroll to "Spaces access keys"
  2. Generate new key

    • Click "Generate New Key"
    • Enter a name (e.g., "photosphere-access")
    • Click "Generate Key"
    • IMPORTANT: Save both the access key and secret key immediately
    • You won't be able to see the secret key again!

Environment Variables Configuration

For Photosphere Backend

Add these environment variables to your .env file:

# S3 Storage Configuration
ASSET_STORAGE_CONNECTION=s3:your-space-name/collections
DATABASE_CONNECTION=s3:your-space-name/database

# AWS/S3 Credentials (works with Digital Ocean Spaces)
AWS_ACCESS_KEY_ID=your-spaces-access-key
AWS_SECRET_ACCESS_KEY=your-spaces-secret-key
AWS_DEFAULT_REGION=us-east-1  # Always use us-east-1 for Digital Ocean
AWS_ENDPOINT=https://nyc3.digitaloceanspaces.com  # Replace nyc3 with your region

For Photosphere CLI

You can configure the CLI in two ways:

Option 1: Environment Variables

export AWS_ACCESS_KEY_ID=your-spaces-access-key
export AWS_SECRET_ACCESS_KEY=your-spaces-secret-key
export AWS_DEFAULT_REGION=us-east-1
export AWS_ENDPOINT=https://nyc3.digitaloceanspaces.com

Option 2: Configuration File

Run the configuration command:

psi config

Or manually edit ~/.config/photosphere/photosphere.conf:

[s3]
region=us-east-1
accessKeyId=your-spaces-access-key
secretAccessKey=your-spaces-secret-key
endpoint=https://nyc3.digitaloceanspaces.com

Digital Ocean Spaces Endpoints

Replace the endpoint URL based on your Space's region:

Region Endpoint
NYC3 (New York) https://nyc3.digitaloceanspaces.com
SFO3 (San Francisco) https://sfo3.digitaloceanspaces.com
AMS3 (Amsterdam) https://ams3.digitaloceanspaces.com
SGP1 (Singapore) https://sgp1.digitaloceanspaces.com
FRA1 (Frankfurt) https://fra1.digitaloceanspaces.com

Using Digital Ocean Spaces with Photosphere

CLI Usage

Once configured, you can use Spaces directly:

# Initialize a collection in Spaces
psi init --db s3:my-photosphere-storage/collections/my-photos

# Add photos to Spaces
psi add --db s3:my-photosphere-storage/collections/my-photos ~/Pictures/*.jpg

# List photos in Spaces
psi list --db s3:my-photosphere-storage/collections/my-photos

Backend Usage

With the environment variables configured, the backend will automatically use Spaces for:

  • Storing photo and video assets
  • Saving database files
  • Managing collections

Troubleshooting

Common issues and solutions:

  • "Access Denied" errors: Check that your access keys are correct and have the necessary permissions
  • "Bucket not found": Ensure the Space name in your connection string matches exactly
  • Slow uploads: Check your internet connection and consider using a closer region

Related Documentation