{"id":1526,"date":"2019-07-22T17:55:32","date_gmt":"2019-07-22T17:55:32","guid":{"rendered":"https:\/\/the-plot.com\/blog\/?p=1526"},"modified":"2021-10-23T17:22:33","modified_gmt":"2021-10-23T17:22:33","slug":"containerising-the-plot","status":"publish","type":"post","link":"https:\/\/the-plot.com\/blog\/?p=1526","title":{"rendered":"Containerising The Plot"},"content":{"rendered":"\n<p>A couple of months ago, what should have been a routine upgrade via the WordPress UI started alarm bells going off: fail2ban was complaining about the version of PHP I was using. My attempt to update PHP turned into a can of worms, because the version of Debian that I use on the vm for hosting was pretty old. I thought it would be an interesting learning exercise to build out a new vm for the upgrade using Docker [and Docker compose] for WordPress, MySQL, PostFix and Dovecote. &#8216;Interesting&#8217; turned out to be &#8216;quite a lot of work&#8217;.<\/p>\n\n\n\n<p>I didn&#8217;t use the stock WordPress container: there are a few customisations that I wanted to add, and which [at the time] seemed a bit tricky to shoehorn in.<\/p>\n\n\n\n<p>The main thing I wanted to do was to get a certificate from LetsEncrypt on startup; I&#8217;ve created a cron which <em>should<\/em> request a replacement cert every month; I also have a pretty nasty script which scans the Apache log files for people trying to break in, and adds them to iptables [I was never convinced that fail2ban was working as intended]. That&#8217;s another cron job, which runs every half hour. I&#8217;ve also added in a few utilities for debug. Finally, I have some static content &#8211; a pretty large galleries directory &#8211; which lives outside WordPress, and which I need to copy across.<\/p>\n\n\n\n<p>There is a very heavily starred container &#8211; docker-mailserver &#8211; which took care of Dovecote and PostFix; it&#8217;s fantastic. I&#8217;ve configured it to mount in the volume where the WordPress certificate lives. I&#8217;ve noticed that its fail2ban is configured in turbo-facist mode: I initially couldn&#8217;t understand why I couldn&#8217;t connect to the server from my laptop. fail2ban had immediately blocked our public IP when it hit the server with an old password from my phone.<\/p>\n\n\n\n<p>One other gotcha was around port exposure. I obviously didn&#8217;t want to map the MySql port to the outside world, but I got stuck at the WordPress install page that asks for the database details. I finally figured out that I needed to refer to server by its container_name.<\/p>\n\n\n\n<p>There is a balancing act in terms of what to bake into the container. My it&#8217;s-exploded-and-I-need-to-start-from-scratch approach is to build my WordPress docker image; deploy it using docker compose; then import a backup using the All-In-One plugin. I had a bit of a think over whether or not to bake that in as well in but decided against it. While I could wget it [the same way I do with WordPress itself], it would have to be a reference to a particular version rather than the latest.<\/p>\n\n\n\n<p>So my WordPress container isn&#8217;t exactly a work of art: it&#8217;s pretty flabby, with all of the nonsense I [tell myself I] need. In some performance testing, I also noticed that WordPress returned its results considerably slower than the hand-rolled equivalent. It&#8217;s hardly surprising: this is running on OVH&#8217;s cheapest vm and, with 3 containers running it has a fair bit on its mind.<\/p>\n\n\n\n<p>Anyway, if you actually know anything about Docker, you can amuse yourself with my efforts <a href=\"https:\/\/github.com\/zogspat\/the-plot-docker\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of months ago, what should have been a routine upgrade via the WordPress UI started alarm bells going off: fail2ban was complaining about the version of PHP I was using. My attempt to update PHP turned into a &hellip; <a href=\"https:\/\/the-plot.com\/blog\/?p=1526\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,5],"tags":[],"class_list":["post-1526","post","type-post","status-publish","format-standard","hentry","category-cloud","category-tech"],"_links":{"self":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1526"}],"version-history":[{"count":2,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1526\/revisions"}],"predecessor-version":[{"id":1528,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1526\/revisions\/1528"}],"wp:attachment":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}