diff --git a/Dockerfile b/Dockerfile index 0f49a12..6d9e4e0 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 default parser git hash environment variable -ENV PARSER_GIT_HASH="unknown" +# Set parser git hash environment variable for runtime +RUN PARSER_HASH=$(cat /app/parser_hash.txt) && echo "PARSER_GIT_HASH=$PARSER_HASH" >> /etc/environment # 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 69cd2ed..3abb4fb 100644 --- a/lib/aprsme/dependency_info.ex +++ b/lib/aprsme/dependency_info.ex @@ -47,27 +47,17 @@ defmodule Aprsme.DependencyInfo do defp get_static_parser_hash do case System.get_env("PARSER_GIT_HASH") do nil -> - "unknown" - - "unknown" -> - # Try to read from the file copied during build + # Fallback: try to read from the file hash_file = Path.join(["/app", "parser_hash.txt"]) - # Try alternative paths - alternative_paths = [ - hash_file, - Path.join([File.cwd!(), "parser_hash.txt"]), - "parser_hash.txt" - ] - - Enum.find_value(alternative_paths, "unknown", fn path -> - if File.exists?(path) do - case File.read(path) do - {:ok, hash} -> String.trim(hash) - _ -> nil - end + if File.exists?(hash_file) do + case File.read(hash_file) do + {:ok, hash} -> String.trim(hash) + _ -> "unknown" end - end) + else + "unknown" + end hash -> hash