Skip to content

Conversation

@joshuacurtiss
Copy link
Member

@joshuacurtiss joshuacurtiss commented Sep 11, 2025

This bug doesn't actually impact behavior, but negates the purpose of the build hash. Due to inconsistencies with the way sorting occurs on different systems, the build hash may differ between systems.

To fix this, we use LC_ALL=C which consistently sorts files on all systems regardless of their locale, which influences the sorting algorithm.

While looking at the code, though, I realized that we were (a) Including some code that isn't "live" to the installer, like the exp and .github directories, and (b) NOT including symlinked directories and files, which could potentially result in the hash not changing when symlinked directories and files are added or omitted.

To demonstrate what files will be included in the hash calculation now, run this script from the docker-host project checkout:

dir=$(pwd); find -L "$dir" \
      \( -path '*/node_modules' -o -path '*/exp' -o -path '*/.*' \) -prune -o \
      \( \( -type f -o -type l \) -a \( -name '*.sh' -o -name '*.yml' \) \) -print0 | \
      LC_ALL=C sort -z|while IFS= read -r -d '' file; do; echo ${file/$dir\//}; done

It should return:

init.sh
macos/1-prep.sh
macos/2-docker.sh
macos/3-ghcr-auth.sh
macos/4-stacks.sh
macos/docker.sh
macos/prep.sh
macos/setup-shared.sh
macos/setup.sh
rhel-9/1-prep.sh
rhel-9/2-docker.sh
rhel-9/3-ghcr-auth.sh
rhel-9/4-stacks.sh
rhel-9/5-github-actions-runner.sh
rhel-9/bin/podman-install-service.sh
rhel-9/docker.sh
rhel-9/prep.sh
rhel-9/setup-shared.sh
rhel-9/setup.sh
rocky-9/1-prep.sh
rocky-9/2-docker.sh
rocky-9/3-ghcr-auth.sh
rocky-9/4-stacks.sh
rocky-9/5-github-actions-runner.sh
rocky-9/bin/podman-install-service.sh
rocky-9/docker.sh
rocky-9/prep.sh
rocky-9/setup-shared.sh
rocky-9/setup.sh
shared/bin/deploy.sh
shared/bin/publish.sh
shared/ghcr-auth.sh
shared/github-actions-runner.sh
shared/setup.sh
shared/stacks.sh
stacks/nginx-proxy-manager-install.sh
stacks/nginx-proxy-manager.yml
stacks/portainer-install.sh
stacks/portainer.yml
stacks/setup.sh
ubuntu-22/1-prep.sh
ubuntu-22/2-docker.sh
ubuntu-22/3-ghcr-auth.sh
ubuntu-22/4-stacks.sh
ubuntu-22/5-github-actions-runner.sh
ubuntu-22/docker.sh
ubuntu-22/prep.sh
ubuntu-22/setup-shared.sh
ubuntu-22/setup.sh
ubuntu-24/1-prep.sh
ubuntu-24/2-docker.sh
ubuntu-24/3-ghcr-auth.sh
ubuntu-24/4-stacks.sh
ubuntu-24/5-github-actions-runner.sh
ubuntu-24/docker.sh
ubuntu-24/prep.sh
ubuntu-24/setup-shared.sh
ubuntu-24/setup.sh

You can also test this on other systems by asking for the version from this branch like this:

 bash <(curl -H 'Cache-Control: no-cache, no-store' -o- https://raw.githubusercontent.com/uicpharm/docker-host/jcurt/hash/init.sh) -b jcurt/hash --version

Currently, it reports: Docker Host version 1.0.0 build 4036ef92

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Fixes inconsistent build hash generation across different systems by standardizing file sorting and improving file inclusion logic. The build hash is used to uniquely identify the version of the installer scripts.

  • Enforces consistent sorting across systems using LC_ALL=C locale
  • Excludes non-essential directories (exp, .github, hidden files) from hash calculation
  • Includes symlinked files and directories in hash calculation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

The build hash was including some files that were not intended, and not sorting the files
in a consistent way, so this led to inconsistent hashes between systems.

Both `exp` and `.github` directories were allowed to be included in the hash calculation,
even though these directories are not part of the live code. Incidentally, different
locales would handle sorting `.github` differently, leading to different hashes.

So, we prune those directories from the file search, and we set `LC_ALL=C` to ensure
consistent sorting.

Additionally, we were not considering symlinks when identifying files and directories to
include in the hash calculation. This wasn't causing a problem but it could result in
unchanged hashes even when symlinks are changed or omitted. So, we improve the file search
to include symlinks in the hash calculation.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@joshuacurtiss joshuacurtiss added the bug Something isn't working label Sep 12, 2025
@akamal4 akamal4 merged commit ccad884 into main Sep 17, 2025
2 checks passed
@joshuacurtiss joshuacurtiss deleted the jcurt/hash branch September 17, 2025 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants