Skip to content

Commit 3e3c644

Browse files
committed
Refresh windows docker setup
1 parent e720e6f commit 3e3c644

File tree

4 files changed

+175
-30
lines changed

4 files changed

+175
-30
lines changed

.github/workflows/msvc.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: MSVC Build
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
build:
15+
runs-on: windows-2022
16+
env:
17+
THRIFT_BUILD_DIR: C:\thrift-build
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Ensure expected workspace path
24+
shell: pwsh
25+
run: |
26+
if (-not (Test-Path 'C:\src')) { New-Item -Path 'C:\src' -ItemType Directory | Out-Null }
27+
if (Test-Path 'C:\src\thrift') { Remove-Item 'C:\src\thrift' -Recurse -Force }
28+
cmd /c mklink /J C:\src\thrift $env:GITHUB_WORKSPACE
29+
30+
- name: Configure build output directory
31+
shell: pwsh
32+
run: |
33+
New-Item -Path $env:THRIFT_BUILD_DIR -ItemType Directory -Force | Out-Null
34+
35+
- name: Set Docker image name
36+
shell: pwsh
37+
env:
38+
OWNER: ${{ github.repository_owner }}
39+
run: |
40+
$image = "ghcr.io/{0}/thrift-build" -f $env:OWNER.ToLower()
41+
"DOCKER_IMAGE=$image" | Out-File -FilePath $env:GITHUB_ENV -Append
42+
43+
- name: Compute Docker image tag
44+
shell: pwsh
45+
run: |
46+
$hash = (Get-FileHash -Algorithm SHA256 'build/docker/msvc2017/Dockerfile').Hash.ToLower().Substring(0, 12)
47+
"IMAGE_TAG=msvc2017-$hash" | Out-File -FilePath $env:GITHUB_ENV -Append
48+
49+
- name: Log in to GHCR
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Pull cached image
57+
id: pull_cached
58+
continue-on-error: true
59+
shell: pwsh
60+
run: |
61+
Write-Host "Attempting to pull hash-based tag: $($env:DOCKER_IMAGE):$($env:IMAGE_TAG)"
62+
docker pull "$($env:DOCKER_IMAGE):$($env:IMAGE_TAG)"
63+
if ($LASTEXITCODE -eq 0) {
64+
Write-Host "Successfully pulled cached image with hash tag"
65+
} else {
66+
Write-Host "Hash tag not found, trying fallback to msvc2017 tag"
67+
docker pull "$($env:DOCKER_IMAGE):msvc2017"
68+
if ($LASTEXITCODE -eq 0) {
69+
Write-Host "Pulled msvc2017 tag, re-tagging with hash"
70+
docker tag "$($env:DOCKER_IMAGE):msvc2017" "$($env:DOCKER_IMAGE):$($env:IMAGE_TAG)"
71+
} else {
72+
Write-Host "No cached image found, will build from scratch"
73+
exit 1
74+
}
75+
}
76+
77+
- name: Build Docker image
78+
if: steps.pull_cached.outcome != 'success'
79+
shell: pwsh
80+
run: |
81+
Write-Host "Building with tags: $($env:DOCKER_IMAGE):$($env:IMAGE_TAG) and $($env:DOCKER_IMAGE):msvc2017"
82+
docker build -t "$($env:DOCKER_IMAGE):$($env:IMAGE_TAG)" -t "$($env:DOCKER_IMAGE):msvc2017" -f build\docker\msvc2017\Dockerfile 'build\'
83+
if ($LASTEXITCODE -ne 0) {
84+
Write-Error "Docker build failed"
85+
exit 1
86+
}
87+
Write-Host "Verifying tags were created:"
88+
docker images "$($env:DOCKER_IMAGE)"
89+
90+
- name: Push Docker image
91+
if: github.event_name != 'pull_request' && steps.pull_cached.outcome != 'success'
92+
shell: pwsh
93+
run: |
94+
Write-Host "Pushing hash-based tag: $($env:DOCKER_IMAGE):$($env:IMAGE_TAG)"
95+
docker push "$($env:DOCKER_IMAGE):$($env:IMAGE_TAG)"
96+
if ($LASTEXITCODE -ne 0) {
97+
Write-Error "Failed to push hash-based tag"
98+
exit 1
99+
}
100+
Write-Host "Pushing msvc2017 tag: $($env:DOCKER_IMAGE):msvc2017"
101+
docker push "$($env:DOCKER_IMAGE):msvc2017"
102+
if ($LASTEXITCODE -ne 0) {
103+
Write-Error "Failed to push msvc2017 tag"
104+
exit 1
105+
}
106+
Write-Host "Successfully pushed both tags"
107+
108+
- name: Build and test inside container
109+
shell: pwsh
110+
run: |
111+
docker run -v c:\src\thrift:C:\Thrift -v "${env:THRIFT_BUILD_DIR}:C:\build" --rm -t "$($env:DOCKER_IMAGE):$($env:IMAGE_TAG)" c:\thrift\build\docker\msvc2017\build.bat
112+
113+
- name: Check test results
114+
if: always()
115+
shell: pwsh
116+
run: |
117+
$logPath = Join-Path $env:THRIFT_BUILD_DIR 'Testing\Temporary\LastTest.log'
118+
if (Test-Path $logPath) {
119+
$content = Get-Content $logPath -Raw
120+
if ($content -match 'Test Failed\.') {
121+
Write-Error "Tests failed - check LastTest.log artifact for details"
122+
exit 1
123+
} else {
124+
Write-Host "All tests passed"
125+
}
126+
} else {
127+
Write-Warning "LastTest.log not found at $logPath"
128+
}
129+
130+
- name: Upload LastTest log
131+
if: always()
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: msvc2017-LastTest-log
135+
path: ${{ env.THRIFT_BUILD_DIR }}\Testing\Temporary\LastTest.log
136+
if-no-files-found: warn

