This website is a collection of files being seeded via the decentralized protocol dat from one or more computers, including a DigitalOcean droplet running homebase.

Below I'll walk through how the website was created/seeded.

1. Seeding from your computer with dat.

  1. Install dat globally with npm install -g dat or follow these instructions.
  2. cd into your website's directory and run dat share. This will create a .dat folder in the directory and seed the directory's files.
  3. Copy and paste the terminal output's dat:// address into beaker browser to view your website

Now, as long as your computer is on, your website will now be accessible from any computer via the beaker browser.

2. Setting up homebase on a DigitalOcean droplet.

Now, we'll set up a $5/month DigitalOcean droplet to seed your files from, so that even when your personal computer is off, the website will be accessible. We'll also mirror it over https so that the site can be accessed with any modern web browser.

I. Create your droplet

  1. Create a DigitalOcean account. Here is my referral link for $100 credit (over 60 days).
  2. Set up SSH keys if you haven't already by following these instructions. Take note of where your public key is stored on your computer (you'll need it in the next step).
  3. Create a new droplet with Ubuntu, Starter (Standard) Plan, at $5/mo (1GB CPU, 25GB SSD, 1000GB transfer), at any datacenter region.
  4. Assign the SSH key that you created if it's there, otherwise press New SSH key and copy and paste the entire contents of your SSH Key (likely the id_rsa.pub file). Choose a memorable hostname and press Create.
  5. Wait for the loading bar to complete to see the IP for your new droplet and make note of this address for later.

II. Connect your droplet to your domain

To connect your public domain (i.e. dillon.dev) to this droplet, you can either point the domain to the IP address or point the domain's nameservers to DigitalOcean and let DigitalOcean handle it. I decided to do the latter, which I'll explain below or you can follow these instructions.

  1. Change your domain's nameservers to point to DigitalOcean. This DO tutorial includes specific instructions for a number of the most common domain registrars.
  2. Navigate to the Networking tab in DigitalOcean and add a new Domain. Do this by typing your domain's name (i.e. dillon.dev) and clicking Add Domain.
  3. Add two new A records: one with hostname @ that will direct to your droplet's IP address (click it in the dropdown or type it in manually) TTL 3600; another one with hostname www that will direct to your droplet's IP address and TTL 3600. The result will look something like this:

the two new A records and three pre-existing default nameservers

These changes can take up to three days to take effect. They took overnight for me.

III. Install node, homebase, and pm2 on your droplet

  1. Open terminal and access your new droplet remotely via SSH by running ssh root@IP where IP is your droplet's IP address. (So if your IP address was 138.197.100.21 you'd run ssh root@138.197.100.21)
  2. If prompted whether or not to continue, enter yes. You should now have root access to your Ubuntu droplet and may see an Ubuntu welcome screen. Your terminal will say root@name-of-your-droplet, and commands run in this terminal shell will now be run on your droplet.
  3. Configure your firewall to open ports 80 (http), 443 (https), and dat (3282) by running
    content_copy
    ufw allow proto tcp from any to any port 80,443,3282
  4. Install NVM with cURL by running
    content_copy
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
    Follow the terminal prompt, which will give you these three lines of code to run:
content_copy
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  1. Install node with NVM by running nvm install node
  2. Install homebase globally with npm by running npm install -g @beaker/homebase
  3. In order to keep homebase running as a background process (to daemonize it), you'll need to install pm2 globally with npm by running npm install -g pm2

3. Configuring homebase to seed your website.

I. Create your .well-known directory

Create a folder in your directory titled .well-known and add in it a file named dat with your raw dat address on the first line, and TTL=3600 on the second line. For example, this is this website's .well-known/dat file:


dat://6d592b82418d8b9fbb4f9c79e97cc3711649ee7abb84f6359e54e02b3b3df047/
TTL=3600
          

II. Create your .homebase.yml configuration file

Follow my instructions below or check these instructions on the official homebase repo.

  1. Create a hidden homebase configuration YAML file by running touch .homebase.yml
  2. Open the empty file with the nano editor by running nano .homebase.yml
  3. Write your configuration file. It may be easier to write it in the text editor of your choice on your computer and then paste it into the terminal. You can follow the official documentation to set up your configuration file or use mine below as a starting point and replace the following information: the url of your dat (which is seeding from your own computer), the name of the domain you'd like to mirror to, and an email address for LetsEncrypt to potentially contact you at. Here is this website's .homebase.yml file:
content_copy
directory: ~/.homebase # where your data will be stored
httpMirror: true       # enables HTTP mirroring
ports:
  http: 80             # HTTP port for redirects or non-TLS serving
  https: 443           # HTTPS port for serving mirrored content and DNS data
letsencrypt:           # set to false to disable Let's Encrypt
  email: "redacted@gmail.com" # provide your email to Let's Encrypt
  agreeTos: true       # you must agree to the LE terms (set to true)
dashboard:             # set to false to disable
  port: 8089           # port for accessing the metrics dashboard

# enter your pinned dats here
dats:
  - url: dat://6d592b82418d8b9fbb4f9c79e97cc3711649ee7abb84f6359e54e02b3b3df047 # URL of the dat to be pinned
    domains:
      - dillon.dev     # (optional) the domains of the dat
  1. When you're done, save with ctrl-O and hit enter to confirm overwrite. Then exit with ctrl-X.

III. Daemonize homebase

Make sure that you are still seeding your website with dat share from your own computer (as instructed in the very first step in this document), otherwise the droplet won't have access to your files.

  1. Run homebase. You should see something like this:

HTTP mirror, Lets Encrypt, and Dashboard are enabled, WebAPI is disabled. It says that it's serving your dat address at your domain name — see that both are correct

  1. If an error occurs that you don't understand, consult the Troubleshooting section of homebase's official docs

  2. If it works, stop it with ctrl-C and daemonize it with pm2 by running pm2 start homebase. You should see something like this:

PM2 Successfully daemonized / Starting … in fork mode (1 instance) / Done. Then there is a chart with status: online

  1. (optional) see more information about the pm2 daemon with pm2 show 0 and pm2 logs. If you need to stop the process for any reason, run pm2 stop homebase.

  2. You can now close all terminal shells, including the one seeding dat from your own computer, and the one connected to your droplet.

  3. Your website should now be seeding to https and dat (https://dillon.dev and dat://dillon.dev) but it may take up to three days for your DNS records to change.

4. Updating your website

Once your DNS records are changed, you can cd into your website's directory and run dat share at any time to instantly update your website.

Take care that a hidden .dat folder and a dat.json file live in your website's directory. Make sure to keep these with your files.