Skip to content
Open
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
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ RUN if [ -z "$EXECUTABLE_NAME" ]; then \
echo "ERROR: EXECUTABLE_NAME build argument is required" && exit 1; \
fi

RUN apk add --no-cache libc6-compat

# Copy the contents of the publish directory to '/mcp-server' and set it as the working directory
RUN mkdir -p /mcp-server
COPY ${PUBLISH_DIR} /mcp-server/
Expand All @@ -31,7 +29,7 @@ RUN ls -la
RUN if [ ! -f $EXECUTABLE_NAME ]; then \
echo "ERROR: $EXECUTABLE_NAME executable does not exist" && exit 1; \
fi

# Copy the server binary to a known location and make it executable
COPY ${PUBLISH_DIR}/${EXECUTABLE_NAME} server-binary
RUN chmod +x server-binary && test -x server-binary
Expand Down
1 change: 1 addition & 0 deletions eng/scripts/Build-Docker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ try {

$dockerArch = switch($platform.architecture) {
"x64" { "amd64" }
"musl-x64" { "amd64" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in DockerFile we can now remove the line that adds shim package -
 

 RUN apk add --no-cache libc6-compat

"arm64" { "arm64" }
default {
LogWarning "Skipping unsupported architecture $($platform.architecture) for server $serverName"
Expand Down
113 changes: 58 additions & 55 deletions eng/scripts/New-BuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,45 @@ $isPipelineRun = $CI -or $env:TF_BUILD -eq 'true'
$isPullRequestBuild = $env:BUILD_REASON -eq 'PullRequest'
$exitCode = 0

# We currently only want to build linux-x64 native
$nativePlatforms = @(
'linux-x64-native'
#'linux-arm64-native' We can't currently build arm64 native in a CI run
#'macos-x64-native'
#'macos-arm64-native'
#'windows-x64-native'
#'windows-arm64-native'
)
$architectures = @('x64', 'arm64')

# When native builds are shipped, we still may want to build only linux-x64 native in pull requests for pipeline performance
# if ($isPipelineRun -and $PublishTarget -eq 'none') {
# $nativePlatforms = @('linux-x64-native')
# }
# Get-OperatingSystems returns an array of objects with properties: name, nodeName, dotnetName, extension
$operatingSystems = Get-OperatingSystems

# Until https://github.com/microsoft/mcp/issues/1051 is fixed, to support hosted mcp servers, we need to ensure there
# are untrimmed versions of certain platforms available to the docker packaging step
$additionalUntrimmedPlatforms = @(
'linux-x64'
# Platform names, e.g. windows-arm64, from the standard $operatingSystems X $architectures combinations that should not be built.
$excludedPlatforms = @(
# Currently, all standard platforms are included
)

# Platforms outside of the standard combinations that should also be built. Setting a "specialPurpose" allows then to
# be targeted or excluded in packaging scripts
$additionalPlatforms = @(
# Until https://github.com/microsoft/mcp/issues/1051 is fixed, to support hosted mcp servers, we need to ensure there
# are untrimmed versions of certain identity-compatible platforms available to the docker packaging step
@{
name = 'linux-musl-x64-docker'
operatingSystem = 'linux'
architecture = 'musl-x64'
native = $false
trimmed = $false
specialPurpose = 'docker'
}
)

if ($IncludeNative) {
# We currently only want to build linux-x64 native
# When native builds are shipped, we still may want to build only linux-x64 native in pull requests for pipeline performance

$additionalPlatforms += @{
name = 'linux-x64-native'
operatingSystem = 'linux'
architecture = 'x64'
native = $true
trimmed = $false
specialPurpose = 'native'
}
}

if ($BuildId -eq 0) {
if ($isPipelineRun) {
LogError 'A non-zero BuildId is required when running in a pipeline.'
Expand All @@ -62,10 +80,6 @@ $serverDirectories = Get-ChildItem "$RepoRoot/servers" -Directory
$toolDirectories = Get-ChildItem "$RepoRoot/tools" -Directory
$coreDirectories = Get-ChildItem "$RepoRoot/core" -Directory

$architectures = @('x64', 'arm64')

$operatingSystems = Get-OperatingSystems

# Public releases always use the version from the repo without a dynamic prerelease suffix, except for test pipelines
# which always use a dynamic prerelease suffix to allow for multiple releases from the same commit
$dynamicPrereleaseVersion = $PublishTarget -ne 'public' -or $TestPipeline
Expand Down Expand Up @@ -432,7 +446,6 @@ function Get-ServerDetails {
foreach ($os in $operatingSystems) {
foreach ($arch in $architectures) {
$name = "$($os.name)-$arch"
$nativeName = "$name-native"

if ($excludedPlatforms -notcontains $name) {
$platforms += [ordered]@{
Expand All @@ -447,40 +460,30 @@ function Get-ServerDetails {
trimmed = $true
}
}
}
}

$shouldIncludeNative = $IncludeNative -and
$props.IsAotCompatible -eq 'true' -and
$nativePlatforms -contains $nativeName
foreach ($additionalPlatform in $additionalPlatforms) {
$name = $additionalPlatform.name
$os = $operatingSystems | Where-Object { $_.name -eq $additionalPlatform.operatingSystem }

if($shouldIncludeNative) {
$platforms += [ordered]@{
name = $nativeName
artifactPath = "$serverName/$nativeName"
operatingSystem = $os.name
nodeOs = $os.nodeName
dotnetOs = $os.dotnetName
architecture = $arch
extension = $os.extension
native = $true
trimmed = $false
}
}
if (-not $os) {
LogError "Additional platform $name has unknown operating system $($additionalPlatform.operatingSystem)"
$script:exitCode = 1
continue
}

if($additionalUntrimmedPlatforms -contains $name) {
$untrimmedName = "$name-untrimmed"
$platforms += [ordered]@{
name = $untrimmedName
artifactPath = "$serverName/$untrimmedName"
operatingSystem = $os.name
nodeOs = $os.nodeName
dotnetOs = $os.dotnetName
architecture = $arch
extension = $os.extension
native = $false
trimmed = $false
specialPurpose = 'untrimmed'
}
}
$platforms += [ordered]@{
name = $name
artifactPath = "$serverName/$name"
operatingSystem = $os.name
nodeOs = $os.nodeName
dotnetOs = $os.dotnetName
architecture = $additionalPlatform.architecture
extension = $os.extension
native = $additionalPlatform.native
trimmed = $additionalPlatform.trimmed
specialPurpose = $additionalPlatform.specialPurpose
}
}

Expand All @@ -507,9 +510,9 @@ function Get-ServerDetails {
dnxDescription = $props.DnxDescription
dnxToolCommandName = $props.DnxToolCommandName
dnxPackageTags = @($props.DnxPackageTags -split '[;,] *' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' })
platforms = $platforms
mcpRepositoryName = $props.McpRepositoryName
serverJsonPath = $props.ServerJsonPath | Get-RepoRelativePath -NormalizeSeparators
platforms = $platforms
}
}

Expand Down Expand Up @@ -587,7 +590,7 @@ function Get-ServerMatrix {
Write-Host "Forming server matrix"

$serverMatrix = [ordered]@{}
$platformName = "linux-x64-untrimmed"
$platformName = "linux-musl-x64-docker"

foreach ($server in $servers) {
$platform = $server.platforms | Where-Object { $_.name -eq $platformName -and -not $_.native }
Expand Down
10 changes: 8 additions & 2 deletions eng/scripts/Prepare-Docker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ Remove-Item -Path $OutputPath -Recurse -Force -ErrorAction SilentlyContinue -Pro
Push-Location $RepoRoot
try {
$buildInfo = Get-Content $BuildInfoPath -Raw | ConvertFrom-Json
$platformName = "linux-x64-untrimmed"
$platformName = "linux-musl-x64-docker"

foreach($server in $buildInfo.servers) {
$platform = $server.platforms | Where-Object { $_.name -eq $platformName -and -not $_.native }
$platform = $server.platforms | Where-Object { $_.name -eq $platformName }
if(-not $platform) {
LogError "Server $($server.name) does not have a platform named $platformName in build_info.json"
$exitCode = 1
continue
}

$platformOutputPath = "$OutputPath/$($server.artifactPath)/$platformName"

New-Item -ItemType Directory -Force -Path $platformOutputPath | Out-Null
Expand Down
Loading