Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Dockerfile by adding libpugixml1v5 #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MauroLeidi
Copy link

After building the image and trying to use the library I encounter an error: (step to reproduce)
% docker build -t siemens_to_ismrmrd_image .
% docker run -it siemens_to_ismrmrd_image /bin/bash
root@e8fb57b6c3b9:/# siemens_to_ismrmrd
siemens_to_ismrmrd: error while loading shared libraries: libpugixml.so.1: cannot open shared object file: No such file or directory

I fixed the error by adding libpugixml1v5 in the second stage of the building process. Now running the same code results in:
% docker build -t siemens_to_ismrmrd_image .
% docker run -it siemens_to_ismrmrd_image /bin/bash
root@c5f0bf7c81bb:/# siemens_to_ismrmrd
Missing Siemens DAT filename
Allowed options:
-h [ --help ] Produce HELP message
-v [ --version ] Prints converter version and ISMRMRD version
-f [ --file ]
-z [ --measNum ]
-Z [ --allMeas ]
-M [ --multiMeasFile ]
--skipSyncData <Skip syncdata (PMU) conversion>
--attachTrajectory
-m [ --pMap ]
-x [ --pMapStyle ]
-o [ --output ]
-g [ --outputGroup ]
-l [ --list ]
-e [ --extract ]
-X [ --debug ]
-F [ --flashPatRef ]
-H [ --headerOnly ] <HEADER ONLY flag (create xml header only)>
-B [ --bufferAppend ]
--studyDate <User can supply study date, in the format of
yyyy-mm-dd>

@cenarius1985
Copy link

te dejo mi dockerfile:

Primera fase: ismrmrd_base

FROM ubuntu:22.04 as ismrmrd_base

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Chicago

Instalar las dependencias necesarias, incluidas las bibliotecas de desarrollo y herramientas de compilación

RUN apt-get update && apt-get install -y git cmake g++ libhdf5-dev libxml2-dev libxslt1-dev libboost-all-dev xsdcxx libxerces-c-dev libtinyxml-dev libpugixml-dev libhdf5-serial-dev h5utils hdf5-tools

RUN mkdir -p /opt/code

Crear directorio para siemens_to_ismrmrd y copiar el contenido

RUN mkdir -p /opt/code/siemens_to_ismrmrd
COPY . /opt/code/siemens_to_ismrmrd/

Clonar y compilar la biblioteca ISMRMRD

RUN cd /opt/code &&
git clone https://github.com/ismrmrd/ismrmrd.git &&
cd ismrmrd &&
git checkout $(cat /opt/code/siemens_to_ismrmrd/dependencies/ismrmrd | xargs) &&
mkdir build &&
cd build &&
cmake .. &&
make -j $(nproc) &&
make install

Compilar el convertidor siemens_to_ismrmrd

RUN cd /opt/code/siemens_to_ismrmrd &&
mkdir build &&
cd build &&
cmake .. &&
make -j $(nproc) &&
make install

Crear un archivo comprimido con las bibliotecas de ISMRMRD para la siguiente fase

RUN cd /usr/local/lib && tar -czvf libismrmrd.tar.gz libismrmrd*

Segunda fase: imagen ligera con las dependencias mínimas

FROM ubuntu:22.04

Instalar las dependencias mínimas necesarias para ejecutar el convertidor y las bibliotecas ISMRMRD

RUN apt-get update && apt-get install -y --no-install-recommends libxslt1.1 libhdf5-dev libxerces-c-dev libboost-all-dev libpugixml1v5 && apt-get clean && rm -rf /var/lib/apt/lists/*

Copiar el binario de siemens_to_ismrmrd y las bibliotecas de la fase anterior

COPY --from=ismrmrd_base /usr/local/bin/siemens_to_ismrmrd /usr/local/bin/siemens_to_ismrmrd
COPY --from=ismrmrd_base /usr/local/lib/libismrmrd.tar.gz /usr/local/lib/

Descomprimir las bibliotecas de ISMRMRD y ejecutar ldconfig para actualizar las referencias de las bibliotecas

RUN cd /usr/local/lib && tar -zxvf libismrmrd.tar.gz && rm libismrmrd.tar.gz && ldconfig

@cenarius1985
Copy link

automate the process by means of a bat file and rebuild in batches: @echo off
REM Habilitar expansión de variables retardada
setlocal enabledelayedexpansion

REM Directorios para los archivos de entrada y salida
set input_dir=C:\Users\Ferna\Documentos\GitHub\siemens_to_ismrmrd\Conversion_dat_mrd
set output_dir=C:\Users\Ferna\Documentos\GitHub\siemens_to_ismrmrd\Conversion_dat_mrd

REM Directorio para guardar los archivos XML/XSL extraídos
set parameter_maps_dir=C:\Users\Ferna\Documentos\GitHub\siemens_to_ismrmrd\parameter_maps

REM Extraer el archivo incrustado IsmrmrdParameterMap_Siemens_NX.xsl si aún no está extraído
if not exist "%parameter_maps_dir%\IsmrmrdParameterMap_Siemens_NX.xsl" (
echo Extrayendo IsmrmrdParameterMap_Siemens_NX.xsl...
docker run --rm ^
siemenstoismrmrd siemens_to_ismrmrd ^
-e IsmrmrdParameterMap_Siemens_NX.xsl > "%parameter_maps_dir%\IsmrmrdParameterMap_Siemens_NX.xsl"
)

REM Verificar si el directorio de entrada contiene archivos .dat
if not exist "%input_dir%*.dat" (
echo No se encontraron archivos .dat en el directorio de entrada: %input_dir%
exit /b
)

REM Iterar sobre todos los archivos .dat en el directorio de entrada
for %%f in ("%input_dir%*.dat") do (
REM Extraer el nombre del archivo sin la extensión
set "filename=%%~nf"
echo Procesando archivo %%f...

REM Ejecutar el contenedor Docker y convertir el archivo usando el archivo XSL extraído
docker run --rm ^
    -v "%input_dir%:/input" ^
    -v "%output_dir%:/output" ^
    -v "%parameter_maps_dir%:/parameter_maps" ^
    siemenstoismrmrd siemens_to_ismrmrd ^
    -f "/input/!filename!.dat" ^
    -x "/parameter_maps/IsmrmrdParameterMap_Siemens_NX.xsl" ^
	--skipSyncData ^
    -o "/output/!filename!.mrd"

REM Verificar si la conversión fue exitosa
if exist "%output_dir%\!filename!.mrd" (
    echo Archivo convertido con éxito: !filename!.mrd
) else (
    echo Error al convertir el archivo: !filename!.dat
)

)

echo Conversión completa.
pause

@MauroLeidi
Copy link
Author

Hi Cenarius,
I am unsure to understand your point, but yes also in your case the libpugixml1v5 library is included in the second stage and you have a two stage build in your Dockerfile. I just opened the pull request with the minimal change to make it work. I don't need a solution, I have it already.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants