Dockerfile_windows_10 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # Dockerfile for installing the necessary dependencies for building Hadoop.
  17. # See BUILDING.txt.
  18. FROM mcr.microsoft.com/windows:ltsc2019
  19. # Need to disable the progress bar for speeding up the downloads.
  20. # hadolint ignore=SC2086
  21. RUN powershell $Global:ProgressPreference = 'SilentlyContinue'
  22. # Restore the default Windows shell for correct batch processing.
  23. SHELL ["cmd", "/S", "/C"]
  24. # Install Visual Studio 2019 Build Tools.
  25. RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe \
  26. && (start /w vs_buildtools.exe --quiet --wait --norestart --nocache \
  27. --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" \
  28. --add Microsoft.VisualStudio.Workload.VCTools \
  29. --add Microsoft.VisualStudio.Component.VC.ASAN \
  30. --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
  31. --add Microsoft.VisualStudio.Component.Windows10SDK.19041 \
  32. || IF "%ERRORLEVEL%"=="3010" EXIT 0) \
  33. && del /q vs_buildtools.exe
  34. # Install Chocolatey.
  35. ENV chocolateyVersion=1.4.0
  36. RUN powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
  37. # Install git.
  38. RUN choco install git.install -y
  39. RUN powershell Copy-Item -Recurse -Path 'C:\Program Files\Git' -Destination C:\Git
  40. # Install vcpkg.
  41. # hadolint ignore=DL3003
  42. RUN powershell git clone https://github.com/microsoft/vcpkg.git \
  43. && cd vcpkg \
  44. && git fetch --all \
  45. && git checkout 2025.03.19 \
  46. && .\bootstrap-vcpkg.bat
  47. ADD vcpkg/vcpkg.json .
  48. RUN powershell .\vcpkg\vcpkg.exe install --x-install-root .\vcpkg\installed
  49. # Install Azul Java 8 JDK.
  50. RUN powershell Invoke-WebRequest -URI https://cdn.azul.com/zulu/bin/zulu8.62.0.19-ca-jdk8.0.332-win_x64.zip -OutFile $Env:TEMP\zulu8.62.0.19-ca-jdk8.0.332-win_x64.zip
  51. RUN powershell Expand-Archive -Path $Env:TEMP\zulu8.62.0.19-ca-jdk8.0.332-win_x64.zip -DestinationPath "C:\Java"
  52. # Install Apache Maven.
  53. RUN powershell Invoke-WebRequest -URI https://downloads.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.zip -OutFile $Env:TEMP\apache-maven-3.8.8-bin.zip
  54. RUN powershell Expand-Archive -Path $Env:TEMP\apache-maven-3.8.8-bin.zip -DestinationPath "C:\Maven"
  55. # Install CMake 3.19.0.
  56. RUN powershell Invoke-WebRequest -URI https://cmake.org/files/v3.19/cmake-3.19.0-win64-x64.zip -OutFile $Env:TEMP\cmake-3.19.0-win64-x64.zip
  57. RUN powershell Expand-Archive -Path $Env:TEMP\cmake-3.19.0-win64-x64.zip -DestinationPath "C:\CMake"
  58. # Install zstd 1.5.4.
  59. RUN powershell Invoke-WebRequest -Uri https://github.com/facebook/zstd/releases/download/v1.5.4/zstd-v1.5.4-win64.zip -OutFile $Env:TEMP\zstd-v1.5.4-win64.zip
  60. RUN powershell Expand-Archive -Path $Env:TEMP\zstd-v1.5.4-win64.zip -DestinationPath "C:\ZStd"
  61. RUN setx PATH "%PATH%;C:\ZStd"
  62. # Install libopenssl 3.1.1 needed for rsync 3.2.7.
  63. RUN powershell Invoke-WebRequest -Uri https://repo.msys2.org/msys/x86_64/libopenssl-3.1.1-1-x86_64.pkg.tar.zst -OutFile $Env:TEMP\libopenssl-3.1.1-1-x86_64.pkg.tar.zst
  64. RUN powershell zstd -d $Env:TEMP\libopenssl-3.1.1-1-x86_64.pkg.tar.zst -o $Env:TEMP\libopenssl-3.1.1-1-x86_64.pkg.tar
  65. RUN powershell mkdir "C:\LibOpenSSL"
  66. RUN powershell tar -xvf $Env:TEMP\libopenssl-3.1.1-1-x86_64.pkg.tar -C "C:\LibOpenSSL"
  67. # Install libxxhash 0.8.1 needed for rsync 3.2.7.
  68. RUN powershell Invoke-WebRequest -Uri https://repo.msys2.org/msys/x86_64/libxxhash-0.8.1-1-x86_64.pkg.tar.zst -OutFile $Env:TEMP\libxxhash-0.8.1-1-x86_64.pkg.tar.zst
  69. RUN powershell zstd -d $Env:TEMP\libxxhash-0.8.1-1-x86_64.pkg.tar.zst -o $Env:TEMP\libxxhash-0.8.1-1-x86_64.pkg.tar
  70. RUN powershell mkdir "C:\LibXXHash"
  71. RUN powershell tar -xvf $Env:TEMP\libxxhash-0.8.1-1-x86_64.pkg.tar -C "C:\LibXXHash"
  72. # Install libzstd 1.5.4 needed for rsync 3.2.7.
  73. RUN powershell Invoke-WebRequest -Uri https://repo.msys2.org/msys/x86_64/libzstd-1.5.5-1-x86_64.pkg.tar.zst -OutFile $Env:TEMP\libzstd-1.5.5-1-x86_64.pkg.tar.zst
  74. RUN powershell zstd -d $Env:TEMP\libzstd-1.5.5-1-x86_64.pkg.tar.zst -o $Env:TEMP\libzstd-1.5.5-1-x86_64.pkg.tar
  75. RUN powershell mkdir "C:\LibZStd"
  76. RUN powershell tar -xvf $Env:TEMP\libzstd-1.5.5-1-x86_64.pkg.tar -C "C:\LibZStd"
  77. # Install rsync 3.2.7.
  78. RUN powershell Invoke-WebRequest -Uri https://repo.msys2.org/msys/x86_64/rsync-3.2.7-2-x86_64.pkg.tar.zst -OutFile $Env:TEMP\rsync-3.2.7-2-x86_64.pkg.tar.zst
  79. RUN powershell zstd -d $Env:TEMP\rsync-3.2.7-2-x86_64.pkg.tar.zst -o $Env:TEMP\rsync-3.2.7-2-x86_64.pkg.tar
  80. RUN powershell mkdir "C:\RSync"
  81. RUN powershell tar -xvf $Env:TEMP\rsync-3.2.7-2-x86_64.pkg.tar -C "C:\RSync"
  82. # Copy the dependencies of rsync 3.2.7.
  83. RUN powershell Copy-Item -Path "C:\LibOpenSSL\usr\bin\*.dll" -Destination "C:\Program` Files\Git\usr\bin"
  84. RUN powershell Copy-Item -Path "C:\LibXXHash\usr\bin\*.dll" -Destination "C:\Program` Files\Git\usr\bin"
  85. RUN powershell Copy-Item -Path "C:\LibZStd\usr\bin\*.dll" -Destination "C:\Program` Files\Git\usr\bin"
  86. RUN powershell Copy-Item -Path "C:\RSync\usr\bin\*" -Destination "C:\Program` Files\Git\usr\bin"
  87. COPY pkg-resolver pkg-resolver
  88. ## Install Python 3.11.8.
  89. # The Python installation steps below are derived from -
  90. # https://github.com/docker-library/python/blob/105d6f34e7d70aad6f8c3e249b8208efa591916a/3.11/windows/windowsservercore-ltsc2022/Dockerfile
  91. ENV PYTHONIOENCODING UTF-8
  92. ENV PYTHON_VERSION 3.11.8
  93. ENV PYTHON_PIP_VERSION 24.0
  94. ENV PYTHON_SETUPTOOLS_VERSION 65.5.1
  95. ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/dbf0c85f76fb6e1ab42aa672ffca6f0a675d9ee4/public/get-pip.py
  96. ENV PYTHON_GET_PIP_SHA256 dfe9fd5c28dc98b5ac17979a953ea550cec37ae1b47a5116007395bfacff2ab9
  97. RUN powershell Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  98. RUN powershell pkg-resolver\install-python.ps1
  99. RUN powershell pkg-resolver\install-pip.ps1
  100. RUN powershell pip install python-dateutil
  101. # Create a user HadoopBuilder with basic privileges and use it for building Hadoop on Windows.
  102. RUN powershell New-LocalUser -Name 'HadoopBuilder' -Description 'User account for building Apache Hadoop' -Password ([securestring]::new()) -AccountNeverExpires -PasswordNeverExpires
  103. # Grant the privilege to create symbolic links to HadoopBuilder.
  104. RUN powershell secedit /export /cfg "C:\secpol.cfg"
  105. RUN powershell "(Get-Content C:\secpol.cfg).Replace('SeCreateSymbolicLinkPrivilege = ', 'SeCreateSymbolicLinkPrivilege = HadoopBuilder,') | Out-File C:\secpol.cfg"
  106. RUN powershell secedit /configure /db "C:\windows\security\local.sdb" /cfg "C:\secpol.cfg"
  107. RUN powershell Remove-Item -Force "C:\secpol.cfg" -Confirm:$false
  108. # Login as HadoopBuilder and set the necessary environment and PATH variables.
  109. USER HadoopBuilder
  110. ENV PROTOBUF_HOME "C:\vcpkg\installed\x64-windows"
  111. ENV JAVA_HOME "C:\Java\zulu8.62.0.19-ca-jdk8.0.332-win_x64"
  112. ENV MAVEN_OPTS '-Xmx2048M -Xss128M'
  113. ENV IS_WINDOWS 1
  114. RUN setx PATH "%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  115. RUN setx PATH "%PATH%;%JAVA_HOME%\bin"
  116. RUN setx PATH "%PATH%;C:\Maven\apache-maven-3.8.8\bin"
  117. RUN setx PATH "%PATH%;C:\CMake\cmake-3.19.0-win64-x64\bin"
  118. RUN setx PATH "%PATH%;C:\ZStd"
  119. RUN setx PATH "%PATH%;C:\Program Files\Git\usr\bin"
  120. RUN setx PATH "%PATH%;C:\Python"
  121. # The mvnsite module runs a bash script and somewhere down in the invocation, it resorts to call
  122. # /usr/bin/env python3. Thus, we need to create the following symbolic link to satisfy this need.
  123. RUN powershell New-Item -ItemType SymbolicLink -Path "C:\Python\python3" -Target "C:\Python\python.exe"
  124. # We get strange Javadoc errors without this.
  125. RUN setx classpath ""
  126. # Setting Git configurations.
  127. RUN git config --global core.autocrlf true
  128. RUN git config --global core.longpaths true
  129. # Define the entry point for the docker container.
  130. ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat", "&&", "cmd.exe"]