We often use the Memcached extension in our Lucee applications, and since it’s not bundled with Lucee core then we need a simple way of installing it as part of a Docker build.
Lucee 5.x supports installing extensions via system properties (and by convention these also work via environment variables, by using an
_ in the environment variable name in place of the
. in the system variable name) using a comma separated list of extension IDs. This means that we can add a line like this to our
Dockerfile to install the latest Memcached and H2 extensions, respectively;
ENV LUCEE_EXTENSIONS "16FF9B13-C595-4FA7-B87DED467B7E61A0,465E1E35-2425-4F4E-8B3FAB638BD7280A"
These extension IDs are found on the Lucee extensions download page:
However, let’s say that we need to install version
22.214.171.124 of the Memcached extension because we’ve found a bug in
126.96.36.199 that is causing a problem for us in production. There is another way to install Lucee extensions which is to drop them into the Lucee server
deploy directory. In our
Dockerfile, instead of using the line with the environment variable, we can use wget to download the specific version of the Memcached extension and place it in the appropriate directory;
RUN wget -nv http://extension.lucee.org/rest/extension/provider/full/16FF9B13-C595-4FA7-B87DED467B7E61A0?version=188.8.131.52 -O /opt/lucee/server/lucee-server/deploy/extension-memcached-184.108.40.206.lex
I figured this might be a good workaround, however during the next startup of Lucee after the build (the build starts and stops Tomcat to “prewarm” the installation and ensure that Lucee starts up quickly), I see the following output in the console which shows that Lucee is downloading and installing version
220.127.116.11 of the extension rather than the
18.104.22.168 that I had previously downloaded;
fandango_1 | 12-May-2017 15:35:13.538 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2021 ms fandango_1 | start set instrumentation fandango_1 | sun.misc.Launcher$AppClassLoader fandango_1 | sun.misc.Launcher$AppClassLoader fandango_1 | sun.misc.Launcher$AppClassLoader fandango_1 | found memcached.extension-22.214.171.124.jar:false fandango_1 | download memcached.extension:126.96.36.199 from http://release.lucee.org/rest/update/provider/download/memcached.extension/188.8.131.52/?webId=965a7cd80d6c48e6c4d3bc4d4732ab20&webSecurityKey=043c7cc5-09ef-4718-ba07-281536ca0fc5&serverId=4bb321329fb282ecb82a59805be1d76d&serverSecurityKey=979b0968-fc36-42fa-847f-9529f2ff666d&allowRedirect=true and copy to /opt/lucee/server/lucee-server/bundles/memcached-extension-3-0-2-29.jar
This raises a couple of questions, and possible feature enhancements;
1) Can we add support for installing specific versions of Lucee extensions via the LUCEE_EXTENSIONS environment variable (and system property), so that we can more easily produce repeatable builds if we need to? for e.g.
ENV LUCEE_EXTENSIONS "16FF9B13-C595-4FA7-B87DED467B7E61A0?version=184.108.40.206"
2) Does the above “automatic upgrade” of the extension to a newer version after Lucee startup happen for a reason, for example is it because 220.127.116.11 is incompatible with Lucee 5.2.x. and so it needed to download 18.104.22.168 to function correctly? Is there any hidden dependency rules that we might need to know about? Or was Lucee just downloading a new version of the extension because it was found?
3) Is there some kind of flag that we can toggle so that Lucee never tries to automatically download newer versions of extensions? Automatic updates would be particularly problematic if you happened to restart a Lucee container in production and it downloaded a newer extension that broke your application. I would want any Lucee server to default to not automatically downloading newer versions of extensions after a restart – once the extension is installed (or a specific version is intended to be installed by placing it in the
deploy directory) the version should stay the same until you choose to upgrade it.
For now we’re fine using the latest version of the Memcached plugin, but a way to manage these versions and produce fast, repeatable Docker builds, while avoiding unexpected extension updates, is very important to us Perhaps we could target some of these things for Lucee 5.3.x?