#seamsh - Copyright (C) <2010-2020>
# <Universite catholique de Louvain (UCL), Belgium
# 	
# List of the contributors to the development of seamsh: see AUTHORS file.
# Description and complete License: see LICENSE file.
# 	
# This program (seamsh) is free software: 
# you can redistribute it and/or modify it under the terms of the GNU Lesser General 
# Public License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public License
# along with this program (see COPYING file).  If not, 
# see <http://www.gnu.org/licenses/>.

FROM ubuntu:24.04

env DEBIAN_FRONTEND=noninteractive
#linux
RUN apt update && apt install -y git python3 make gcc \
        ca-certificates gpg wget && \
    wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor - \
        > /usr/share/keyrings/kitware-archive-keyring.gpg && \
    echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' \
        > /etc/apt/sources.list.d/kitware.list && \
    apt update && apt install -y cmake
#windows
RUN apt update && apt install -y mingw-w64 mingw-w64-tools
run echo "\
SET(CMAKE_SYSTEM_NAME Windows)\n\
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)\n\
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)\n\
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)\n\
SET(CMAKE_Fortran_COMPILER x86_64-w64-mingw32-gfortran)\n\
SET(CMAKE_FIND_ROOT_PATH /mingw64)\n\
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n"\
> /cmake-mingw

RUN apt update && apt install -y git python3-setuptools python3-wheel twine


### osxcross

RUN apt-get update && apt-get install -y clang patch libssl-dev liblzma-dev libxml2-dev llvm-dev uuid-dev zlib1g-dev xz-utils

RUN useradd -ms /bin/bash validator
RUN mkdir -p /osxcross && chown validator /osxcross
USER validator
RUN git clone https://github.com/tpoechtrager/osxcross.git /osxcross
COPY MacOSX15.5.sdk.tar.xz /osxcross/tarballs/MacOSX15.5.sdk.tar.xz
RUN cd /osxcross && SDK_VERSION=15.5 UNATTENDED=1 ./build.sh
RUN rm -rf /osxcross/build
ENV PATH=/osxcross/target/bin/:$PATH
ENV OSXCROSS_HOST=arm64-apple-darwin24.5
ENV MACOSX_DEPLOYMENT_TARGET=11.0
COPY toolchain.cmake /osxcross/target/toolchain.cmake


### doc
USER root
RUN apt-get update && apt-get install -y python3-venv gdal-bin python3-scipy
RUN python3 -m venv /venv --system-site-packages
RUN /venv/bin/pip install -i https://gmsh.info/python-packages-dev-nox --no-cache-dir gmsh
RUN /venv/bin/pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints gdal
ENV PATH=/venv/bin:$PATH
USER validator

VOLUME ["/etc/gitlab-runner"]

WORKDIR /home/validator
