Fix build version showing "unknown" in production
The previous approach baked git rev-parse --short HEAD into the image at Docker build time, but Dockhand's build context doesn't reliably have .git available, so it silently fell back to "unknown" in production even though the build itself succeeded. Replace it with a plain VERSION file committed to the repo (a timestamp + short description, updated by hand alongside each commit) that ships via the same COPY . . as everything else - no git access needed inside the build at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+14
-13
@@ -33,22 +33,23 @@ app.config['SECRET_KEY'] = 'your-secret-key-change-in-production'
|
||||
|
||||
def _load_build_version() -> str:
|
||||
"""
|
||||
Commit + build time baked into the image at build time (see
|
||||
Dockerfile) - lets Settings and /health show which version is
|
||||
actually running, the only way to confirm a git push made it into a
|
||||
rebuilt container, since the webhook does a full image rebuild with
|
||||
no other visible confirmation. Falls back to 'dev' outside Docker,
|
||||
where there's no BUILD_VERSION file (e.g. running via --library-path
|
||||
directly).
|
||||
Reads the repo-committed VERSION file - lets Settings and /health show
|
||||
which version is actually running, the only way to confirm a push made
|
||||
it into a rebuilt container, since the webhook does a full image
|
||||
rebuild with no other visible confirmation. Deliberately a plain file
|
||||
checked into the repo (updated by hand alongside each commit) rather
|
||||
than baked from `git rev-parse` at Docker build time: Dockhand's build
|
||||
context doesn't reliably have .git available, which silently produced
|
||||
"unknown" instead of a real commit. Falls back to 'dev' if the file is
|
||||
ever missing (shouldn't happen once committed, since it ships via the
|
||||
same COPY . . as everything else).
|
||||
"""
|
||||
version_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'BUILD_VERSION')
|
||||
version_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION')
|
||||
try:
|
||||
with open(version_file, 'r') as f:
|
||||
lines = [line.strip() for line in f if line.strip()]
|
||||
if len(lines) >= 2:
|
||||
return f'{lines[0]} · built {lines[1]}'
|
||||
if lines:
|
||||
return lines[0]
|
||||
content = f.read().strip()
|
||||
if content:
|
||||
return content
|
||||
except OSError:
|
||||
pass
|
||||
return 'dev'
|
||||
|
||||
Reference in New Issue
Block a user