Deploy Forem on Digital Ocean and build your tech community

Deploy Forem on Digital Ocean and build your tech community


This tutorial is the continuity of the previous one where we want to self-host Forem, the open-source blog, to build a community. The last tutorial shows how to deploy From on AWS, and if you are here, you probably want to deploy it on Digital Ocean. You must follow this tutorial before continuing with this one.

Deploy Forem on AWS and build your tech community
Forem is an open-source software for building communities. In this post, we will see how to self-host an instance on AWS and Digital Ocean.

Generate the SSH key

Run the command below:

ssh-keygen -t ed25519 -C ""

This creates a new ssh key, using the provided email as a label. Don't forget to replace the email address with your own.

When you're prompted to "Enter a file in which to save the key" press Enter. This accepts the default file location. Copy the default location that is in your terminal. ex: ~/.ssh/id_ed25519

Generate the SSH key.

After you have saved the file, you can change its location to ${HOME}/.ssh/forem with the following command:

cp ~/.ssh/id_ed25519 ~/.ssh/forem
cp ~/.ssh/ ~/.ssh/

Install Ansible collection for AWS

ansible-galaxy collection install community.digitalocean

Install Digital Ocean CLI

The Digital Ocean CLI is called doctl; it helps you perform tasks on your digital ocean through the terminal. This is great when you want to automate things inside a CI/CD pipeline or in an Ansible playbook, as in our case. Run the commands below to install doctl

dnf install wget -y


tar xf doctl-1.70.0-linux-amd64.tar.gz

mv doctl /usr/local/bin

Verify the installation succeed with doctl version

Generate Digital Ocean access token

Follow the instructions of this page: Create DigitalOcean Auth Token

Once you have the access token, let's authenticate with from the doctl

doctl auth init --access-token <digital_ocean_access_token>

# verify we are logged in successfully
doctl account get

You will get the following output:

Update Droplet instance settings

In the file playbooks/providers/digitalocean.yml, locate the following variables and update them based on your needs:

forem_do_region: nyc3
forem_do_size: s-2vcpu-2gb
  • forem_do_region: the DigitalOcean region used to set up your Forem server. The default region is nyc3 which is in New York City, New York, USA
  • forem_do_size: the Droplet size. The recommended size is s-2vcpu-2gb, with 2 Shared CPUs, 2GB of RAM, a 60GB SSD disk, and 3TB of outbound transfer.

Save and exit.

Run the Ansible playbook

Run the DigitalOcean provider playbook to set up your Forem

ansible-playbook -i inventory/forem/setup.yml playbooks/providers/digitalocean.yml

Note: DigitalOcean does not have support for Fedora CoreOS. We have to upload a custom image to your account via Ansible. If the "Wait for fcos-{{ fcos_download_release }} to be created" task times out. Please check the Custom Images section on your DigitalOcean account to see if your image is still in a pending state. Wait for it to finish processing and re-run the DigitalOcean provider playbook.

Configure the DNS Zone

We need to create a DNS record of type A that points the subdomain to the EC2 instance IP address where Forem is installed. This IP address is printed at the end of the Ansible playbook execution.

Go to your domain name provider and look at how to do that. My domain name is registered at OVH.

Wait for the DNS to propagate completely. You can check the propagation status on this website:

Restart the Web server service

Connect to the server through SSH using the private key:

ssh -i "~/.ssh/id_rsa" core@<server_public_dns>

Once connected, run the command below:

sudo systemctl restart forem-traefik.service

First connection to Forem

Navigate to your subdomain URL, in my case:; you will see a beautiful webpage. Please see the Forem Admin documentation located here for more information on setting up your Forem.

Create the first admin user.
Create the first admin user.

Provide information to create the admin user and submit. You will be redirected to a page to add basic information about the community.

Configure Forem settings
Configure basic settings

Define the settings as you want and click on finish

Forem configured successfully ?.

Yay! You are all set. You can continue writing your first article.

Forem Control (foremctl)

Since Forem is now running on your server, you will need to perform some tasks often to check the health, restart, update the version, etc...

foremctl is a helper script you can use to control your Forem via CLI.

$ foremctl help

Usage: foremctl {console|deploy|help|rake|restart|start|stat|status|stop|update|version}

console         Open a Rails console
deploy          Updates and deploy the most current version of Forem
help            Show this message
rake            Run a rake task
restart         Restart Forem
start           Start Forem
stats           Show CPU, RAM, Disk IO usage of the Forem containers
status          Show the current running Forem containers
stop            Stop Forem
update          Updates Forem to the lastest container
version         Shows information on the current running version of Forem

Update Forem to the latest version and restart

sudo foremctl deploy

Note: The deploy process causes a small downtime while the Forem code restarts.

Going Further

There are many other commands you can run to manage your Forem application. To learn more, check out this repository on GitHub.

GitHub - forem/selfhost: Selfhost your Forem Community on your own infrastructure ?
Selfhost your Forem Community on your own infrastructure ? - GitHub - forem/selfhost: Selfhost your Forem Community on your own infrastructure ?

Follow me on Twitter or subscribe to my newsletter to not miss the upcoming posts and the tips and tricks I share every week.

Happy to see you soon ?