Skip to content

Commit bbd0fc2

Browse files
committed
dockerfiles: windows: update to ltsc 2025 and fix layers
Signed-off-by: Eduardo Silva <[email protected]>
1 parent ecdde29 commit bbd0fc2

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

dockerfiles/Dockerfile.windows

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
# - dockerfiles/Dockerfile.windows
1212
#
1313

14-
ARG WINDOWS_VERSION=ltsc2019
14+
ARG WINDOWS_VERSION=ltsc2025
1515

1616
# Builder Image - Windows Server Core
1717
FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION AS builder-base
1818

1919
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
2020

21+
# Clean up any existing temp files and create fresh temp directory
22+
RUN Remove-Item -Path $env:TEMP\* -Recurse -Force -ErrorAction SilentlyContinue; `
23+
Remove-Item -Path C:\Windows\Temp\* -Recurse -Force -ErrorAction SilentlyContinue; `
24+
New-Item -ItemType Directory -Path $env:TEMP -Force -ErrorAction SilentlyContinue;
25+
2126
# Install Visual Studio Build Tools 2019 (MSVS_VERSION=16) / 2022 (MSVS_VERSION=17, requires WINDOWS_VERSION=ltsc2022)
2227
WORKDIR /local
23-
ARG MSVS_VERSION="16"
28+
ARG MSVS_VERSION="17"
2429
ENV MSVS_BUILD_TOOLS_VERSION="$MSVS_VERSION" `
2530
MSVS_BUILD_TOOLS_DOWNLOAD_URL="https://aka.ms/vs" `
2631
MSVS_HOME="C:\BuildTools"
32+
2733
RUN $msvs_build_tools_dist_name=\"vs_buildtools.exe\"; `
2834
$msvs_build_tools_dist=\"${env:TMP}\${msvs_build_tools_dist_name}\"; `
2935
$msvs_build_tools_channel=\"C:\local\VisualStudio.chman\"; `
@@ -42,8 +48,8 @@ RUN $msvs_build_tools_dist_name=\"vs_buildtools.exe\"; `
4248
\"--installChannelUri ${msvs_build_tools_channel}\", `
4349
'--add Microsoft.VisualStudio.Workload.VCTools', `
4450
'--includeRecommended' -NoNewWindow -Wait; `
45-
Remove-Item -Force \"${msvs_build_tools_dist}\";
46-
51+
Remove-Item -Force \"${msvs_build_tools_dist}\"; `
52+
Remove-Item -Path \"${msvs_build_tools_channel}\" -Force;
4753

4854
ENV CMAKE_HOME="C:\cmake"
4955
ARG CMAKE_VERSION="3.31.6"
@@ -98,7 +104,7 @@ RUN $win_flex_bison_dist_base_name=\"win_flex_bison-${env:WIN_FLEX_BISON_VERSION
98104
Write-Host \"Copying...\"; `
99105
Write-Host \"${env:WIN_FLEX_BISON_HOME}\win_flex.exe -> ${env:WIN_FLEX_BISON_HOME}\flex.exe\"; `
100106
Copy-Item -Path \"${env:WIN_FLEX_BISON_HOME}\win_flex.exe\" \"${env:WIN_FLEX_BISON_HOME}\flex.exe\"; `
101-
$env:PATH=\"${env:PATH}${env:WIN_FLEX_BISON_HOME}\"; `
107+
$env:PATH=\"${env:PATH};${env:WIN_FLEX_BISON_HOME}\"; `
102108
Write-Host \"Setting PATH...\"; `
103109
Write-Host \"${env:PATH}\"; `
104110
[Environment]::SetEnvironmentVariable(\"PATH\", \"${env:PATH}\", [EnvironmentVariableTarget]::Machine);
@@ -127,7 +133,7 @@ RUN $vcpkg_dist_base_name=\"vcpkg-${env:VCPKG_VERSION}\"; `
127133
Write-Host \"Moving vcpkg...\"; `
128134
Write-Host \"${vcpkg_temp_dir} -> ${vcpkg_home_dir}\"; `
129135
[System.IO.Directory]::Move(\"${vcpkg_temp_dir}\", \"${vcpkg_home_dir}\"); `
130-
$env:PATH=\"${env:PATH}${vcpkg_home_dir}\"; `
136+
$env:PATH=\"${env:PATH};${vcpkg_home_dir}\"; `
131137
Write-Host \"Setting PATH...\"; `
132138
Write-Host \"${env:PATH}\"; `
133139
[Environment]::SetEnvironmentVariable(\"PATH\", \"${env:PATH}\", [EnvironmentVariableTarget]::Machine); `
@@ -138,10 +144,14 @@ RUN $vcpkg_dist_base_name=\"vcpkg-${env:VCPKG_VERSION}\"; `
138144
ENV VCPKG_BUILD_TYPE=release `
139145
VCPKG_LIBRARY_LINKAGE=static
140146

147+
# Install dependencies with cleanup between each to save space
141148
RUN vcpkg install --recurse openssl --triplet x64-windows-static; `
142-
vcpkg install --recurse libyaml --triplet x64-windows-static;
149+
vcpkg cleanup;
150+
151+
RUN vcpkg install --recurse libyaml --triplet x64-windows-static; `
152+
vcpkg cleanup;
143153

144-
# Technique from https://github.com/StefanScherer/dockerfiles-windows/blob/master/mongo/3.6/Dockerfile
154+
# Copy required runtime libraries
145155
WORKDIR /fluent-bit/bin
146156
RUN Copy-Item -Path C:\Windows\System32\msvcp140.dll -Destination /fluent-bit/bin/; `
147157
Copy-Item -Path C:\Windows\System32\vccorlib140.dll -Destination /fluent-bit/bin/; `
@@ -206,6 +216,7 @@ LABEL org.opencontainers.image.title="Fluent Bit" `
206216
org.opencontainers.image.source="https://github.com/fluent/fluent-bit" `
207217
org.opencontainers.image.revision=$IMAGE_SOURCE_REVISION
208218

219+
# Copy only the built artifacts from builder stage
209220
COPY --from=builder /fluent-bit /fluent-bit
210221

211222
RUN setx /M PATH "%PATH%;C:\fluent-bit\bin"

0 commit comments

Comments
 (0)