From 72fe9d48cdf7028b8b95996b60ccea13d2cf42c0 Mon Sep 17 00:00:00 2001
From: Moritz Maxeiner <moritz@ucworks.org>
Date: Thu, 13 Sep 2018 16:57:57 +0200
Subject: [PATCH] Support Windows - Add windows docker image - Add CI/CD for
 that image

---
 .gitlab-ci.yml         | 11 ++++++++
 windows/Dockerfile     | 58 ++++++++++++++++++++++++++++++++++++++++++
 windows/qtifwsilent.qs | 51 +++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+)
 create mode 100644 windows/Dockerfile
 create mode 100644 windows/qtifwsilent.qs

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e5975f0..272e58d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,3 +11,14 @@ build-ubuntu-18.04:
     - docker push "${CI_REGISTRY}/${CI_PROJECT_PATH,,}:ubuntu-18.04"
   after_script:
     - docker logout "${CI_REGISTRY}"
+
+build-windows:
+  stage: build
+  tags: [ windows, shell ]
+  before_script:
+    - echo "${CI_REGISTRY_PASSWORD}" | docker login -u "${CI_REGISTRY_USER}" "${CI_REGISTRY}" --password-stdin
+  script:
+    - docker build --isolation process --memory 12G --pull -t "${CI_REGISTRY}/${CI_PROJECT_PATH,,}:windows" windows
+    - docker push "${CI_REGISTRY}/$(${CI_PROJECT_PATH}.toLower()):windows"
+  after_script:
+    - docker logout "${CI_REGISTRY}"
diff --git a/windows/Dockerfile b/windows/Dockerfile
new file mode 100644
index 0000000..649a9d9
--- /dev/null
+++ b/windows/Dockerfile
@@ -0,0 +1,58 @@
+# Use the latest Windows Server Core image
+FROM microsoft/windowsservercore
+
+SHELL ["powershell", "-NoProfile", "-ExecutionPolicy Bypass", "-Command", "$ErrorActionPreference = 'Stop';"]
+
+RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
+    Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
+    choco install -y visualstudio2017buildtools; \
+    choco install -y visualstudio2017-workload-vctools; \
+    Start-Process "\"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe\"" -ArgumentList 'modify --installPath \"C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools\" --quiet --norestart --remove Microsoft.VisualStudio.Component.VC.CMake.Project' -NoNewWindow -Wait; \
+    choco install -y cmake --version 3.12.2 --installargs "ADD_CMAKE_TO_PATH=System"; \
+    choco install -y git 7zip; \
+    (New-Object Net.WebClient).DownloadFile('https://github.com/Kitware/ninja/releases/download/v1.8.2.g972a7.kitware.dyndep-1/ninja-1.8.2.g972a7.kitware.dyndep-1_i686-pc-windows-msvc.zip', 'C:/ninja.zip'); \
+    7z e C:/ninja.zip -oC:/ninja -y; \
+    Remove-Item C:/ninja.zip -Force; \
+    [Environment]::SetEnvironmentVariable('PATH', "$([Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine))" + ';C:/ninja', [EnvironmentVariableTarget]::Machine)
+
+COPY qtifwsilent.qs C:/qtifwsilent.qs
+RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
+    (New-Object Net.WebClient).DownloadFile('https://download.qt.io/official_releases/qt/5.11/5.11.1/qt-opensource-windows-x86-5.11.1.exe', 'C:/qt.exe'); \
+    $Env:QT_INSTALL_DIR = 'C:/Qt'; \
+    Start-Process C:/qt.exe -ArgumentList '--verbose --script C:/qtifwsilent.qs' -NoNewWindow -Wait; \
+    Remove-Item C:/qtifwsilent.qs -Force; \
+    Remove-Item C:/qt.exe -Force; \
+    [Environment]::SetEnvironmentVariable('Qt5_DIR', 'C:/Qt/5.11.1/msvc2017_64', [EnvironmentVariableTarget]::Machine); \
+    [Environment]::SetEnvironmentVariable('EGL_PLATFORM_DIR', 'C:/Qt/5.11.1/msvc2017_64/include/QtANGLE', [EnvironmentVariableTarget]::Machine)
+
+RUN choco install -y python --version 3.6.6; \
+    $Env:PATH = "\"$([Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::User));$([Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine))\""; \
+    python -m pip --no-cache-dir install --no-warn-script-location \
+        wheel \
+        twine;
+
+RUN git clone --depth=1 https://github.com/BioroboticsLab/RF_vcpkg.git C:/vcpkg; \
+    cd C:/vcpkg; \
+    git checkout 247c77cbdee32767707f0390e1b4b4d16c2a9fef; \
+    ./scripts/bootstrap.ps1
+
+RUN cd C:/vcpkg; \
+    ./vcpkg install \
+        zlib:x64-windows \
+        libepoxy[egl]:x64-windows \
+        glm:x64-windows \
+        cgal:x64-windows \
+        hdf5:x64-windows \
+        openblas:x64-windows \
+        pybind11:x64-windows; \
+    ./vcpkg install opencv:x64-windows; \
+    ./vcpkg install mxnet[cpp,opencv]:x64-windows; \
+    Remove-Item -Recurse -Force -Path C:/vcpkg/downloads; \
+    Remove-Item -Recurse -Force -Path C:/vcpkg/buildtrees; \
+    Remove-Item -Recurse -Force -Path C:/vcpkg/packages;
+
+RUN python -m pip --no-cache-dir install --no-warn-script-location \
+        numpy \
+        scipy \
+        matplotlib \
+        pandas
diff --git a/windows/qtifwsilent.qs b/windows/qtifwsilent.qs
new file mode 100644
index 0000000..2d37dd2
--- /dev/null
+++ b/windows/qtifwsilent.qs
@@ -0,0 +1,51 @@
+function Controller() {
+    installer.autoRejectMessageBoxes();
+    installer.installationFinished.connect(function() {
+        gui.clickButton(buttons.NextButton);
+    })
+}
+
+Controller.prototype.WelcomePageCallback = function() {
+    gui.clickButton(buttons.NextButton, 7000);
+}
+
+Controller.prototype.CredentialsPageCallback = function() {
+    gui.clickButton(buttons.NextButton);
+}
+
+Controller.prototype.IntroductionPageCallback = function() {
+    gui.clickButton(buttons.NextButton);
+}
+
+Controller.prototype.TargetDirectoryPageCallback = function() {
+    gui.currentPageWidget().TargetDirectoryLineEdit.setText(installer.environmentVariable("QT_INSTALL_DIR"));
+    gui.clickButton(buttons.NextButton);
+}
+
+Controller.prototype.ComponentSelectionPageCallback = function() {
+    var widget = gui.currentPageWidget();
+    widget.deselectAll();
+    widget.selectComponent("qt.qt5.5111.win64_msvc2017_64");
+    widget.selectComponent("qt.qt5.5111.qtcharts");
+    gui.clickButton(buttons.NextButton);
+}
+
+Controller.prototype.LicenseAgreementPageCallback = function() {
+    gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
+    gui.clickButton(buttons.NextButton);
+}
+
+Controller.prototype.StartMenuDirectoryPageCallback = function() {
+    gui.clickButton(buttons.NextButton);
+}
+
+Controller.prototype.ReadyForInstallationPageCallback = function() {
+    gui.clickButton(buttons.NextButton);
+}
+
+Controller.prototype.FinishedPageCallback = function() {
+    var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm;
+    if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox)
+        checkBoxForm.launchQtCreatorCheckBox.checked = false;
+    gui.clickButton(buttons.FinishButton);
+}
-- 
GitLab