Skip to content

Commit 76a8e10

Browse files
ClaudeComponent: install latest version instead of hardcoded, with daily cache invalidation
Move Claude after the timestamp layer so Docker cache busts daily, use @latest npm tag, and auto-require TimestampComponent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7224a27 commit 76a8e10

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

eng/docker/Dockerfile.claude

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,20 @@ ENV NPM_CONFIG_PREFIX=C:\npm
7272
ENV PATH="C:\nodejs;C:\npm;${PATH}"
7373

7474

75+
# Timestamp
76+
# Cache invalidation layer - changes when -Update is used
77+
COPY .g/update.timestamp C:\docker-context\update.timestamp
78+
RUN Write-Host "PostSharp.Engineering build timestamp: $(Get-Content C:\docker-context\update.timestamp)"
79+
80+
7581
# Install Claude CLI
7682
# Set HOME/USERPROFILE so Claude CLI finds credentials during build
7783
ENV HOME=C:\\Users\\ContainerAdministrator
7884
ENV USERPROFILE=C:\\Users\\ContainerAdministrator
7985

8086
# Install Claude CLI and configure using cmd shell to avoid HCS issues with PowerShell
8187
SHELL ["cmd", "/S", "/C"]
82-
RUN C:\nodejs\npm.cmd install --global @anthropic-ai/claude-code@2.1.81
88+
RUN C:\nodejs\npm.cmd install --global @anthropic-ai/claude-code@latest
8389
RUN mkdir C:\Users\ContainerAdministrator\.claude && echo {"hasCompletedOnboarding": true} > C:\Users\ContainerAdministrator\.claude.json && echo {"alwaysThinkingEnabled": true, "spinnerTipsEnabled": false} > C:\Users\ContainerAdministrator\.claude\settings.json
8490

8591
# Restore PowerShell shell using full path

eng/docker/Dockerfile.claude.win2022

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,20 @@ ENV NPM_CONFIG_PREFIX=C:\npm
7272
ENV PATH="C:\nodejs;C:\npm;${PATH}"
7373

7474

75+
# Timestamp
76+
# Cache invalidation layer - changes when -Update is used
77+
COPY .g/update.timestamp C:\docker-context\update.timestamp
78+
RUN Write-Host "PostSharp.Engineering build timestamp: $(Get-Content C:\docker-context\update.timestamp)"
79+
80+
7581
# Install Claude CLI
7682
# Set HOME/USERPROFILE so Claude CLI finds credentials during build
7783
ENV HOME=C:\\Users\\ContainerAdministrator
7884
ENV USERPROFILE=C:\\Users\\ContainerAdministrator
7985

8086
# Install Claude CLI and configure using cmd shell to avoid HCS issues with PowerShell
8187
SHELL ["cmd", "/S", "/C"]
82-
RUN C:\nodejs\npm.cmd install --global @anthropic-ai/claude-code@2.1.81
88+
RUN C:\nodejs\npm.cmd install --global @anthropic-ai/claude-code@latest
8389
RUN mkdir C:\Users\ContainerAdministrator\.claude && echo {"hasCompletedOnboarding": true} > C:\Users\ContainerAdministrator\.claude.json && echo {"alwaysThinkingEnabled": true, "spinnerTipsEnabled": false} > C:\Users\ContainerAdministrator\.claude\settings.json
8490

8591
# Restore PowerShell shell using full path

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
namespace PostSharp.Engineering.BuildTools.Docker;
99

1010
/// <summary>
11-
/// Installs the Claude CLI. This component is placed before the timestamp for caching.
12-
/// Plugin installation is handled by <see cref="ClaudeAddInsComponent"/> which runs after the timestamp.
11+
/// Installs the Claude CLI. This component is placed after the timestamp so that the latest version
12+
/// is installed whenever the Docker image is rebuilt. Plugin installation is handled by <see cref="ClaudeAddInsComponent"/>.
1313
/// </summary>
1414
public class ClaudeComponent : ContainerComponent
1515
{
1616
private const string _minNodeVersion = "22.0.0";
17-
private const string _claudeVersion = "2.1.81";
18-
1917
public override string Name => "Install Claude CLI";
2018

2119
public override ContainerComponentKind Kind => ContainerComponentKind.Claude;
@@ -36,7 +34,7 @@ public override void WriteDockerfile( TextWriter writer, ContainerOperatingSyste
3634
""" );
3735

3836
// Build a single multi-line RUN command for all operations
39-
writer.WriteLine( $"RUN C:\\nodejs\\npm.cmd install --global @anthropic-ai/claude-code@{_claudeVersion}" );
37+
writer.WriteLine( "RUN C:\\nodejs\\npm.cmd install --global @anthropic-ai/claude-code@latest" );
4038
writer.Write( "RUN mkdir C:\\Users\\ContainerAdministrator\\.claude" );
4139
writer.Write( " && echo {\"hasCompletedOnboarding\": true} > C:\\Users\\ContainerAdministrator\\.claude.json" );
4240
writer.Write( " && echo {\"alwaysThinkingEnabled\": true, \"spinnerTipsEnabled\": false} > C:\\Users\\ContainerAdministrator\\.claude\\settings.json" );
@@ -66,6 +64,10 @@ public override void AddRequirements( IReadOnlyList<ContainerComponent> componen
6664
throw new InvalidOperationException( $"Claude CLI requires Node.js >= {_minNodeVersion}, but {existingNodeJs.Version} is configured." );
6765
}
6866

69-
// We don't add GitHub CLI because we don't have pass the token anyway.
67+
// Require timestamp component for cache invalidation so @latest resolves on each daily build.
68+
if ( !components.OfType<TimestampComponent>().Any() )
69+
{
70+
add( new TimestampComponent() );
71+
}
7072
}
7173
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public enum ContainerComponentKind
1919
GitHubCli,
2020
AzureCli,
2121
AzureArtifactsCredentialProvider,
22-
Claude,
2322
Timestamp,
23+
Claude,
2424
ClaudeAddIns,
2525
Epilogue
2626
}

0 commit comments

Comments
 (0)