FROM ubuntu:20.04

# https://rtfm.co.ua/en/docker-configure-tzdata-and-timezone-during-build/
ENV TZ=Europe/Brussels
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Install the dependencies
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
    g++ cmake wget mercurial unzip patch \
    uuid-dev libcurl4-openssl-dev liblua5.3-dev \
    libgtest-dev libpng-dev libsqlite3-dev libssl-dev libjpeg-dev \
    zlib1g-dev libdcmtk-dev libboost-all-dev libwrap0-dev \
    libcharls-dev libjsoncpp-dev libpugixml-dev locales \
    python3-pip wkhtmltopdf && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Download the source code of Orthanc and Python plugin
WORKDIR /root
RUN hg clone -u Orthanc-1.7.3 https://hg.orthanc-server.com/orthanc
RUN hg clone -u OrthancPython-2.0 https://hg.orthanc-server.com/orthanc-python

# Build Orthanc and run the unit tests
RUN mkdir /root/orthanc/Build
WORKDIR /root/orthanc/Build
RUN cmake -DALLOW_DOWNLOADS=ON \
        -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON \
        -DUSE_SYSTEM_CIVETWEB=OFF \
        -DDCMTK_LIBRARIES=dcmjpls \
        -DCMAKE_BUILD_TYPE=Release \
        ../OrthancServer/
RUN make -j`nproc` UnitTests Orthanc

RUN locale-gen en_US.UTF-8 && update-locale
RUN ./UnitTests

# Build Python plugin
RUN mkdir /root/orthanc-python/Build
WORKDIR /root/orthanc-python/Build
RUN cmake -DALLOW_DOWNLOADS=ON \
        -DCMAKE_BUILD_TYPE=Release \
        -DPYTHON_VERSION=3.8 \
        ..
RUN make -j`nproc`

# This is the answer to your question:
RUN python3.8 -m pip install pdfkit pydicom

COPY ./sample.py /root/sample.py
COPY ./configuration.json /root/configuration.json

WORKDIR /root
RUN /root/orthanc/Build/Orthanc configuration.json
