forked from GoogleCloudPlatform/ops-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.windows
177 lines (130 loc) · 7.48 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
# 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:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
RUN setx /M PATH "%PATH%;C:\WinFlexBison"
RUN setx /M PATH "%PATH%;C:\Go\bin"
RUN setx /M PATH "%PATH%;C:\Java\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 1.19
#
ADD https://go.dev/dl/go1.19.windows-amd64.msi /local/go1.19.windows-amd64.msi
RUN Start-Process msiexec.exe `
-ArgumentList '/i C:\local\go1.19.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_OUT_KINESIS_STREAMS=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/;
# 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/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_windows_hotspot_11.0.12_7.msi /local/jdk-11-windows-x64.msi
RUN Start-Process -Wait 'msiexec' -ArgumentList '/i C:\local\jdk-11-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-*-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/;
###############################################################################
# Packaging
###############################################################################
WORKDIR /work
COPY . /work
RUN & .\pkg\goo\build.ps1 -DestDir /work/out;