Mounting DigitalOcean Spaces

Mounting DigitalOcean Spaces

I assume you have already created a Space and Droplet on DigitalOcean. If you haven’t, do that now, then come back to this post. In this example, I’m using Ubuntu 16.04. I’ve also pointed a domain to this Droplet and put it behind Cloudflare, so Spaces can act as my file repository for my assets, and Cloudflare will deliver them.

Mounting Spaces on your Droplet

  1. SSH into your Droplet and run the following commands:
    • sudo apt-get install automake autotools-dev fuse g++ git libcurl4-gnutls-dev libfuse-dev libssl-dev libxml2-dev make pkg-config
    • git clone https://github.com/s3fs-fuse/s3fs-fuse.git
    • cd s3fs-fuse
    • ./autogen.sh
    • ./configure
    • make
    • sudo make install
  2. Next you need to create a file with your Spaces API Key and Secret Key
    • echo 'KEY:SECRET_KEY' > ~/.passwd-s3fs
    • chmod 600 ~/.passwd-s3fs
  3. Create a mountpoint for Spaces by running mkdir /spaces
  4. Then you need to append the following to your /etc/fstab file
    s3fs#BUCKET_NAME /spaces fuse allow_other,_netdev,nosuid,nodev,url=https://nyc3.digitaloceanspaces.com 0 0
    Be sure to replace BUCKET_NAME with your actual Spaces name
  5. After saving that file, run sudo mount -a .

Now you have unlimited storage capabilities on that Droplet. You could also install nginx and point the root directory to your Spaces mount point. Doing that would allow you to host as many assets as you want, without worrying about space. Maybe you can create the next Imgur.

Comments are closed.