build/docker/msvc2017/Dockerfile

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
#
1515

16-
FROM microsoft/dotnet-framework:4.7.1
16+
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022
1717

1818
# Restore the default Windows shell for correct batch processing below.
1919
SHELL ["cmd", "/S", "/C"]
@@ -22,29 +22,29 @@ SHELL ["cmd", "/S", "/C"]
2222
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
2323
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
2424
--installPath C:\BuildTools `
25-
--all `
26-
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
27-
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
28-
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
29-
--remove Microsoft.VisualStudio.Component.Windows81SDK `
25+
--add Microsoft.VisualStudio.Workload.VCTools `
26+
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
3027
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
3128
RUN DEL C:\TEMP\vs_buildtools.exe
3229

3330
# Install CMake
34-
ADD https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-win64-x64.msi C:\TEMP\cmake.msi
31+
ADD https://github.com/Kitware/CMake/releases/download/v4.1.2/cmake-4.1.2-windows-x86_64.msi C:\TEMP\cmake.msi
3532
RUN msiexec.exe /i C:\TEMP\cmake.msi /qn && `
3633
SETX PATH "%PATH%;C:\Program Files\CMake\bin" && `
3734
DEL C:\TEMP\cmake.msi
3835

3936
# Install boost (for the thrift runtime library build)
40-
ADD https://boost.teeks99.com/bin/1.69.0/boost_1_69_0-msvc-14.1-64.exe C:\TEMP\boost.exe
41-
RUN C:\TEMP\boost.exe /DIR="C:\Libraries\boost_1_69_0" /SILENT && `
42-
DEL C:\TEMP\boost.exe
37+
ADD https://boost.teeks99.com/bin/1.88.0/boost_1_88_0-msvc-14.1-64.exe C:\TEMP\boost.exe
38+
ENV BOOST_ROOT=C:\Libraries\boost_1_88_0
39+
RUN C:\TEMP\boost.exe /DIR=%BOOST_ROOT% /SILENT && `
40+
DEL C:\TEMP\boost.exe && `
41+
SETX BOOST_LIBRARYDIR "%BOOST_ROOT%\lib64-msvc-14.1" && `
42+
SETX PATH "%BOOST_LIBRARYDIR%;%PATH%"
4343

4444
# Install chocolatey
4545
RUN @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" `
4646
-NoProfile -InputFormat None -ExecutionPolicy Bypass -Command `
47-
"iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" `
47+
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" `
4848
&& SETX PATH "%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
4949

5050
# Install winflexbison (for the thrift compiler build)
@@ -57,34 +57,40 @@ RUN choco install 7zip curl -y
5757
COPY appveyor\build-libevent.bat C:\TEMP\build-libevent.bat
5858
ENV LIBEVENT_VERSION=2.1.8
5959
ENV WIN3P=C:\TEMP\WIN3P
60-
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 && `
60+
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=x64 -host_arch=x64 && `
6161
MKDIR C:\TEMP\WIN3P && `
6262
C:\TEMP\build-libevent.bat && `
6363
MKDIR C:\Libraries\libevent-%LIBEVENT_VERSION% && `
6464
MOVE C:\TEMP\WIN3P\libevent-%LIBEVENT_VERSION%-stable\include C:\Libraries\libevent-%LIBEVENT_VERSION% && `
6565
MOVE C:\TEMP\WIN3P\libevent-%LIBEVENT_VERSION%-stable\lib C:\Libraries\libevent-%LIBEVENT_VERSION% && `
66-
RMDIR /S /Q C:\TEMP\WIN3P
66+
RMDIR /S /Q C:\TEMP\WIN3P && `
67+
SETX LIBEVENT_ROOT "C:\Libraries\libevent-%LIBEVENT_VERSION%"
6768

