Skip to content

Commit

Permalink
Updated Docker file to build Ops Agent Windows tarball. (#1905)
Browse files Browse the repository at this point in the history
  • Loading branch information
XuechunHou authored Mar 11, 2025
1 parent 814d004 commit 035a837
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,15 @@ WORKDIR /work
COPY . /work

RUN & .\pkg\goo\build.ps1 -DestDir /work/out;

###############################################################################
# Packaging for the Ops Agent Plugin
###############################################################################

WORKDIR /work

COPY . /work

RUN & .\pkg\plugin\build.ps1 -DestDir /work/out/bin;


2 changes: 2 additions & 0 deletions kokoro/scripts/build/build_package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Move-Item -Path "$env:KOKORO_ARTIFACTS_DIR/out/*.goo" -Destination "$env:KOKORO_
# They are not distributed to customers.
Move-Item -Path "$env:KOKORO_ARTIFACTS_DIR/out/bin/*.pdb" -Destination "$env:KOKORO_ARTIFACTS_DIR/result"
Move-Item -Path "$env:KOKORO_ARTIFACTS_DIR/out/bin/*.dll" -Destination "$env:KOKORO_ARTIFACTS_DIR/result"
# Copy Ops Agent UAP Plugin tarball to the result directory.
Move-Item -Path "$env:KOKORO_ARTIFACTS_DIR/out/bin/*.tar.gz" -Destination "$env:KOKORO_ARTIFACTS_DIR/result"

# If Kokoro is being triggered by Louhi, then Louhi needs to be able to
# reconstruct the path where the artifacts are placed. Louhi does not have
Expand Down
53 changes: 53 additions & 0 deletions pkg/plugin/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Param(
[Parameter(Mandatory=$false)][string]$DestDir,
[Parameter(Mandatory=$false)][string]$Arch
)

if (!$DestDir) {
$DestDir = '.'
}

# Read PKG_VERSION from VERSION file.
$PkgVersion = Select-String -Path "VERSION" -Pattern '^PKG_VERSION="(.*)"$' | %{$_.Matches.Groups[1].Value}

# If ARCH is not supplied, set default value based on user's system.
if (!$Arch) {
$Arch = (&{If([System.Environment]::Is64BitProcess) {'x86_64'} Else {'x86'}})
}

# Set GOARCH based on ARCH.
switch ($Arch) {
'x86_64' { $GoArch = 'amd64'; break}
'x86' { $GoArch = '386'; break}
default { Throw 'Arch must be set to one of: x86, x86_64' }
}

# Create the license directory
$LicenseDir = "$DestDir\THIRD_PARTY_LICENSES"
$Subfolder = "$LicenseDir\subfolder"

New-Item -ItemType Directory -Path $LicenseDir -Force | Out-Null
New-Item -ItemType Directory -Path $Subfolder -Force | Out-Null

"license to be added" | Out-File "$LicenseDir\text1.txt"
"license to be added" | Out-File "$Subfolder\text2.txt"

$TarFileName = "google-cloud-ops-agent-plugin-$PkgVersion-windows-$Arch.tar.gz" # Define tar file name

$FilesToInclude = @(
"msvcp140.dll",
"vccorlib140.dll",
"vcruntime140.dll",
"fluent-bit.exe",
"fluent-bit.dll",
"opentelemetry-java-contrib-jmx-metrics.jar",
"google-cloud-metrics-agent_windows_${GoArch}.exe",
"google-cloud-ops-agent-wrapper.exe"
"plugin.exe"
"THIRD_PARTY_LICENSES"
)

# Create the tar archive
& tar -cvzf "$DestDir\$TarFileName" -C "$DestDir" $FilesToInclude

Write-Host "Tar archive created: $($DestDir)\$TarFileName"

0 comments on commit 035a837

Please sign in to comment.