From 6cebd03d7ffa06fbe5a29c722bbbd1ccb3e0801d Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 7 Jul 2025 14:16:55 -0500 Subject: [PATCH] fix parser version check --- Dockerfile | 4 ++-- lib/aprsme/dependency_info.ex | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3956956..0f49a12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,8 +67,8 @@ RUN date -u +"%Y-%m-%dT%H:%M:%SZ" > /app/deployed_at.txt # Copy parser hash from builder stage COPY --from=builder /tmp/parser_hash.txt /app/parser_hash.txt -# Set parser git hash environment variable for runtime -ENV PARSER_GIT_HASH=$(cat /app/parser_hash.txt) +# Set default parser git hash environment variable +ENV PARSER_GIT_HASH="unknown" # Copy release from builder COPY --from=builder --chown=nobody:root /app/release ./ diff --git a/lib/aprsme/dependency_info.ex b/lib/aprsme/dependency_info.ex index 9b7874b..e61668a 100644 --- a/lib/aprsme/dependency_info.ex +++ b/lib/aprsme/dependency_info.ex @@ -55,9 +55,24 @@ defmodule Aprsme.DependencyInfo do # Get static parser hash at compile time defp get_static_parser_hash do case System.get_env("PARSER_GIT_HASH") do - nil -> "unknown" - "unknown" -> "unknown" - hash -> hash + nil -> + "unknown" + + "unknown" -> + # Try to read from the file copied during build + hash_file = Path.join(["/app", "parser_hash.txt"]) + + if File.exists?(hash_file) do + case File.read(hash_file) do + {:ok, hash} -> String.trim(hash) + _ -> "unknown" + end + else + "unknown" + end + + hash -> + hash end end end