Adam K Dean

Setup your own persistent web IRC client

Published on 16 March 2020 at 14:28 by Adam

These days, Slack is all the rage, but in years gone by, whenever facing world-changing events, IRC has been the place to hangout. These days, you don't seem to hear much about it, and when you try and introduce people to it, the old and somewhat dated clients are hard to sell.

I've used all manner of clients over the years. I think I started with mIRC back in the early 00s, and over time I've used bouncers (these are services that keep you connected to a network which you in turn connect to) and command line clients. The last client I used was an online cloud based IRC client named irccloud. It's great, but it's a few quid a month.

Recently, an online acquaintance setup an IRC server, to help folks working remotely, to have somewhere outside of Twitter to discuss current affairs etc. World changing event in place, I needed an IRC client, a persistent one.

The Lounge

I had a look around and found thelounge. The name doesn't do much for me. I'm not a fan of the word the in a name, but it's okay, breath Adam. The easiest way to test something like this is to spin up an instance. So I went to Scaleway and created a small machine for €2.99/mo, grabbed the IP and setup a domain, let's say irc.example.com. (Setting up the domain simply means creating an A record that points to the IP address of your server.)

Setup

On the server itself, the only setup we need is to install docker.

# apt update
# apt install docker.io -y

... Done

Once we have docker, we'll spin up an automatic reverse proxy service along with an automatic LetsEncrypt certificate generation service. It's super simple, and to learn more, read this award winning article about it right here on dev: Automatic SSL with Let's Encrypt & Nginx.

First, the nginx proxy.

docker run \
  --detach \
  --restart always \
  --publish 80:80 \
  --publish 443:443 \
  --name nginx-proxy \
  --network service-network \
  --volume /var/run/docker.sock:/tmp/docker.sock:ro \
  --volume nginx-certs:/etc/nginx/certs \
  --volume nginx-vhost:/etc/nginx/vhost.d \
  --volume nginx-html:/usr/share/nginx/html \
  jwilder/nginx-proxy

Then the letsencrypt companion service.

docker run \
  --detach \
  --restart always \
  --name nginx-proxy-letsencrypt \
  --network service-network \
  --volume /var/run/docker.sock:/var/run/docker.sock:ro \
  --volume nginx-certs:/etc/nginx/certs \
  --volume nginx-vhost:/etc/nginx/vhost.d \
  --volume nginx-html:/usr/share/nginx/html \
  --env NGINX_PROXY_CONTAINER="nginx-proxy" \
  jrcs/letsencrypt-nginx-proxy-companion

Now we're ready to setup the IRC service. It's so easy.

docker run \
  --detach \
  --restart always \
  --name irc \
  --network service-network \
  --env VIRTUAL_HOST=irc.example.com \
  --env LETSENCRYPT_HOST=irc.example.com \
  --env LETSENCRYPT_EMAIL="webmaster@example.com" \
  --volume ~/.thelounge:/var/opt/thelounge \
  thelounge/thelounge:latest

Configuration

Well that was easy. Now we can head to https://irc.example.com and be met with the initial sign in screen. But, first, we need to configure it and create a user. To do this, on the server, take a look inside the ~/.thelounge/ directory (which maps into the container). You'll see a few files and directories in there. You can read more about the configuration in the thelounge documentation.

You can, if you like, modify the server settings. You do this by editing config.js. The only option I changed here was the channel leave message leaveMessage which defaults to "The Lounge - https://thelounge.chat", which I changed to "".

The main thing to do is to create a user. For this, we need to use the thelounge binary. Easiest way to do that is to hop into the container, so let's do that.

# docker exec -ti 93a08 bash

root@93a08cb52985:/#

Now to create a user we simply run thelounge add yournamehere.

root@93a08cb52985:/# thelounge add example

2020-03-16 13:52:12 [PROMPT] Enter password: *types dogsarebetterthancats*

2020-03-16 13:52:48 [INFO] User example created.
2020-03-16 13:52:48 [INFO] User file located at /var/opt/thelounge/users/example.json.

There may be some additional logging, some warnings, but don't worry about that. You can now login with those credentials at https://irc.example.com and proceed to add networks, setup your IRC users, and so forth. When you open the site, you'll be able to browse your IRC networks. And when you leave, you'll remain connected via this service. This is important because with IRC, if you're not in the channel, you won't get messages.

Now, that's done, welcome to the real social network(s).



This post was first published on 16 March 2020 at 14:28. It was filed under archive with tags tutorial, beginners, social, docker.