Skip to content

Fix CI Docker build on modern Ubuntu images#13

Draft
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-ci-failure-docker-build
Draft

Fix CI Docker build on modern Ubuntu images#13
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-ci-failure-docker-build

Conversation

Copy link
Copy Markdown

Copilot AI commented May 31, 2026

Pull Request

Description

This PR addresses the CI Docker build failure on current ubuntu:latest images. The locale setup now uses the Ubuntu-supported path, and non-root user creation no longer assumes UID/GID 1000 is unused.

Type of Change:

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change
  • Documentation update
  • Test improvements
  • CI/CD improvements
  • Code refactoring

Changes

Explain what was changed and why:

  • Locale setup

    • Replace the brittle localedef ... -A /usr/share/locale/locale.alias invocation with Ubuntu-native locale generation.
    RUN sed -i '/^# *en_US.UTF-8 UTF-8/s/^# *//' /etc/locale.gen \
        && locale-gen en_US.UTF-8 \
        && update-locale LANG=en_US.UTF-8
    ENV LANG=en_US.UTF-8
  • User creation on modern base images

    • Remove reliance on deleting the built-in ubuntu user.
    • Make user/group setup reuse the existing UID/GID 1000 account when present, preserving the expected coder home and shell.
  • Dockerfile hardening

    • Quote shell-expanded values in the user setup step.
    • Keep the change scoped to the failing build path.

Testing

Test Coverage:

  • Unit tests added/updated
  • Integration tests added/updated
  • All tests pass

Test Results:

$ bats tests/unit/
1..38
ok 1 script exists and is executable
...
ok 38 profile uses Invoke-Expression for oh-my-posh init script

Manual Testing:

  1. Build the Docker base stage on current ubuntu:latest
  2. Verify /home/coder and LANG=en_US.UTF-8 in the resulting image

Environment:

  • OS: Ubuntu
  • Docker version: local Docker Engine
  • Architecture: x64

Quality Checks

  • Code follows project style guidelines
  • Scripts pass shellcheck validation
  • No new warnings or errors
  • Code is properly commented
  • No sensitive information exposed
  • No security vulnerabilities introduced
  • No performance regressions

Documentation

  • README.md updated (if needed)
  • CONTRIBUTING.md updated (if needed)
  • Code comments added/updated
  • Breaking changes documented (if applicable)

Deployment

  • Changes are backward compatible
  • CI/CD pipeline updated (if needed)

Rollback Plan:

Revert the Dockerfile user-setup and locale changes to restore the previous image behavior.

Screenshots

N/A

Checklist

  • Self-reviewed my code
  • Added/updated tests
  • Updated documentation
  • All tests pass locally
  • Resolved merge conflicts
  • Ready for review

Additional Notes

The latest PR workflow run is waiting in action_required; once approved, it should exercise the exact Docker build path this change targets.

Original prompt

Create a fix for the CI failure in jmcombs/powershell.

Context:

RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG=en_US.utf8

Observed error from logs:

locale alias file `/usr/share/locale/locale.alias' not found: No such file or directory
ERROR: process "/bin/sh -c localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8" did not complete successfully: exit code: 1

Required solution:

  1. Update the Dockerfile to use a robust Ubuntu-compatible locale generation approach (for example locale-gen / update-locale) instead of the failing localedef ... -A /usr/share/locale/locale.alias invocation.
  2. Remove or adjust the userdel ubuntu step if it is unnecessary or harmful on modern ubuntu:latest images, since logs show package setup warnings about missing system users/groups after that deletion.
  3. Keep the fix minimal and focused on restoring CI.
  4. Create a branch and open a pull request with a clear title and description.
  5. Verify CI validation runs for the PR and ensure the failing build issue is resolved if possible within the PR.

Issue context:

  • Drafted issue title: [BUG] Docker build fails on locale setup in CI pipeline
  • Repository: jmcombs/powershell

Please implement the fix, push the branch, and open the PR.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is in the Docker build step of Build Test Image in .github/workflows/ci.yml, where the workflow builds the image with docker/build-push-action@v6 (build-test-image, lines 101–109).

Root cause

The actual build error is in Dockerfile:

RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

The logs show:

locale alias file `/usr/share/locale/locale.alias' not found: No such file or directory

So the image build fails because localedef is using a path that does not exist in the current ubuntu:latest base image.

Best fix

Replace the locale generation step with the Ubuntu-supported locale-gen flow.

Suggested Dockerfile change

Replace:

# Set US English and UTF-8 Locale
RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG=en_US.utf8

with:

# Set US English and UTF-8 Locale
RUN sed -i '/^# *en_US.UTF-8 UTF-8/s/^# *//' /etc/locale.gen \
    && locale-gen en_US.UTF-8 \
    && update-locale LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8

Why this is the right solution

  • It avoids the missing locale.alias file entirely.
  • It matches standard Ubuntu locale setup.
  • It is more stable against ubuntu:latest image changes.

Optional simpler alternative

If you want the smallest possible change, you can also try:

RUN localedef -i en_US -f UTF-8 en_US.UTF-8
ENV LANG=en_US.UTF-8

But locale-gen is the safer fix for Ubuntu.

Additional issue worth correcting

There is also a risky user deletion step in Dockerfile lines 28–33. The logs show multiple missing system users/groups after package installation, which is a sign that deleting the default ubuntu user on ubuntu:latest is no longer safe.

Current code:

RUN if id "ubuntu" &>/dev/null; then \
    echo "Deleting user 'ubuntu'" && userdel -f -r ubuntu || echo "Failed to delete ubuntu user"; \
    else \
    echo "User 'ubuntu' does not exist"; \
    fi;

Recommended change: remove this step entirely.

Recommended final patch

FROM ubuntu:latest AS base

# Define build arguments
ARG TARGETARCH
ARG NET_RUNTIME_LTS_VERSION
ARG NET_RUNTIME_URL_arm
ARG NET_RUNTIME_PACKAGE_NAME_arm
ARG NET_RUNTIME_URL_arm64
ARG NET_RUNTIME_PACKAGE_NAME_arm64
ARG NET_RUNTIME_URL_x64
ARG NET_RUNTIME_PACKAGE_NAME_x64
ARG PWSH_LTS_URL_arm32
ARG PWSH_LTS_PACKAGE_NAME_arm32
ARG PWSH_LTS_URL_arm64
ARG PWSH_LTS_PACKAGE_NAME_arm64
ARG PWSH_LTS_URL_x64
ARG PWSH_LTS_PACKAGE_NAME_x64
ARG PWSH_LTS_VERSION
ARG PWSH_LTS_MAJOR_VERSION

# Set environment variables based on build arguments
ENV DOTNET_VERSIO...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Copilot AI added 2 commits May 31, 2026 01:24
- Remove the 'userdel ubuntu' step that caused package setup warnings
  on modern ubuntu:latest images
- Replace failing 'localedef -A /usr/share/locale/locale.alias' with
  the Ubuntu-standard locale-gen approach
- Add LC_ALL=en_US.UTF-8 environment variable for full locale support"
Copilot AI changed the title [WIP] Fix CI failure in Docker image build fix: Docker build failure on locale setup in CI pipeline May 31, 2026
Copilot AI requested a review from jmcombs May 31, 2026 01:25
Copilot AI changed the title fix: Docker build failure on locale setup in CI pipeline Fix CI Docker build on modern Ubuntu images May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants