Skip to content

Commit 50c4e2b

Browse files
gfraiteurclaude
andcommitted
Set locale to C.UTF-8 in Docker containers for consistent behavior
Adds LANG and LC_ALL environment variables in the Dockerfile prolog to prevent container behavior from depending on the host's locale. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7b7a9bd commit 50c4e2b

3 files changed

Lines changed: 52 additions & 40 deletions

File tree

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ ENV TEMP=C:\Temp
1414
ENV TMP=C:\Temp
1515
ENV RUNNING_IN_DOCKER=TRUE
1616

17+
# Set locale for consistent behavior regardless of host locale
18+
ENV LANG=C.UTF-8
19+
ENV LC_ALL=C.UTF-8
20+
1721
# Add Windows PowerShell to PATH (pwsh added later by PowershellComponent)
1822
ENV PATH="C:\Windows\System32\WindowsPowerShell\v1.0;${PATH}"
1923

Dockerfile.claude

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ ENV TEMP=C:\Temp
1414
ENV TMP=C:\Temp
1515
ENV RUNNING_IN_DOCKER=TRUE
1616

17+
# Set locale for consistent behavior regardless of host locale
18+
ENV LANG=C.UTF-8
19+
ENV LC_ALL=C.UTF-8
20+
1721
# Add Windows PowerShell to PATH (pwsh added later by PowershellComponent)
1822
ENV PATH="C:\Windows\System32\WindowsPowerShell\v1.0;${PATH}"
1923

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
1-
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2-
3-
using System.IO;
4-
5-
namespace PostSharp.Engineering.BuildTools.Docker;
6-
7-
internal class PrologComponent : ContainerComponent
8-
{
9-
public override string Name => "Prolog";
10-
11-
public override ContainerComponentKind Kind => ContainerComponentKind.Prolog;
12-
13-
public override void WriteDockerfile( TextWriter writer )
14-
{
15-
writer.WriteLine(
16-
"""
17-
# escape=`
18-
19-
# This file is auto-generated by PostSharp.Engineering.
20-
21-
FROM mcr.microsoft.com/windows/servercore:ltsc2025
22-
23-
# The initial shell is Windows PowerShell (use full path to avoid HCS issues)
24-
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-Command"]
25-
26-
# Prepare environment
27-
ENV PSExecutionPolicyPreference=Bypass
28-
ENV POWERSHELL_UPDATECHECK=Off
29-
ENV TEMP=C:\Temp
30-
ENV TMP=C:\Temp
31-
ENV RUNNING_IN_DOCKER=TRUE
32-
33-
# Add Windows PowerShell to PATH (pwsh added later by PowershellComponent)
34-
ENV PATH="C:\Windows\System32\WindowsPowerShell\v1.0;${PATH}"
35-
36-
# Enable long path support
37-
RUN Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
38-
39-
""" );
40-
}
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
using System.IO;
4+
5+
namespace PostSharp.Engineering.BuildTools.Docker;
6+
7+
internal class PrologComponent : ContainerComponent
8+
{
9+
public override string Name => "Prolog";
10+
11+
public override ContainerComponentKind Kind => ContainerComponentKind.Prolog;
12+
13+
public override void WriteDockerfile( TextWriter writer )
14+
{
15+
writer.WriteLine(
16+
"""
17+
# escape=`
18+
19+
# This file is auto-generated by PostSharp.Engineering.
20+
21+
FROM mcr.microsoft.com/windows/servercore:ltsc2025
22+
23+
# The initial shell is Windows PowerShell (use full path to avoid HCS issues)
24+
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-Command"]
25+
26+
# Prepare environment
27+
ENV PSExecutionPolicyPreference=Bypass
28+
ENV POWERSHELL_UPDATECHECK=Off
29+
ENV TEMP=C:\Temp
30+
ENV TMP=C:\Temp
31+
ENV RUNNING_IN_DOCKER=TRUE
32+
33+
# Set locale for consistent behavior regardless of host locale
34+
ENV LANG=C.UTF-8
35+
ENV LC_ALL=C.UTF-8
36+
37+
# Add Windows PowerShell to PATH (pwsh added later by PowershellComponent)
38+
ENV PATH="C:\Windows\System32\WindowsPowerShell\v1.0;${PATH}"
39+
40+
# Enable long path support
41+
RUN Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
42+
43+
""" );
44+
}
4145
}

0 commit comments

Comments
 (0)