Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Docker file to build Ops Agent Windows tarball. #1905

Merged
merged 4 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"