From b91d4540a35e1021a3628785392edcb02e42bdc0 Mon Sep 17 00:00:00 2001 From: poorndm Date: Wed, 19 Mar 2025 12:47:01 +0530 Subject: [PATCH] Dockerfile for Ruby 3.4.2 on Windows Signed-off-by: poorndm --- .expeditor/build-windows-docker.yml | 10 +++--- 3.4/windows/2019/Dockerfile | 51 +++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 3.4/windows/2019/Dockerfile diff --git a/.expeditor/build-windows-docker.yml b/.expeditor/build-windows-docker.yml index ddd23a05..7af22c8d 100644 --- a/.expeditor/build-windows-docker.yml +++ b/.expeditor/build-windows-docker.yml @@ -12,13 +12,13 @@ steps: - id: build-and-push-on-windows-2019-server-rubydistros-dockerhub label: ":docker::windows: build-and-push-rubydistros-dockerhub" commands: - - "docker build . -f 3.3/windows/2019/Dockerfile -t windows-2019:3.3" - - "docker tag windows-2019:3.3 docker.io/rubydistros/windows-2019:3.3" - - "docker tag windows-2019:3.3 docker.io/rubydistros/windows-2019:latest" - - "docker push docker.io/rubydistros/windows-2019:3.3" + - "docker build . -f 3.4/windows/2019/Dockerfile -t windows-2019:3.4" + - "docker tag windows-2019:3.4 docker.io/rubydistros/windows-2019:3.4" + - "docker tag windows-2019:3.4 docker.io/rubydistros/windows-2019:latest" + - "docker push docker.io/rubydistros/windows-2019:3.4" - "docker push docker.io/rubydistros/windows-2019:latest" agents: queue: docker-windows-2019 plugins: - docker-login#v2.1.0: - username: expeditor \ No newline at end of file + username: expeditor diff --git a/3.4/windows/2019/Dockerfile b/3.4/windows/2019/Dockerfile new file mode 100644 index 00000000..df86efcb --- /dev/null +++ b/3.4/windows/2019/Dockerfile @@ -0,0 +1,51 @@ +FROM mcr.microsoft.com/windows/servercore:ltsc2019 + +ENV BUNDLE_SILENCE_ROOT_WARNING=true \ + GIT_DISCOVERY_ACROSS_FILESYSTEM=true + +# When launched by user, default to PowerShell if no other command specified. +CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"] + +# latest choco via PowerShell on windows2019 requires .NET, Download and install .NET Framework 4.8 +FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 +ADD https://go.microsoft.com/fwlink/?linkid=863265 /ndp472-kb4054530-x86-x64-allos-enu.exe +RUN C:\ndp472-kb4054530-x86-x64-allos-enu.exe /quiet /install + +# Install Chocolatey (and essentials) +ADD https://chocolatey.org/install.ps1 /chocolatey_install.ps1 +RUN powershell -File C:\chocolatey_install.ps1 +RUN C:\ProgramData\Chocolatey\bin\refreshenv -and \ + choco feature enable -n=allowGlobalConfirmation -and \ + choco config set cacheLocation C:\chococache -and \ + choco upgrade chocolatey -and \ + rmdir /q /s C:\chococache -and \ + del C:\chocolatey_install.ps1 -and \ + Write-Output "Chocolatey install complete -- closing out layer" +#install git +RUN choco install git.install -y +#from the versions which are >2.35 requires Strict repository ownership checks hence we are doing this step +#can found more on here https://github.blog/2022-04-18-highlights-from-git-2-36/#stricter-repository-ownership-checks +RUN git config --system --add safe.directory '*' +RUN git --version + +# Install Ruby + Devkit +RUN $ErrorActionPreference = 'Stop'; \ + Write-Output 'Downloading Ruby + DevKit'; \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + (New-Object System.Net.WebClient).DownloadFile('https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.4.2-1/rubyinstaller-3.4.2-1-x64.exe', 'c:\\rubyinstaller-devkit-3.4.2-1-x64.exe'); \ + Write-Output 'Installing Ruby + DevKit'; \ + Start-Process c:\rubyinstaller-devkit-3.4.2-1-x64.exe -ArgumentList '/verysilent /allusers /dir=C:\\ruby33' -Wait ; \ + Write-Output 'Cleaning up installation'; \ + Remove-Item c:\rubyinstaller-devkit-3.4.2-1-x64.exe -Force; \ + Write-Output 'Closing out the layer'; + +# Download MSYS2 dev kit, extract it and add to the PATH variable + +RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('https://github.com/msys2/msys2-installer/releases/download/2025-02-21/msys2-x86_64-20250221.exe', 'c:\\msys2-x86_64-20250221.exe'); \ + .\msys2-x86_64-20250221.exe in --confirm-command --accept-messages --root C:\msys2 ; \ + [Environment]::SetEnvironmentVariable('PATH', $env:PATH + ';C:\msys2', [EnvironmentVariableTarget]::Machine); \ + Remove-Item 'C:\msys2-x86_64-20250221.exe' + +#Install MSYS2 and MINGW development toolchain and enable it +RUN ridk install 3 +RUN ridk enable \ No newline at end of file