diff --git a/Dockerfile b/Dockerfile index 155f9ded..7de56462 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,26 +22,45 @@ ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}" FROM ${RUNNER_IMAGE} AS wgrib2-builder ARG WGRIB2_VERSION=3.6.0 +ARG G2C_VERSION=1.9.0 RUN apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential gfortran cmake wget ca-certificates \ + build-essential gfortran cmake wget ca-certificates pkg-config \ zlib1g-dev libaec-dev libpng-dev \ && rm -rf /var/lib/apt/lists/* +# NCEPLIBS-g2c: wgrib2 >= 3.x requires this via find_package whenever +# PNG / JPEG2000 decoders are enabled (wgrib2 CMakeLists:94). We only +# need PNG (MRMS PrecipRate / native HRRR) + AEC — Jasper/OpenJPEG +# default to ON in g2c and must be explicitly disabled since libjasper +# isn't installed in this stage and would pull another runtime dep +# into the debian-slim runner. +WORKDIR /tmp/g2c +RUN wget -q --content-disposition "https://github.com/NOAA-EMC/NCEPLIBS-g2c/archive/refs/tags/v${G2C_VERSION}.tar.gz" \ + -O g2c.tar.gz \ + && tar xzf g2c.tar.gz \ + && cd NCEPLIBS-g2c-${G2C_VERSION} \ + && mkdir build && cd build \ + && cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local \ + -DCMAKE_BUILD_TYPE=Release \ + -DUSE_PNG=ON \ + -DUSE_AEC=ON \ + -DUSE_Jasper=OFF \ + -DUSE_OpenJPEG=OFF \ + -DBUILD_G2C=OFF \ + && make -j$(nproc) \ + && make install + WORKDIR /tmp/wgrib2 -## NOTE: wgrib2 3.6.0 enabling -DUSE_PNG / -DUSE_AEC triggers a hard -## find_package(g2c 1.9.0 REQUIRED) for NCEPLIBS-g2c, which isn't -## installed here. Until that's addressed, the stock build stays — -## MRMS PrecipRate (packing type 41) can't be decoded, so -## MrmsFetchWorker is kept out of the prod cron. RUN wget -q --content-disposition "https://github.com/NOAA-EMC/wgrib2/archive/refs/tags/v${WGRIB2_VERSION}.tar.gz" \ -O wgrib2.tar.gz \ && tar xzf wgrib2.tar.gz \ && cd wgrib2-${WGRIB2_VERSION} \ && mkdir build && cd build \ && cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release \ + -DUSE_PNG=ON -DUSE_AEC=ON \ && make -j$(nproc) \ && make install \ && strip /usr/local/bin/wgrib2 @@ -120,6 +139,12 @@ WORKDIR "/app" RUN chown nobody /app COPY --from=wgrib2-builder /usr/local/bin/wgrib2 /usr/local/bin/wgrib2 +# wgrib2 links dynamically against libg2c.so from the builder stage — +# carry it across and refresh the loader cache so /usr/local/lib is +# searched at exec time. +COPY --from=wgrib2-builder /usr/local/lib/libg2c.so* /usr/local/lib/ +RUN ldconfig + COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/microwaveprop ./ USER nobody diff --git a/config/runtime.exs b/config/runtime.exs index 3abe84d4..23bffde8 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -215,13 +215,12 @@ if config_env() == :prod do # Hourly cron caused overlapping/failed runs because one full sweep # exceeds a 60-minute window. {"5 */3 * * *", Microwaveprop.Workers.PropagationGridWorker}, - # MrmsFetchWorker is intentionally absent: the prod wgrib2 build - # doesn't have the PNG decoder (DRT 5.41) that MRMS PrecipRate - # uses, so every fetch failed with "packing type 41 not - # supported". AsosAdjustmentWorker gracefully handles an empty - # MRMS cache — the rain overlay is a nice-to-have, the ASOS - # nudge still runs on its own. Re-add once the Dockerfile - # installs NCEPLIBS-g2c + rebuilds wgrib2 with -DUSE_PNG=ON. + # MRMS refreshes the PrecipRate cache that AsosAdjustmentWorker + # overlays onto the score grid. Both must run together — an + # ASOS nudge without a fresh MRMS frame reverts to HRRR-only + # rain. Requires wgrib2 built with PNG decoder support (DRT + # 5.41), which the Dockerfile now enables via NCEPLIBS-g2c. + {"*/2 * * * *", Microwaveprop.Workers.MrmsFetchWorker}, {"*/10 * * * *", Microwaveprop.Workers.AsosAdjustmentWorker}, {"*/15 * * * *", Microwaveprop.Workers.PropagationPruneWorker}, {"*/30 * * * *", Microwaveprop.Workers.BackfillEnqueueWorker,