david alfonso

Discourse dev setup instructions

The installation steps for developing Discourse aren't updated and don't match the minimal requirements. Most are figured out easily, but some require some lookup.

Redis

For example, Redis uses Chris Lea's ppa, which doesn't contain packages for Ubuntu 22.04 (jammy). If you had already added it, remove it like this:

sudo add-apt-repository --remove ppa:chris-lea/redis-server

and add the official Redis Apt repo:

curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update

This repository contains the most recent stable versions of Redis, which can be listed with:

apt-cache policy redis

And installed with:

# This is the latest 7.2.x available, which is supposedly
# compatible with Discourse.
sudo apt-get install redis=6:7.2.4-1rl1~jammy1

# Enable it
sudo systemctl daemon-reload
sudo systemctl enable redis-server
sudo systemctl start redis-server

Miscelanea

There's also oxipng, which can be easily installed using Rust's cargo:

cargo install oxipng@8.0.0

Once inside the discourse source folder, there are some more things to do beyond those described in the instructions:

Now we can run all those bundle commands without errors.

Mailpit

Finally, because MailHog seems to be abandoned, I went for Mailpit and installed it with Docker, using some specific options to avoid dealing with authentication in a local environment:

docker run -d \
    --restart unless-stopped \
    --name=mailpit \
    -v /var/mailpit:/data \
    -e MP_DATA_FILE=/data/mailpit.db \
    -e MP_SMTP_AUTH_ACCEPT_ANY=1 \
    -e MP_SMTP_AUTH_ALLOW_INSECURE=1 \
    -p 8025:8025 \
    -p 1025:1025 \
    axllent/mailpit