# Docker container with 3D Slicer build to build and test an extension

**URL:** <https://discourse.slicer.org/t/docker-container-with-3d-slicer-build-to-build-and-test-an-extension/32461>\
**Category:** SlicerDMRI\
**Tags:** docker, extensions\
**Created:** [October 29, 2023, 9:03pm UTC](https://discourse.slicer.org/t/docker-container-with-3d-slicer-build-to-build-and-test-an-extension/32461 "2023-10-29T21:03:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhlegarreta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jhlegarreta/32/66542_2.png) [@jhlegarreta](https://discourse.slicer.org/u/jhlegarreta)\
**Post date:** [October 29, 2023, 9:03pm UTC](https://discourse.slicer.org/t/docker-container-with-3d-slicer-build-to-build-and-test-an-extension/32461/1 "2023-10-29T21:03:37Z")

</div>

Hi,  
related to [Adding a CI build to a Slicer extension](https://discourse.slicer.org/t/adding-a-ci-build-to-a-slicer-extension/30857), I am willing to add an additional GitHub Actions workflow to check building and testing an extension this time using a Slicer Docker image, so that I can know early if a change to the extension fails (Slicer taking above 3 hours to build).

I have done several attempts here, so far unsuccessfully:  
[ENH: Add Docker-assisted build, test GHA workflow · SlicerDMRI/SlicerDMRI@b030e77 · GitHub](https://github.com/SlicerDMRI/SlicerDMRI/actions/runs/6679889770/job/18152413938?pr=192)

I am pulling the nightly `slicer/slicer-base:latest` image.

And I am using the step below in my GHA workflow file to try to build the extension against it:

```auto
Slicer_DIR=/usr/src/Slicer-build/Slicer-build

EXTENSION_NAME=SlicerDMRI
EXTENSION_SOURCE_DIR=${{ github.workspace }}/$EXTENSION_NAME
EXTENSION_BUILD_DIR=${{ github.workspace }}/$EXTENSION_NAME-build

docker run \
  --rm \
  -v $EXTENSION_SOURCE_DIR:/usr/src/slicerdmri \
  -v $EXTENSION_BUILD_DIR:/usr/src/slicerdmri-build \
Slicer-build
  slicer/slicer-base \
  cmake \
    -GNinja \
    -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \
    -DSlicer_DIR:PATH=$Slicer_DIR \
    -S /usr/src/slicerdmri \
    -B /usr/src/slicerdmri-build

```

It looks like I am not giving it the right Slicer build directory or I am not mapping it correctly to the Docker volume:

```auto
-- Configuring incomplete, errors occurred!
CMake Error at CMakeLists.txt:22 (find_package):
  By not providing "FindSlicer.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Slicer", but
  CMake did not find one.

  Could not find a package configuration file provided by "Slicer" with any
  of the following names:

    SlicerConfig.cmake
    slicer-config.cmake

```

[ENH: Add Docker-assisted build, test GHA workflow · SlicerDMRI/SlicerDMRI@b030e77 · GitHub](https://github.com/SlicerDMRI/SlicerDMRI/actions/runs/6679889770/job/18152413938?pr=192#step:5:33)

IIUC, I am giving it the same directory as I do in my regular GHA workflow build that compiles Slicer:  
[Merge pull request #194 from jhlegarreta/FixSprintfWarnings · SlicerDMRI/SlicerDMRI@f95c613 · GitHub](https://github.com/SlicerDMRI/SlicerDMRI/actions/runs/6684590637/job/18162009288#step:7:2)

Locally,

```auto
docker run --rm slicer/slicer-base find . -name "SlicerConfig.cmake" -type f

```

or

```auto
docker run --rm slicer/slicer-base find . -name "slicer-config.cmake" -type f

```

dot not provide any answer.

And

```auto
docker run --rm slicer/slicer-base ls ./Slicer-build

```

does not show a meaningful directory structure (`Slicer-build/share/Slicer-5.5/Slicer.crt`) for this purpose.

Locally, if I do

```auto
docker run --rm 
  -v /bld/slicer:/usr/src/Slicer-build/slicer-build \
  -v /src/slicerdmri:/usr/src/slicerdmri \
  -v /bld/slicerdmri:/usr/src/slicerdmri-build \
  slicer/slicer-base \
  cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Debug \
  -DSlicer_DIR:PATH=$Slicer_DIR \
  -S /usr/src/slicerdmri \
  -B /usr/src/slicerdmri-build

```

I get an CMake error:

```auto
CMake Error:
The current CMakeCache.txt directory
/usr/src/slicerdmri-build/CMakeCache.txt
is different than the directory
/bld/slicerdmri where CMakeCache.txt was created.
This may result in binaries being created in the wrong place.
If you are not sure, reedit the CMakeCache.txt
CMake Error:
The source "/usr/src/slicerdmri/CMakeLists.txt"
does not match the source
"/src/slicerdmri/CMakeLists.txt"
used to generate cache.
Re-run cmake with a different source directory.

```

So,

- Can this be done, i.e. does `slicer/slicer-base:latest` contain a Slicer that is already built? If not, do such images exist (PS: I have already gone through [this note](https://github.com/Slicer/SlicerDocker/blob/main/unmaintained-images.rst)).
- I do not find a nightly build of the image used [by the OpenDose3D extension](https://gitlab.com/opendose/opendose3d/-/blob/develop/.gitlab-ci.yml?ref_type=heads) mentioned in [Adding a CI build to a Slicer extension - #24 by lassoan](https://discourse.slicer.org/t/adding-a-ci-build-to-a-slicer-extension/30857/24), Dokcer only hosting [these possibly related images](https://hub.docker.com/u/bishopwolf), none being large enough to host a Slicer build, and not being updated nightly.
- What am I missing?

Thanks.
