Categories
Docker Kubernetes

Composer Updates in Docker Images

I recently started to use composer-packaged applications within Docker images. But I noticed that the Docker image did not change when I rebuilt after I updated one of the module dependencies. The reason is the caching mechanism of docker builds. A very obvious solution would be the --no-cache option when building. But this is a bad solution as it would cause the complete build to make use of the cache.

Another solution I found was using ARGs that will disable the cache for a command. I personally felt this not very helpful as it would involve some awkward tweak of the build process (as I understand). So I discovered a very simple solution: the ADD command can skip the caching when using a web URL as the content to download. The command would download the content from the address and compare it to the previous cache content. We would just need a URL that returns a different content each time it is called. And luckily there is one.

So the elegant solution is to use this combination of lines in your Dockerfile and the composer modules are updated accordingly each time:

# The RUN must use cached layers, this is the hack
ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
RUN composer install \
    && chown -R www-data:www-data /var/www/html
Categories
Linux Miscellaneous Shell

Using sendmail with a Relay Host

It is useful when Docker containers can send e-mail to you in case there is an error condition that needs attention. Here is how to.

Install the sendmail package from your distribution and edit the file /etc/mail/sendmail.mc. Add this line to the end of it:

define('SMART_HOST', '<dns-name-of-your-relay')

Done! Just restart sendmail:

/etc/init.d/sendmail stop
/etc/init.d/sendmail start
Categories
Miscellaneous

Long Time No See

A long time has passed since the last post on this blog. Not because I was lazy. It was merely because there were more important things to do than writing blog posts about things that most people can look-up in the internet anyway.

However, the Open Source software projects were still going on. Not so frequent updates but once in a while. The current Corona pandemic now gives me some possibilities to finish things that were long time on my list. First and most importantly is to gain independance of hosting all my software on my own and maintaining the infrastructure for it. Still, some main parts will be on me. Such as build tools, issue tracking and automation.

However, I managed to host all my code now at GitHub. This task alone cost me about two weeks until each and every Subversion repository was migrated. I have been writing code now for more than 20 years. That’s why about 110 software projects piled up at my previous Subversion repository. Most of them are not public, only 26 can be accessed by everyone. But migrating all 110 physically took me 3 days. Another 10 days I was busy to update the CI/CD pipelines for the still active projects (around 50). And the last week passed with upgrading the Open Source projects to new software versions, documenting them, changing the workflows, upgrading build tools and writing CI/CD tools for these changes. Finally, I managed to bump up the versions of the major OSS projects – after 3 weeks of work. Most of them were API breaking. That’s why the major versions increased (Check Maven Central for an overview).

You will find updates on them here in this blog – and you will see more updates coming soon. The main changes are:

  • Upgrading to Java 9: My Java projects will not support any older runtime environment.
  • Documentation moves to GitHub along withe code and the respective version. It is still going on. So this blog will become less important for documentation and the respective sections will be removed from the menu (but still be available).
  • Development workflow will follow the Gitflow workflow model now.

Feel free to contact me for any of the projects, the new or the old ones. For the moment, I wish you all the best and stay healthy!

Ralph

PS: Of course, I will try to blog more IT stuff and more frequently than before 🙂