6869
# Install zlib
6970
COPY appveyor\build-zlib.bat C:\TEMP\build-zlib.bat
70-
ENV ZLIB_VERSION=1.2.13
71+
ENV ZLIB_VERSION=1.3.1
7172
ENV WIN3P=C:\TEMP\WIN3P
72-
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 && `
73+
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=x64 -host_arch=x64 && `
7374
MKDIR C:\TEMP\WIN3P && `
7475
C:\TEMP\build-zlib.bat && `
7576
MOVE C:\TEMP\WIN3P\zlib-inst C:\Libraries\zlib-%ZLIB_VERSION% && `
76-
RMDIR /S /Q C:\TEMP\WIN3P
77+
RMDIR /S /Q C:\TEMP\WIN3P && `
78+
SETX ZLIB_ROOT "C:\Libraries\zlib-%ZLIB_VERSION%" && `
79+
SETX PATH "%ZLIB_ROOT%\bin;%PATH%"
7780

78-
# Install OpenSSL 1.1.0
79-
ADD http://slproweb.com/download/Win64OpenSSL-1_1_0l.exe C:\TEMP\openssl.exe
81+
# Install OpenSSL 3.6.0
82+
ADD https://slproweb.com/download/Win64OpenSSL-3_6_0.exe C:\TEMP\openssl.exe
8083
RUN C:\TEMP\openssl.exe /silent && `
81-
DEL C:\TEMP\openssl.exe
84+
DEL C:\TEMP\openssl.exe && `
85+
SETX OPENSSL_ROOT "C:\OpenSSL-Win64" && `
86+
SETX PATH "%OPENSSL_ROOT%\bin;%PATH%"
8287

8388
# Install java
8489
RUN choco install jdk8 -y
8590

8691
# Install python3
8792
RUN choco install python3 -y
93+
RUN pip install setuptools
8894

8995
# Install Adobe Flex 4.6 SDK and set FLEX_HOME so it can be found
9096
ADD http://download.macromedia.com/pub/flex/sdk/flex_sdk_4.6.zip C:\Adobe\Flex\SDK\4.6\SDK.zip
@@ -93,8 +99,10 @@ RUN CD C:\Adobe\Flex\SDK\4.6 && `
9399
DEL SDK.zip && `
94100
SETX FLEX_HOME "C:\Adobe\Flex\SDK\4.6"
95101

102+
RUN choco install nodejs -y
103+
96104
# Start developer command prompt with any other commands specified.
97-
ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 &&
105+
ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=x64 -host_arch=x64 &&
98106

99107
# Default to PowerShell if no other command specified.
100-
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
108+
CMD powershell.exe -NoLogo -ExecutionPolicy Bypass

build/docker/msvc2017/build-compiler.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ cd c:\build
2626

2727
:: Generate the out-of-tree build files
2828
cmake^
29-
-DBOOST_ROOT=C:\Libraries\boost_1_69_0^
30-
-DBOOST_LIBRARYDIR=C:\Libraries\boost_1_69_0\lib64-msvc-14.1^
29+
-DBOOST_ROOT=C:\Libraries\boost_1_89_0^
30+
-DBOOST_LIBRARYDIR=C:\Libraries\boost_1_89_0\lib64-msvc-14.1^
3131
-DBUILD_LIBRARIES=OFF^
3232
-DCMAKE_BUILD_TYPE=Release^
3333
-DCMAKE_INSTALL_PREFIX=C:\install^
@@ -38,7 +38,7 @@ cmake^
3838
cmake --build . --target thrift-compiler --config Release || EXIT /B
3939

4040
:: Test
41-
cmake --build . --target check || EXIT /B
41+
ctest -C Release || EXIT /B
4242

4343
:: Install
4444
cmake --install .

build/docker/msvc2017/build.bat

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ cd c:\build
2626

2727
:: Generate the out-of-tree build files
2828
cmake^
29-
-DBOOST_ROOT=C:\Libraries\boost_1_69_0^
30-
-DBOOST_LIBRARYDIR=C:\Libraries\boost_1_69_0\lib64-msvc-14.1^
31-
-DFLEX_HOME=C:\Adobe\Flex\SDK\4.6^
32-
-DLIBEVENT_ROOT=C:\Libraries\libevent-2.1.8^
33-
-DZLIB_ROOT=C:\Libraries\zlib-1.2.11^
29+
-DCMAKE_GENERATOR_PLATFORM=x64^
30+
-DBOOST_ROOT=%BOOST_ROOT%^
31+
-DFLEX_HOME=%FLEX_HOME%^
32+
-DLIBEVENT_ROOT=%LIBEVENT_ROOT%^
33+
-DZLIB_ROOT=%ZLIB_ROOT%^
3434
-DCMAKE_BUILD_TYPE=Release^
35+
-DBUILD_SHARED_LIBS=OFF^
3536
-DCMAKE_INSTALL_PREFIX=C:\install^
3637
c:\thrift || EXIT /B
3738

3839
:: Build
3940
cmake --build . --config Release || EXIT /B
4041

4142
:: Test
42-
cmake --build . --target check || EXIT /B
43+
ctest -C Release || EXIT /B
4344

4445
:: Install
4546
cmake --install .

0 commit comments

Comments
 (0)