FROM ubuntu:focal

RUN apt-get update

# disable interactive install 
ENV DEBIAN_FRONTEND noninteractive

# install developement tools
RUN apt-get -y install cmake
RUN apt-get -y install g++
RUN apt-get -y install git

# install developement debugging tools
RUN apt-get -y install valgrind

# install CTL dependencies
#RUN apt-get -y install libilmbase-dev
#RUN apt-get -y install libopenexr-dev
#RUN apt-get -y install zlib1g-dev

WORKDIR /usr/src/
RUN git clone https://github.com/madler/zlib.git
WORKDIR /usr/src/zlib/build
RUN cmake ..
RUN make
RUN make install

WORKDIR /usr/src/
RUN git clone https://github.com/AcademySoftwareFoundation/Imath.git
WORKDIR /usr/src/Imath/build
RUN cmake ..
RUN make
RUN make install

WORKDIR /usr/src/
RUN git clone https://github.com/AcademySoftwareFoundation/openexr.git
WORKDIR /usr/src/openexr
RUN git checkout RB-3.1 
WORKDIR /usr/src/openexr/build
RUN cmake ..
RUN make
RUN make install

RUN apt-get -y install libtiff-dev

# build CTL
WORKDIR /usr/src/CTL
COPY . .
WORKDIR /usr/src/CTL/build
RUN cmake ..
RUN make
RUN make install

# finalize docker environment
WORKDIR /usr/src/CTL

