Docker instance: transition from Trusty to Xenial base Ubuntu image

Hello,

Yes, the Docker images do have the “-DENABLE_LUA_MODULES=ON” compilation flag.

You can find more information in the two following threads:
https://groups.google.com/d/msg/orthanc-users/C9HfrMat3FQ/H9yeYlqxBwAJ

https://groups.google.com/d/msg/orthanc-users/Y1HAGTnx9Cs/MhdYmWIiGAAJ

Sébastien-

Thanks, Sebastien.

I should clarify my request. I realize you’ve added the compilation flag to your Docker images, but I was wondering about the Osimis images.

From our last exchange last year, I thought that Alain was going to add the compilation flag to the Osimis images. Since I’ve had trouble with the most recent Osimis image, I wondered where I could look to see whether the flag was turned on.

I thought that maybe sometimes the compilation flag is on and sometimes it’s not - and that would be documented somewhere in the documentation for the Osimis docker images.

I’ll try your sample Lua snippet to test the Osimis image.

John.

Contrarily to last year, both “jodogne/orthanc” and “osimis/orthanc” images are now based upon the same Linux Standard Base (LSB) binaries. So, they should have the same behavior wrt. Lua modules.

Sébastien-

Thanks for the clarification.

I’m going to have to dig deeper into my lua script to determine why it’s failing to load a system installed module.

John.

FYI, here’s the Docker file of the osimis/orthanc docker image: https://bitbucket.org/osimis/orthanc-builder/src/master/docker/orthanc/Dockerfile

I thought I would document some of what I’ve been attempting to do. I don’t expect an answer at this point, unless anyone has helpful hints. I’ve got a pretty sophisticated set of Lua scripts running on Orthanc. So I realize I’m pushing the capability. Ultimately, I’m going to rewrite the functionality to use the RestAPI outside of Orthanc, rather than the native Lua. But for the moment, I’m stuck with my complicated Lua Scripts.

I’m probably running into the similar lua version problems as discussed in the thread on the lua socket module. In my case, I’m working with the luasql-postgres to make calls to the same backend postgres server I’m using for Orthanc’s postgres index. In the Osimis images of the last year, my calls to connect to the remote database simply fail with very little error reporting - even with Orthanc run in verbose mode.

I can install lua5.3 on the host system (docker container) and produce the same errors loading the luasql-postgres module. So, this really does seem to be a lua5.3 vs luasql-postgres 5.1/2 issue than an Orthanc lua problem. The trick is figuring out how to get the host lua to work with the 5.3 lua compiled into Orthanc.

As near as I can tell, that luasql-postgres module is supported by the ubuntu distributions (<=16) and available for apt-get install up to Lua 5.2, but not 5.3. At some point, I guess the internal Orthanc Lua evolved to 5.3 and then stopped working well with the older Lua 5.1 extensions. I think the base Docker image I’ve been using that still works dates back to late 2017.

I tried installing the luasql-postgres module with luarocks. Luarocks sort of worked and compiled luasql-postgres, but not quite, with the module crashing during actual Lua execution with complaints about missing symbols in the dynamic link library. I suspect there might be some version conflict between the host (ubuntu 16 docker based Osimis Orthanc) and luarock’s installed version of luasql-postgres, but I’m not sure.

Compiling luasql-postgres completely from scratch isn’t all that appealing, since I’m working from within docker containers. I’m not so keen on installing the compilation infrastructure necessary to pull this off, only to then have to strip it out to reduce the docker container size back to a reasonable size.

Following Sebastien’s suggestions in that socket thread, I took the Osimis Dockerfile and attempted to modify it to build on top of ubuntu 18.04 since bionic has direct (apt-get) support for the luasq-postgres plugin for lua 5.3. Everything seemed to build ok, except that when I attempt to start the Orthanc container I get an error during boot

"SQL error: ERROR: syntax error at or near “ASSERT”
LINE 32: ASSERT studyKey IS NULL;

This seems to arise from a postgres sql file used when Orthanc selects the postgres backend for its indexing (which is what I do). I can only guess that moving to Ubuntu bionic 18.04 was too much for the Osimis build combined with my use of Postgres. Granted, the Osimis build has grown a lot more sophisticated and it’s possible I might not be turning off some plugin that’s causing a problem here. The above postgres error comes right after Orthanc reporting “Installing the CreateInstance extension”.

Again, I’m not expecting a solution here. I think it’s probably a lot to expect all the new things (the OS, luasql and Osimis) to play nice together.

