diff --git a/Dockerfile b/Dockerfile index 1cd3bc7..872340d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,10 @@ RUN mix local.hex --force && mix local.rebar --force # Set build environment ENV MIX_ENV="prod" +# Capture APRS parser git hash from GitHub API +RUN curl -s https://api.github.com/repos/aprsme/aprs/commits/main | grep -o '"sha":"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7 > /tmp/parser_hash.txt +ENV PARSER_GIT_HASH=$(cat /tmp/parser_hash.txt) + # Install dependencies COPY mix.exs mix.lock ./ RUN mix deps.get --only $MIX_ENV diff --git a/lib/aprsme/dependency_info.ex b/lib/aprsme/dependency_info.ex index 762c0da..f3d07f9 100644 --- a/lib/aprsme/dependency_info.ex +++ b/lib/aprsme/dependency_info.ex @@ -10,7 +10,11 @@ defmodule Aprsme.DependencyInfo do """ def get_aprs_library_sha do if Application.get_env(:aprsme, :env, :dev) == :prod do - fetch_aprs_sha_from_github() + # In production, use environment variable set during build if available + case System.get_env("PARSER_GIT_HASH") do + nil -> fetch_aprs_sha_from_github() + hash -> hash + end else get_aprs_sha_from_vendor() end diff --git a/mix.exs b/mix.exs index b136d51..4709da5 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Aprsme.MixProject do def project do [ app: :aprsme, - version: "0.1.0", + version: get_version(), elixir: "~> 1.17", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, @@ -125,4 +125,12 @@ defmodule Aprsme.MixProject do {:aprs, github: "aprsme/aprs", branch: "main"} end end + + # Get version from PARSER_GIT_HASH environment variable or fall back to default + defp get_version do + case System.get_env("PARSER_GIT_HASH") do + nil -> "0.1.0" + hash -> hash + end + end end