1FROM afni/afni_dev_base
2
3# Remove f2c dev header to ensure within repo f2c.h is used
4USER root
5RUN apt-get remove -y libf2c2-dev
6
7ENV DESTDIR=$AFNI_ROOT/../install
8ENV PATH=$DESTDIR:$PATH
9
10# Copy AFNI source code. This will likely invalidate the build cache.
11COPY --chown=$CONTAINER_UID:$CONTAINER_GID . $AFNI_ROOT/
12
13# Not supported, try the cmake build for coverage testing
14ENV AFNI_WITH_COVERAGE=false
15
16ARG AFNI_MAKEFILE_SUFFIX=linux_ubuntu_16_64_glw_local_shared
17ARG KEEP_BUILD_DIR="0"
18RUN cd $AFNI_ROOT/src \
19    && make -f  other_builds/Makefile.$AFNI_MAKEFILE_SUFFIX afni_src.tgz \
20    && tar -xzf afni_src.tgz -C $AFNI_ROOT/../build --strip-components=1 \
21    && rm afni_src.tgz \
22    # copy and possibly modify makefile
23    && cd $AFNI_ROOT/../build \
24    && cp other_builds/Makefile.$AFNI_MAKEFILE_SUFFIX Makefile \
25    # clean and move source code to build directory
26    && make cleanest \
27    # Build AFNI.
28    && /bin/bash -c \
29    'make itall 2>&1 | tee build_log.txt && test ${PIPESTATUS[0]} -eq 0' \
30    && mv $AFNI_MAKEFILE_SUFFIX/* $AFNI_ROOT/../install \
31    # Remove build tree to drop image size
32    && if [ "$KEEP_BUILD_DIR" = "0" ]; then \
33      rm -rf $AFNI_ROOT/../build; \
34      fi
35
36USER root
37RUN bash -c 'echo PATH=${PATH} >> /etc/environment'
38USER $CONTAINER_UID
39
40WORKDIR $HOME/work
41