John.

Hello,

I recognize this error message:

"SQL error: ERROR: syntax error at or near “ASSERT”
LINE 32: ASSERT studyKey IS NULL;

It happens when using an older version of PostgreSQL server (I have seen this on Ubuntu 14.04). It has been fixed by the following changeset that is pending in the mainline of the PostgreSQL plugin:
https://bitbucket.org/sjodogne/orthanc-databases/commits/b559af8fe6e0b393d646f4ed9105326b44482044

So, I think that everything is fine in your Lua setup (luasql-postgres is loaded fine). Give a try upgrading your PostgreSQL server.

HTH,
Sébastien-

I updated my Postgres (9.4) Docker image. Looking at the Dockerfile on dockerhub, Postgres 9.4 is now based on debian/slim instead of Ubuntu.

I still see the error when I launch Orthanc, but I’m assuming I need to wait for the changes to make their way into mainline in order for the Osimis Dockerfile build (that I modified to point to Ubuntu 18) to work? I’m working with the Dockerfile Alain provided a link to earlier in the thread.

I could also look into what’s required to migrate my actual database from 9.4 to some later Postgres version if that would work.

Thanks for your suggestion,
John.

Hi John,

since you’re building the Docker image yourself, you can download the latest mainline PG SQL server binary from http://orthanc.osimis.io/lsb/plugin-postgresql/changesets/b559af8fe6e0/libOrthancPostgreSQLIndex.so

Woo! Progress!

At least the Orthanc comes up now and seems to be using some of the Lua system libraries I installed for my lua script.

I also pulled the postgre storage plugin from the same link location.

Returning to an old topic, I’ve been working on upgrading my Orthancs to the latest osimis/orthanc and running into the problem of loading externally installed Lua modules again.

I’m working with 1.9.6 at the moment. Was the ENABLE_LUA_MODULES=ON compiler option defined?

Is there a way to determine what compiler flags were used to compile the Orthanc in these docker images? I was poking around the source code repository as well as the docker images repository and couldn’t find anything, though I’m not quite sure where to look.

Thanks,
John.

Hi John,

The cmake command that is used to compile Orthanc in the osimis/orthanc docker images is available here: https://bitbucket.org/osimis/orthanc-builder/src/fbef8e045b6003ec06a281fb7d3f8ad3a0ae2af1/docker/orthanc/Dockerfile#lines-8

This build option is set to OFF by default: https://hg.orthanc-server.com/orthanc/file/tip/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake#l56

Honestly, I’m not very familiar with that part of the code. I read that this option is only meaningful if using the STATIC build of the lua engine. Note that the docker image now contains a DYNAMICALLY linked version of Orthanc but I don’t know what it means wrt lua engine. Could you check on your side if the system lua modules can be loaded with this version of Orthanc ?

Best regards,

Alain

Ugh. I just wrote a long reply detailing my efforts, hit send and it seems to have gone nowhere.

Thanks for your response.

I looked at the CMAKE file and I think my solution lies somewhere between setting appropriate environmental LUA_CPATH/LUA_PATH variables and needing to compile Orthanc with modules enabled.

If I explicitly add a Lua command line interpreter to the container and then shell into the container, run Lua (outside of Orthanc API), and attempt to load the modules I installed (ex. lua-sql-postgres), everything works. If I make the same call via the RestAPI, it fails - as though I’ve either got the wrong CPATH/PATH variables set for Lua to find the installed modules OR external modules are currently turned off by compiler flag in Orthanc.

I’m attempting to figure out which of those is the case or maybe it’s something else.

It would be nice to confirm that Orthanc Lua is running Lua 5.3. That seems to be the case, but it’s not explicitly set by the compilation flags that you sent me.

Thanks,
John.

Duh! (Smacks forehead!) My bad.

I found my problem. In transitioning from the old Osimis/Orthanc I was using, I was moving from the old environmental variable settings (ex. PG_USER for the postgres user) to the new naming convention for environmental variables (ex. ORTHANC__POSTGRESQL__USERNAME).

I had forgotten to update my Lua scripts to reflect the change in naming convention. Thus, it was failing due to using the wrong or absent credentials rather than failing to load the postgres Lua module.

So, to recap, things seem to be working with external Lua modules. Additionally, I found I no longer have to play with the LUA_CPATH or LUA_PATH variables to get things to work. I only need to modify the original osimis/orthanc image to apt-get install the modules I want and rely on the default LUA path.

Thanks again for pointing me to the cmake repository.

John.