Last time I've written about using Huginn. I have never actually used Docker before, but I've decided to give it a go. I'm hosting various pieces of software on my server, which run on anything from Go to PHP. And given my few, but all the more unpleasant experiences with Ruby, I'd decided that I'd rather move most of my software to Docker than try to install yet another stack on my server.
So yeah, you could say this XKCD strip summarizes my intentions with Docker perfectly.
The setup itself wasn't difficult. Huginn even lets you try it out very easily, by just running
docker run -it -p 3000:3000 huginn/huginn
which just starts it up at port 3000. However, that includes a database, and you'd lose data any time you'd change your container. Great for testing, not so great for actual deployment.
So I've created a network with Huginn and MariaDB in it, and a volume to keep the data in, then mostly jsut tweaked the environment vars. I've gone with the
docker stack command, so I've saved my file as
stack.yml and then ran it with
docker stack deploy -c stack.yml stackName.
I've ended up with something like this. (Note I'm using the great Mailgun service for outbound e-mails; they're easy to use, provide an API and an SMTP server for sending e-mails, and are free for my meager mail volumes.)
version: '3' services: mariadb: image: mariadb deploy: restart_policy: condition: any ports: - "3306:3306" networks: - mynetwork environment: - MYSQL_ROOT_PASSWORD=super secret password #1 volumes: - "mariadb_data:/var/lib/mysql" huginn: image: huginn/huginn deploy: restart_policy: condition: any networks: - mynetwork ports: - "3000:3000" depends_on: - "mariadb" environment: - SMTP_DOMAIN=smtp.mailgun.org - SMTP_USER_NAMEfirstname.lastname@example.org - SMTP_PASSWORD=smtpPassword - SMTP_SERVER=smtp.mailgun.org - APP_SECRET_TOKEN=secretAccessToken - DOMAIN=huginn.domain.com - DATABASE_ADAPTER=mysql2 - DATABASE_ENCODING=utf8mb4 - DATABASE_RECONNECT=true - DATABASE_NAME=huginn - DATABASE_POOL=20 - DATABASE_USERNAME=huginn - DATABASE_PASSWORD=super secret password #2 - DATABASE_HOST=mariadb - DATABASE_PORT=3306 - DO_NOT_SEED=true - EMAIL_FROM_ADDRESSemail@example.com - INVITATION_CODE=super secret password #3 - REMEMBER_FOR=40.weeks - IMPORT_DEFAULT_SCENARIO_FOR_ALL_USERS=false - USE_GRAPHVIZ_DOT=dot - TIMEZONE=Bratislava networks: mynetwork: volumes: mariadb_data:
While Huginn itself runs very smoothly, I've had a few issues. Luckily, the devs at Github always helped out with their resolution.
I've created the database manually, then configured Huginn to use it. It went something like this:
CREATE USER 'huginn'; CREATE DATABASE huginn CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON huginn.* TO huginn@'%' IDENTIFIED BY 'super secret password #2';
You may notice a few flags: for instance, I'm setting
true. There was a bug (if I recall correctly; it's been a few months) when I updated the image and restarted Huginn, it tried to seed the DB with the Admin account, which was already there, and that caused an error. This resolved the problem.
A related thing: I've set
false. By default, Huginn creates a default scenario with a few sample agents for each new user. I've done my experimenting already on a test instance, so I've just exported that and didn't want the hassle of having to delete everything manually.
I've encountered another problem when I'd tried to use a scheduler to trigger an e-mail digest. There's room for improvement there; the scheduler is not easy to debug. I'd at least welcome an information display that'd say when the next execution will be, that would help diagnose any issues.
After a while I'd noticed the mail is sent every other day as expected, but at a weird hour; that lead me to believe it's a timezone issue. After looking around and asking, I've tried to set
TIMEZONE to Europe/Bratislava. Not only did that not work, but it also somehow screwed up the visualization of my Agent diagram - where there once was a nice, interactive view, I now only had an ugly PNG.
After someone else shared their config with me, I've found the solution: force the Graphviz method of visualization, and use just the city name for timezone.
- USE_GRAPHVIZ_DOT=dot - TIMEZONE=Bratislava
Since most of the software I host is only used by me, and maybe occasionally a friend or two, I always have to figure out how to make it private and disable registrations. Huginn solves this nicely: I can leave registrations open, but require a secret
INVITATION_CODE. I also like my systems to keep me logged in, so I've bumped up the
That's about it. So far I'm quite satisfied with Huginn and intend to use it for more workflows in the future.