-
Notifications
You must be signed in to change notification settings - Fork 68
/
Dockerfile.windows
259 lines (208 loc) · 9.75 KB
/
Dockerfile.windows
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# escape=`
ARG WINDOWS_VERSION=ltsc2019
#
# Builder Image - Windows Server Core
#
FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION as base
#
# Basic setup
#
RUN setx /M PATH "%PATH%;C:\WinFlexBison;C:\Go\bin;C:\Java\bin;C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
RUN setx /M JAVA_HOME "C:\Java"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Write-Host ('Creating folders'); `
New-Item -Type Directory -Path /local; `
New-Item -Type Directory -Path /work/out/bin; `
New-Item -Type Directory -Path /work/out/config;
###############################################################################
# Install build prerequisites
###############################################################################
WORKDIR /local
#
# Install Visual Studio 2019
#
ADD https://aka.ms/vs/16/release/vs_buildtools.exe /local/vs_buildtools.exe
ADD https://aka.ms/vs/16/release/channel /local/VisualStudio.chman
RUN Start-Process /local/vs_buildtools.exe `
-ArgumentList '--quiet ', '--wait ', '--norestart ', '--nocache', `
'--installPath C:\BuildTools', `
'--channelUri C:\local\VisualStudio.chman', `
'--installChannelUri C:\local\VisualStudio.chman', `
'--add Microsoft.VisualStudio.Workload.VCTools', `
'--includeRecommended' -NoNewWindow -Wait;
#
# Technique from https://github.com/StefanScherer/dockerfiles-windows/blob/master/mongo/3.6/Dockerfile
#
ADD https://aka.ms/vs/15/release/vc_redist.x64.exe /local/vc_redist.x64.exe
RUN Write-Host ('Installing Visual C++ Redistributable Package'); `
Start-Process /local/vc_redist.x64.exe -ArgumentList '/install', '/quiet', '/norestart' -NoNewWindow -Wait; `
Copy-Item -Path /Windows/System32/msvcp140.dll -Destination /work/out/bin/; `
Copy-Item -Path /Windows/System32/vccorlib140.dll -Destination /work/out/bin/; `
Copy-Item -Path /Windows/System32/vcruntime140.dll -Destination /work/out/bin/;
#
# Install OpenSSL
# This must be done after installing Visual Studio
RUN $files = (iwr -UseBasicParsing https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json | ConvertFrom-Json).files.psobject.properties.value; `
$installer = $files | ? {$_.arch -eq \"INTEL\" -and $_.bits -eq 64 -and $_.installer -eq \"msi\" -and -not $_.light -and $_.basever -like \"1.*\" }; `
iwr -UseBasicParsing -Uri \"$($installer.url)\" -OutFile /local/openssl.msi; `
$ActualHash = $(Get-FileHash /local/openssl.msi -Algorithm SHA256).Hash.ToLower(); `
if ($ActualHash -ne \"$($installer.sha256)\") { `
throw \"OpenSSL hash mismatch. Expected: $($installer.sha256), Actual: $ActualHash\" `
}; `
Start-Process msiexec.exe -Wait -ArgumentList \"/i C:\local\openssl.msi /quiet\";
#
# Install winflexbison
#
ADD https://github.com/lexxmark/winflexbison/releases/download/v2.5.22/win_flex_bison-2.5.22.zip /local/win_flex_bison.zip
RUN Expand-Archive /local/win_flex_bison.zip -Destination /WinFlexBison; `
Copy-Item -Path /WinFlexBison/win_bison.exe /WinFlexBison/bison.exe; `
Copy-Item -Path /WinFlexBison/win_flex.exe /WinFlexBison/flex.exe;
#
# Install Golang
#
ADD https://go.dev/dl/go1.21.11.windows-amd64.msi /local/go1.21.11.windows-amd64.msi
RUN Start-Process msiexec.exe `
-ArgumentList '/i C:\local\go1.21.11.windows-amd64.msi ', '/quiet ', `
'/norestart ', 'ALLUSERS=1,INSTALLDIR=C:\Go' -NoNewWindow -Wait;
#
# Install Go build tools
#
# Run these in a directory with a go.mod file so that "go get" doesn't need
# a working Git installation.
WORKDIR /goget
RUN go install github.com/google/googet/v2/goopack@latest;
###############################################################################
# Build fluent-bit
###############################################################################
COPY submodules/fluent-bit /work/submodules/fluent-bit
WORKDIR /work/submodules/fluent-bit/build
RUN cmake -G "'Visual Studio 16 2019'" -DCMAKE_BUILD_TYPE=RELWITHDEBINFO `
-DFLB_WINDOWS_DEFAULTS=Off `
-DFLB_REGEX=On `
-DFLB_BACKTRACE=Off `
-DFLB_CONFIG_YAML=Off `
-DFLB_LUAJIT=On `
-DFLB_EXAMPLES=On `
-DFLB_PARSER=On `
-DFLB_TLS=On `
-DFLB_HTTP_SERVER=On `
-DFLB_METRICS=On `
-DFLB_WASM=Off `
-DFLB_WAMRC=Off `
-DFLB_IN_CPU=Off `
-DFLB_IN_DISK=Off `
-DFLB_IN_EXEC=On `
-DFLB_IN_EXEC_WASI=Off `
-DFLB_IN_FORWARD=On `
-DFLB_IN_HEALTH=Off `
-DFLB_IN_HTTP=On `
-DFLB_IN_MEM=Off `
-DFLB_IN_KAFKA=Off `
-DFLB_IN_KMSG=Off `
-DFLB_IN_LIB=On `
-DFLB_IN_RANDOM=On `
-DFLB_IN_SERIAL=Off `
-DFLB_IN_STDIN=Off `
-DFLB_IN_SYSLOG=On `
-DFLB_IN_TAIL=On `
-DFLB_IN_TCP=On `
-DFLB_IN_MQTT=Off `
-DFLB_IN_HEAD=Off `
-DFLB_IN_PROC=Off `
-DFLB_IN_SYSTEMD=Off `
-DFLB_IN_DUMMY=On `
-DFLB_IN_NETIF=Off `
-DFLB_IN_WINLOG=On `
-DFLB_IN_WINSTAT=On `
-DFLB_IN_WINEVTLOG=On `
-DFLB_IN_COLLECTD=Off `
-DFLB_IN_STATSD=On `
-DFLB_IN_STORAGE_BACKLOG=On `
-DFLB_IN_EMITTER=On `
-DFLB_IN_PODMAN_METRICS=Off `
-DFLB_OUT_BIGQUERY=Off `
-DFLB_OUT_COUNTER=On `
-DFLB_OUT_EXIT=Off `
-DFLB_OUT_FORWARD=On `
-DFLB_OUT_GELF=On `
-DFLB_OUT_HTTP=On `
-DFLB_OUT_NATS=Off `
-DFLB_OUT_PLOT=Off `
-DFLB_OUT_FILE=On `
-DFLB_OUT_TD=Off `
-DFLB_OUT_RETRY=Off `
-DFLB_OUT_STACKDRIVER=On `
-DFLB_OUT_STDOUT=On `
-DFLB_OUT_LIB=On `
-DFLB_OUT_NULL=On `
-DFLB_OUT_FLOWCOUNTER=On `
-DFLB_OUT_KAFKA=Off `
-DFLB_OUT_KAFKA_REST=Off `
-DFLB_FILTER_GREP=On `
-DFLB_FILTER_MODIFY=On `
-DFLB_FILTER_STDOUT=On `
-DFLB_FILTER_PARSER=On `
-DFLB_FILTER_THROTTLE=On `
-DFLB_FILTER_THROTTLE_SIZE=On `
-DFLB_FILTER_NEST=On `
-DFLB_FILTER_LUA=On `
-DFLB_FILTER_RECORD_MODIFIER=On `
-DFLB_FILTER_REWRITE_TAG=On `
-DFLB_FILTER_WASM=Off ../;
RUN cmake --build . --config Release; `
Copy-Item -Path bin/Release/fluent-bit.exe -Destination /work/out/bin/; `
Copy-Item -Path bin/Release/fluent-bit.dll -Destination /work/out/bin/; `
Copy-Item -Path bin/Release/fluent-bit.pdb -Destination /work/out/bin/; `
Copy-Item -Path bin/Release/fluent-bit.dll.pdb -Destination /work/out/bin/;
# TODO: Do something with /work/out/bin/fluent-bit.{exe,dll}
###############################################################################
# Build JMX Project here so it can be hashed for
# a required build flag to support jmx receiver in operations-collector
###############################################################################
ADD https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8%2B7/OpenJDK17U-jdk_x64_windows_hotspot_17.0.8_7.msi /local/jdk-17-windows-x64.msi
RUN Start-Process -Wait 'msiexec' -ArgumentList '/i C:\local\jdk-17-windows-x64.msi ADDLOCAL=FeatureMain INSTALLDIR=C:\Java\ /log c:\java_install64.log'
COPY submodules/opentelemetry-java-contrib /work/submodules/opentelemetry-java-contrib
WORKDIR /work/submodules/opentelemetry-java-contrib
RUN ./gradlew --no-daemon :jmx-metrics:build; `
Copy-Item -Path jmx-metrics/build/libs/opentelemetry-jmx-metrics-*-alpha-SNAPSHOT.jar -Destination /work/out/bin/opentelemetry-java-contrib-jmx-metrics.jar;
###############################################################################
# Build OT collector
###############################################################################
COPY submodules/opentelemetry-operations-collector /work/submodules/opentelemetry-operations-collector
WORKDIR /work/submodules/opentelemetry-operations-collector
RUN $JarHash = (Get-FileHash /work/out/bin/opentelemetry-java-contrib-jmx-metrics.jar -Algorithm SHA256 | Select -Expand Hash).toLower(); `
go build -o bin/google-cloud-metrics-agent_windows_amd64.exe `
-ldflags \"-X github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver.MetricsGathererHash=$JarHash\" `
./cmd/otelopscol; `
Copy-Item -Path bin/google-cloud-metrics-agent_windows_amd64.exe -Destination /work/out/bin/;
###############################################################################
# Config generator/service installer
###############################################################################
WORKDIR /work
COPY . /work
ARG WINDOWS_VERSION
ARG BUILD_DISTRO=windows-$WINDOWS_VERSION
RUN Get-Content VERSION | Where-Object length | ForEach-Object { Invoke-Expression "`$env:$_" }; `
go build -o bin/google-cloud-ops-agent.exe -ldflags \"-X github.com/GoogleCloudPlatform/ops-agent/internal/version.BuildDistro=$env:BUILD_DISTRO -X github.com/GoogleCloudPlatform/ops-agent/internal/version.Version=$env:PKG_VERSION\" ./cmd/ops_agent_windows; `
Copy-Item -Path bin/google-cloud-ops-agent.exe -Destination /work/out/bin/; `
Copy-Item -Path confgenerator/default-config.yaml -Destination /work/out/config/config.yaml;
###############################################################################
# Build diagnostic service
###############################################################################
WORKDIR /work
COPY . /work
RUN go build -o bin/google-cloud-ops-agent-diagnostics.exe ./cmd/google_cloud_ops_agent_diagnostics; `
Copy-Item -Path bin/google-cloud-ops-agent-diagnostics.exe -Destination /work/out/bin/;
###############################################################################
# Build agent wrapping tool
###############################################################################
WORKDIR /work
COPY . /work
RUN go build -o bin/google-cloud-ops-agent-wrapper.exe ./cmd/agent_wrapper; `
Copy-Item -Path bin/google-cloud-ops-agent-wrapper.exe -Destination /work/out/bin/;
###############################################################################
# Packaging
###############################################################################
WORKDIR /work
COPY . /work
RUN & .\pkg\goo\build.ps1 -DestDir /work/out;