1# escape=`
2
3ARG WINDOWS_VERSION=ltsc2019
4
5#
6# Builder Image - Windows Server Core
7#
8FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION as builder
9
10# The FLUENTBIT_VERSION ARG must be after the FROM instruction
11ARG FLUENTBIT_VERSION
12ARG IMAGE_CREATE_DATE
13ARG IMAGE_SOURCE_REVISION
14
15# Metadata as defined in OCI image spec annotations
16# https://github.com/opencontainers/image-spec/blob/master/annotations.md
17LABEL org.opencontainers.image.title="Fluent Bit" `
18      org.opencontainers.image.description="Fluent Bit is an open source and multi-platform Log Processor and Forwarder which allows you to collect data/logs from different sources, unify and send them to multiple destinations. It's fully compatible with Docker and Kubernetes environments." `
19      org.opencontainers.image.created=$IMAGE_CREATE_DATE `
20      org.opencontainers.image.version=$FLUENTBIT_VERSION `
21      org.opencontainers.image.authors="Eduardo Silva <eduardo@treasure-data.com>" `
22      org.opencontainers.image.url="https://hub.docker.com/r/fluent/fluent-bit" `
23      org.opencontainers.image.documentation="https://docs.fluentbit.io/manual/" `
24      org.opencontainers.image.vendor="Fluent Organization" `
25      org.opencontainers.image.licenses="Apache-2.0" `
26      org.opencontainers.image.source="https://github.com/fluent/fluent-bit" `
27      org.opencontainers.image.revision=$IMAGE_SOURCE_REVISION
28
29#
30# Basic setup
31#
32RUN setx /M PATH "%PATH%;C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
33RUN setx /M PATH "%PATH%;C:\WinFlexBison"
34
35SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
36
37RUN Write-Host ('Creating folders'); `
38    New-Item -Type Directory -Path /local; `
39    New-Item -Type Directory -Path /fluent-bit/bin;
40
41WORKDIR /local
42
43#
44# Install Visual Studio 2019
45#
46ADD https://aka.ms/vs/16/release/vs_buildtools.exe /local/vs_buildtools.exe
47ADD https://aka.ms/vs/16/release/channel /local/VisualStudio.chman
48
49RUN Start-Process /local/vs_buildtools.exe `
50    -ArgumentList '--quiet ', '--wait ', '--norestart ', '--nocache', `
51    '--installPath C:\BuildTools', `
52    '--channelUri C:\local\VisualStudio.chman', `
53    '--installChannelUri C:\local\VisualStudio.chman', `
54    '--add Microsoft.VisualStudio.Workload.VCTools', `
55    '--includeRecommended'  -NoNewWindow -Wait;
56
57#
58# Technique from https://github.com/StefanScherer/dockerfiles-windows/blob/master/mongo/3.6/Dockerfile
59#
60ADD https://aka.ms/vs/15/release/vc_redist.x64.exe /local/vc_redist.x64.exe
61
62RUN Write-Host ('Installing Visual C++ Redistributable Package'); `
63    Start-Process /local/vc_redist.x64.exe -ArgumentList '/install', '/quiet', '/norestart' -NoNewWindow -Wait; `
64    Copy-Item -Path /Windows/System32/msvcp140.dll -Destination /fluent-bit/bin/; `
65    Copy-Item -Path /Windows/System32/vccorlib140.dll -Destination /fluent-bit/bin/; `
66    Copy-Item -Path /Windows/System32/vcruntime140.dll -Destination /fluent-bit/bin/;
67
68#
69# Install winflexbison
70#
71ADD https://github.com/lexxmark/winflexbison/releases/download/v2.5.22/win_flex_bison-2.5.22.zip /local/win_flex_bison.zip
72
73RUN Expand-Archive /local/win_flex_bison.zip -Destination /WinFlexBison; `
74    Copy-Item -Path /WinFlexBison/win_bison.exe /WinFlexBison/bison.exe; `
75    Copy-Item -Path /WinFlexBison/win_flex.exe /WinFlexBison/flex.exe;
76
77#
78# Install Fluent Bit
79#
80COPY . /src/
81
82WORKDIR /src/build
83
84RUN cmake -G "'Visual Studio 16 2019'" -DCMAKE_BUILD_TYPE=Release ../;
85
86RUN cmake --build . --config Release;
87
88RUN Copy-Item /src/build/bin/Release/fluent-bit.exe /fluent-bit/bin/; `
89    Copy-Item /src/build/bin/Release/fluent-bit.dll /fluent-bit/bin/; `
90    Copy-Item -Recurse /src/include /fluent-bit; `
91    Copy-Item -Recurse /src/conf /fluent-bit;
92
93#
94# Runtime Image - Windows Server Nano
95#
96FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION as runtime
97
98COPY --from=builder /fluent-bit /fluent-bit
99
100RUN setx /M PATH "%PATH%;C:\fluent-bit\bin"
101
102ENTRYPOINT ["fluent-bit.exe", "-i", "dummy", "-o", "stdout"]
103