From ba80e414d8751f429423a8bbba55a58d3f692f4d Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 7 Jul 2025 14:46:31 -0500 Subject: [PATCH] fix parser version check --- Dockerfile | 7 +++++++ lib/aprsme/dependency_info.ex | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d9e4e0..7f0f2b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,8 @@ RUN curl -s https://api.github.com/repos/aprsme/aprs/commits/main | grep -o '"sh # Install dependencies COPY mix.exs mix.lock ./ +# Extract the hash from mix.lock and write to a file +RUN grep -oE 'aprs.*ref,\\s*"([a-f0-9]+)"' mix.lock | grep -oE '[a-f0-9]{7,}' | head -1 > /tmp/aprs_hash.txt RUN mix deps.get --only $MIX_ENV RUN mix deps.compile @@ -70,6 +72,11 @@ COPY --from=builder /tmp/parser_hash.txt /app/parser_hash.txt # Set parser git hash environment variable for runtime RUN PARSER_HASH=$(cat /app/parser_hash.txt) && echo "PARSER_GIT_HASH=$PARSER_HASH" >> /etc/environment +# In the runtime stage, after WORKDIR /app +COPY --from=builder /tmp/aprs_hash.txt /app/aprs_hash.txt +RUN echo "APRS_PARSER_HASH=$(cat /app/aprs_hash.txt)" >> /etc/environment +ENV APRS_PARSER_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 0b9cdb0..797402f 100644 --- a/lib/aprsme/dependency_info.ex +++ b/lib/aprsme/dependency_info.ex @@ -40,11 +40,7 @@ defmodule Aprsme.DependencyInfo do In production: uses the hash captured at compile time """ def get_aprs_library_sha do - if Application.get_env(:aprsme, :env, :dev) == :prod do - @aprs_hash - else - get_aprs_sha_from_vendor() - end + System.get_env("APRS_PARSER_HASH") || "unknown" end defp get_aprs_sha_from_vendor do