AWS S3 plugins

Hello everyone,

→ I compiled the AWS plugin provided by osimis and by following instructions from orthanc book.
→ I have a “libOrthancAwsS3Storage.so” file (symlink to “libOrthancAwsS3Storage.so.mainline”) that I export to my host (to avoid to rebuild each time the plugin).
→ After that, I created a new image derived from orthanc:1.9.6, putted the .so file in /usr/share/orthanc/plugins/ and the Dockerfile was inspired from orthanc-plugins:1.9.6.

  1. If I don’t install libraries, the container fails with “Error libcurl.so.4: cannot open shared object file: No such file or directory”
    So I installed all needed libraries.

  2. With all libraries installed, the container fails with “free(): invalid pointer”
    Dockerfile:


FROM jodogne/orthanc-plugins:1.9.6
RUN apt-get -y update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install wget nano build-essential unzip cmake mercurial uuid-dev libcurl4-openssl-dev liblua5.1-0-dev libgtest-dev libpng-dev libsqlite3-dev libssl-dev libjpeg-dev zlib1g-dev libdcmtk2-dev libboost-all-dev libwrap0-dev libcharls-dev libjsoncpp-dev libpugixml-dev libcrypto++-dev && apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --chown=root ./plugins/libOrthancAwsS3Storage.so /usr/share/orthanc/plugins/
VOLUME [ "/var/lib/orthanc/db" ]
EXPOSE 4242
EXPOSE 8042

ENTRYPOINT [ "Orthanc" ]
CMD [ "/etc/orthanc/" ]

# https://groups.google.com/d/msg/orthanc-users/qWqxpvCPv8g/Z8huoA5FDAAJ
ENV MALLOC_ARENA_MAX 5

I am not sure what I did wrong. Before to go to a big image with orthanc and plugins compiled, if someone has an idea :slight_smile:

thanks in advance

Stephan Hahn

Dear Stephan,

I think your issue is that you are mixing Linux Standard Base (LSB) binaries with non-LSB binaries. Here is an older post about this topic:
https://groups.google.com/g/orthanc-users/c/GDWUsHRQbdU/m/8L-IcqjWAAAJ

You should try and compile Orthanc from sources instead of deriving from “jodogne/orthanc:1.9.6” (as the latter image contains the LSB binaries of Orthanc).

Note that this situation has been improved a few days ago:
https://groups.google.com/g/orthanc-users/c/gEb9tQVO2dE/m/BiIZSiM_AwAJ

This patch was backported to “jodogne/orthanc:1.9.6”, so you might simply have to update your Docker images by typing the following command line:

$ docker pull jodogne/orthanc:1.9.6

HTH,
Sébastien-

Dear Sébastien

thanks . It is working perfectly.

Stephan Hahn

Hello Stephan,

A docker multistage build can be used in order to avoid huge image size and useless docker layers (read here how to):
For example, Dockerfile:

FROM ubuntu:18.04 as plugins-compiler

Steps:
– Plugins compiler image
----> install deps, prepare environment
----> compile aws cpp sdk (only s3-transfer)
----> compile orthanc cloud storage aws s3 plugin (how to)
– Final orthanc image
----> copy shared libraries deps from previous image
----> copy aws so from previous image

Inside plugins-compiler you must prepare the environment for the compilation, install required linux packages etc…
After the compilation, you must copy the binaries from image ‘plugins-container’ to final orthanc docker image.
In order to resolve shared dependencies, as workaround you can copy whole ‘/usr/local/lib’ from ‘plugins-compiler’:

COPY --from=plugins-compiler /usr/local/lib /usr/local/lib/

AWS plugin ‘.so’ must also pe present, for example:

COPY --from=plugins-compiler /plugins/libOrthancAwsS3Storage.so /usr/share/orthanc/plugins-disabled/libOrthancAwsS3Storage.so

Remarks:

  • in my case, vcpkg cryptopp was not enough, so the install command look like : ./vcpkg/vcpkg install cryptopp cpprestsdk boost
  • if you run in troubles with shared libraries, you can check the aws compiled ‘.so’ requirements using ldd: ldd /plugins/libOrthancAwsS3Storage.so
  • building inside docker is a very good practice because the environment is isolated and the build process can be easily reproduced, also docker builds is caching every layer, so in case of a retry, untouched layers are cached (save time and money :d )

Good luck!
Alex

Hi Alex

yes this one also works :slight_smile:
I am debugging for the moment. Will optimise dockerfiles in next steps. Thanks for the advices :wink: I will follow your suggestions.