prop/Dockerfile
Graham McIntire 0c3be97abb
Some checks failed
Build base image / Build and push base image (push) Successful in 3m10s
Build and Push / Build and Push Docker Image (push) Failing after 14s
Build prop-grid-rs / Test, build, push (push) Successful in 12m52s
fix: resolve 27 security, architecture, test, and performance audit findings
P0 (security-critical):
- Gate CSV/ADIF upload tabs behind authentication, add 30s cooldown to all upload handlers
- Cap CSV/ADIF imports at 2,000 rows server-side in both parsers
- Add submitter_verified boolean to contacts (client-cannot-set, anonymous=false)
- Create k8s/secret.example.yaml with placeholders, add LIVE_VIEW_SIGNING_SALT

P1 (high-priority):
- Add Mox.verify_on_exit!() to valkey_test.exs
- Replace DateTime.utc_now() truncation with static ~U literals in map_live_test.exs
- Replace Process.sleep with render_async in pskr_spots_live_test.exs (6 occurrences)
- Add MonitorLive.Show test coverage (4 tests: owner view, non-owner redirect, config success/error)
- Extract duct-detection and mechanism-classification logic from ContactLive.Show into Propagation.PathAnalysis
- Split ContactLive.Show render into 12 function components
- Update CLAUDE.md: remove stale ML model, mark HRDPS active, add backtest/pskr dirs
- Batch CSV import enrichment jobs via new enqueue_for_contacts/1

P2 (medium-priority):
- Set secure:true on session and remember-me cookies in production
- Change SMTP TLS from verify_none to verify_peer with public_key cacerts
- Make /metrics fail-closed in production when PROMETHEUS_AUTH_TOKEN unset
- Add RateLimiter (anon_limit:10, auth_limit:60) to /api/contacts/map
- Add content-security-policy-report-only header
- Add comment noting String.to_atom is compile-time safe in hrdps_client.ex
- Delegate duplicated haversine_km to canonical Microwaveprop.Geo.haversine_km/4
- Consolidate score-tier/color/verdict formatting into Microwaveprop.Format
- Update CLAUDE.md testing section to match actual raw-string-matching practice
- Batch HrrrPointEnqueuer Repo.insert_all calls to single round-trip
- Split weather.ex (1696→216 lines) and radio.ex (1285→54 lines) into purpose-based sub-facades

P3 (low-priority):
- Add LIVE_VIEW_SIGNING_SALT warning comment, extend filter_parameters
- Add host/community validation to snmp_client.ex
- Add raw/1 safety comment in algo_live.ex
- Add hex-audit and cargo-audit Makefile targets
- Add privacy_live smoke test
- Replace notify_listener busy-poll loop with Process.monitor/1 + assert_receive
- Add ContactCommonVolumeRadar changeset validation tests (5 tests)
2026-07-27 18:19:37 -05:00

89 lines
2.7 KiB
Docker

# syntax=docker/dockerfile:1.6
#
# Builder: elixir-base (prebuilt hexpm/elixir + build-essential + git + hex + rebar)
# https://git.mcintire.me/graham/elixir-base
# Runtime: prop-base (prebuilt wgrib2 + cdo + gdal-bin, see Dockerfile.base)
#
ARG BUILDER_IMAGE="git.mcintire.me/graham/elixir-base:latest"
# Prebuilt runtime base contains wgrib2 + cdo + gdal-bin + locale + the
# BEAM runtime apt deps.
ARG BASE_IMAGE="git.mcintire.me/gmcintire/prop-base:latest"
# ---- Elixir build stage ----
FROM ${BUILDER_IMAGE} AS builder
# build-essential, git, curl, ca-certificates, hex, and rebar are
# already installed in the elixir-base image.
# prepare build dir
WORKDIR /app
# set build ENV
ENV MIX_ENV="prod"
# install mix dependencies (changes only when mix.exs/mix.lock change)
COPY mix.exs mix.lock ./
COPY vendor vendor
RUN mix deps.get --only $MIX_ENV
# copy compile-time config before compiling deps
RUN mkdir config
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile
# install esbuild + tailwind binaries (cached until mix.exs changes)
RUN mix assets.setup
# create priv dir so :code.priv_dir works at compile time
# (actual contents copied after compile to avoid cache busting)
RUN mkdir -p priv/models priv/static
# copy application code and compile
COPY lib lib
COPY algo.md algo.md
# agent-skills markdown is read at compile time by AgentSkillsController
# (sha256 digests are baked into the module attribute)
COPY priv/agent-skills priv/agent-skills
# /docs/api artifacts are read at compile time by ApiDocsController
# and ApiDocsLive (baked into module attributes).
COPY docs/api docs/api
RUN mix compile
# copy assets and build (JS/CSS changes don't require recompilation)
COPY assets assets
RUN mix assets.deploy
# copy priv contents (migrations, ML model, static files)
# after compile so model retraining doesn't bust the compile cache
COPY priv priv
# runtime config doesn't require recompilation
COPY config/runtime.exs config/
COPY rel rel
RUN mix release
# ---- Final runtime stage ----
# Pulls the prebuilt prop-base image (Dockerfile.base) which already
# carries wgrib2 + g2c libs + cdo + gdal-bin + locale + BEAM runtime
# apt deps. We just COPY the Elixir release on top.
FROM ${BASE_IMAGE} AS final
# Build timestamp baked in by CI (--build-arg BUILD_TIMESTAMP=...).
# Only consumed in this final stage, so it never busts the earlier
# compile cache. Read at runtime by Microwaveprop.Application.build_timestamp/0.
ARG BUILD_TIMESTAMP=unknown
ENV MIX_ENV="prod"
WORKDIR "/app"
RUN chown nobody /app
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/microwaveprop ./
RUN echo "${BUILD_TIMESTAMP}" > /app/BUILD_TIMESTAMP \
&& chown nobody /app/BUILD_TIMESTAMP
USER nobody
CMD ["/app/bin/server"]