Skip to content

Commit 414d3a6

Browse files
gfraiteurclaude
andcommitted
Use direct Claude CLI download with error handling and monthly cache
- Download Claude CLI directly from GCS bucket instead of install script - Add $ErrorActionPreference = 'Stop' to fail on first error - Create .local/bin directory before download - Change timestamp cache invalidation from weekly to monthly - Remove TimestampComponent dependency from ClaudeComponent Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c103afe commit 414d3a6

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

src/PostSharp.Engineering.BuildTools/Docker/ClaudeComponent.cs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,27 @@ public override void WriteDockerfile( TextWriter writer )
4545
4646
""" );
4747

48-
// Build a single multi-line RUN command for all operations
4948
writer.WriteLine(
50-
"""
51-
RUN irm https://claude.ai/install.ps1 | iex; `
52-
$claudeJsonPath = 'C:\Users\ContainerAdministrator\.claude.json'; `
53-
if (Test-Path $claudeJsonPath) { `
54-
$claudeConfig = Get-Content $claudeJsonPath -Raw | ConvertFrom-Json; `
55-
$claudeConfig | Add-Member -NotePropertyName 'hasCompletedOnboarding' -NotePropertyValue $true -Force; `
56-
$claudeConfig | ConvertTo-Json -Depth 10 | Set-Content $claudeJsonPath; `
57-
} else { `
58-
'{"hasCompletedOnboarding": true}' | Set-Content $claudeJsonPath; `
59-
}; `
60-
""" );
61-
// Add marketplaces if any are specified
49+
"""
50+
RUN $ErrorActionPreference = 'Stop'; `
51+
$version = '2.1.27'; `
52+
$url = \"https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.1.27/win32-x64/claude.exe\"; `
53+
New-Item -ItemType Directory -Path \"$env:USERPROFILE\.local\bin\" -Force | Out-Null; `
54+
echo \"Downloading Claude CLI from $url...\"; `
55+
Invoke-WebRequest -Uri $url -OutFile \"$env:USERPROFILE\.local\bin\claude.exe\"; `
56+
echo 'Claude CLI $version installed.'; `
57+
echo \"Configuring Claude CLI...\"; `
58+
if (Test-Path $claudeJsonPath) { `
59+
$claudeConfig = Get-Content $claudeJsonPath -Raw | ConvertFrom-Json; `
60+
$claudeConfig | Add-Member -NotePropertyName 'hasCompletedOnboarding' -NotePropertyValue $true -Force; `
61+
$claudeConfig | ConvertTo-Json -Depth 10 | Set-Content $claudeJsonPath; `
62+
} else { `
63+
'{"hasCompletedOnboarding": true}' | Set-Content $claudeJsonPath; `
64+
}; `
65+
echo 'Configuring Claude CLI plugins.';`
66+
67+
""" );
68+
6269
foreach ( var marketplace in this.Marketplaces )
6370
{
6471
writer.WriteLine( $" claude plugin marketplace add {marketplace}; `" );
@@ -70,7 +77,7 @@ public override void WriteDockerfile( TextWriter writer )
7077
writer.WriteLine( $" claude plugin install {plugin}; `" );
7178
}
7279

73-
writer.WriteLine(" echo 'Claude CLI installation completed.'");
80+
writer.WriteLine( $" echo \"Claude $version installed\"" );
7481
writer.WriteLine();
7582
}
7683

@@ -83,11 +90,5 @@ public override void AddRequirements( IReadOnlyList<ContainerComponent> componen
8390
{
8491
add( new GitHubCliComponent() );
8592
}
86-
87-
// Auto-add TimestampComponent for cache invalidation
88-
if ( !components.OfType<TimestampComponent>().Any() )
89-
{
90-
add( new TimestampComponent() );
91-
}
9293
}
9394
}

src/PostSharp.Engineering.BuildTools/Resources/DockerBuild.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ param(
1313
[switch]$NoMcp, # Do not start the MCP approval server (for -Claude mode).
1414
[switch]$Update, # Update timestamp to invalidate Docker cache and force Claude/plugin updates (Claude mode only).
1515
# Timestamp value for Docker cache invalidation. Increase this to force updates of unpinned components like Claude CLI.
16-
# If not specified, defaults to the first day of the current week (so cache auto-invalidates weekly).
16+
# If not specified, defaults to the first day of the current month (so cache auto-invalidates monthly).
1717
[string]$Timestamp,
1818
[string]$ImageName, # Image name (defaults to a name based on the directory).
1919
[string]$BuildAgentPath, # Path to build agent directory (defaults based on platform).
@@ -334,12 +334,10 @@ function New-TeamCityTimestampFile
334334

335335
if ([string]::IsNullOrEmpty($TimestampValue))
336336
{
337-
# Default to first day of current week (Monday) for weekly cache invalidation
337+
# Default to first day of current month for monthly cache invalidation
338338
$today = [DateTime]::UtcNow.Date
339-
$daysFromMonday = [int]$today.DayOfWeek - 1
340-
if ($daysFromMonday -lt 0) { $daysFromMonday = 6 } # Sunday = 6 days from Monday
341-
$firstDayOfWeek = $today.AddDays(-$daysFromMonday)
342-
$TimestampValue = $firstDayOfWeek.ToString("yyyy-MM-dd")
339+
$firstDayOfMonth = [DateTime]::new($today.Year, $today.Month, 1)
340+
$TimestampValue = $firstDayOfMonth.ToString("yyyy-MM-dd")
343341
}
344342

345343
$gDirectory = Join-Path $DockerContextDir ".g"

0 commit comments

Comments
 (0)