fix parser version check

This commit is contained in:
Graham McIntire 2025-07-07 14:24:47 -05:00
parent 10159f7ba7
commit 2c8b594d59
No known key found for this signature in database
2 changed files with 10 additions and 20 deletions

View file

@ -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 ./

View file

@ -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