diff --git a/.tool-versions b/.tool-versions index ddc820de4a..8401caa2e2 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ nodejs 24.5.0 -erlang 28.0.2 -elixir 1.18.4-otp-28 +erlang 28.2 +elixir 1.19.4-otp-28 diff --git a/config/deps/phoenix.exs b/config/deps/phoenix.exs index ac43268ae6..7b36f3b84e 100644 --- a/config/deps/phoenix.exs +++ b/config/deps/phoenix.exs @@ -4,11 +4,6 @@ config :phoenix, :gzippable_exts, ~w(.txt .html .js .css .svg) config :phoenix, :json_library, Poison if config_env() == :prod do - config :dotcom, :websocket_check_origin, [ - "https://*.mbta.com", - "https://*.mbtace.com" - ] - config :dotcom, dev_server?: false diff --git a/config/runtime.exs b/config/runtime.exs index feccb46c29..a2f52f2827 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -196,6 +196,7 @@ config :dotcom, DotcomWeb.ViewHelpers, google_tag_manager_auth: System.get_env("GOOGLE_TAG_MANAGER_AUTH"), google_tag_manager_preview: System.get_env("GOOGLE_TAG_MANAGER_PREVIEW") +config :dotcom, allow_indexing: System.get_env("ALLOW_INDEXING") == "true" config :dotcom, google_api_key: System.get_env("GOOGLE_API_KEY") config :recaptcha, diff --git a/deploy/dotcom/dev/Dockerfile b/deploy/dotcom/dev/Dockerfile index 12f76a5bc5..5dfcf0723a 100644 --- a/deploy/dotcom/dev/Dockerfile +++ b/deploy/dotcom/dev/Dockerfile @@ -1,4 +1,4 @@ -FROM hexpm/elixir:1.18.4-erlang-28.0.2-debian-trixie-20250811-slim +FROM hexpm/elixir:1.19.4-erlang-28.2-debian-trixie-20251229-slim RUN apt-get update && apt-get install -y curl git make build-essential inotify-tools RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - diff --git a/deploy/dotcom/prod/Dockerfile b/deploy/dotcom/prod/Dockerfile index 549d2ac22a..58f8532032 100644 --- a/deploy/dotcom/prod/Dockerfile +++ b/deploy/dotcom/prod/Dockerfile @@ -1,4 +1,4 @@ -FROM hexpm/elixir:1.18.4-erlang-28.0.2-alpine-3.22.1 AS builder +FROM hexpm/elixir:1.19.4-erlang-28.2-alpine-3.23.2 AS builder # ENVS AND ARGS ENV LANG="C.UTF-8" MIX_ENV="prod" @@ -37,7 +37,7 @@ RUN mix compile RUN mix phx.digest RUN mix release -FROM hexpm/elixir:1.18.4-erlang-28.0.2-alpine-3.22.1 +FROM hexpm/elixir:1.19.4-erlang-28.2-alpine-3.23.2 ENV PORT=4000 MIX_ENV="prod" PHX_SERVER=true TERM=xterm LANG="C.UTF-8" REPLACE_OS_VARS=true diff --git a/lib/alerts/alert.ex b/lib/alerts/alert.ex index a44cc11b22..c7cfcbd239 100644 --- a/lib/alerts/alert.ex +++ b/lib/alerts/alert.ex @@ -180,8 +180,8 @@ defmodule Alerts.Alert do defp build_struct(keywords), do: struct!(__MODULE__, keywords) @spec ensure_entity_set(map) :: t() - defp ensure_entity_set(alert) do - %__MODULE__{alert | informed_entity: InformedEntitySet.new(alert.informed_entity)} + defp ensure_entity_set(%__MODULE__{} = alert) do + %{alert | informed_entity: InformedEntitySet.new(alert.informed_entity)} end @spec all_types :: [effect] @@ -333,13 +333,13 @@ defmodule Alerts.Alert do end defimpl Poison.Encoder, for: Alerts.Alert do - def encode(%Alerts.Alert{active_period: active_period_pairs} = alert, options) do - active_period = Enum.map(active_period_pairs, &alert_active_period/1) + def encode(%Alerts.Alert{} = alert, options) do + alert = + Map.update!(alert, :active_period, fn active_period_pairs -> + Enum.map(active_period_pairs, &alert_active_period/1) + end) - Poison.Encoder.Map.encode( - %{alert | active_period: active_period}, - options - ) + Poison.Encoder.Map.encode(alert, options) end @spec alert_active_period(Alerts.Alert.period_pair()) :: [nil | binary] diff --git a/lib/dotcom/alerts/subway/disruptions.ex b/lib/dotcom/alerts/subway/disruptions.ex index 0d664e5936..1bdd37d5cc 100644 --- a/lib/dotcom/alerts/subway/disruptions.ex +++ b/lib/dotcom/alerts/subway/disruptions.ex @@ -60,11 +60,11 @@ defmodule Dotcom.Alerts.Subway.Disruptions do # result is then two alerts, both equivalent to the alert passed in, # except that one has a single active period of {Sun, Tue}, and the # other has a single active period of {Thu, Fri}. - defp split_by_discontiguous_active_periods(alert) do + defp split_by_discontiguous_active_periods(%Alerts.Alert{} = alert) do alert.active_period |> combine_contiguous_active_periods() |> Enum.map(fn active_period -> - %Alerts.Alert{alert | active_period: [active_period]} + %{alert | active_period: [active_period]} end) end diff --git a/lib/dotcom/application.ex b/lib/dotcom/application.ex index 9c30b281df..2ac0a03f89 100644 --- a/lib/dotcom/application.ex +++ b/lib/dotcom/application.ex @@ -10,20 +10,8 @@ defmodule Dotcom.Application do # See http://elixir-lang.org/docs/stable/elixir/Application.html # for more information on OTP Applications + @impl Application def start(_type, _args) do - Application.put_env( - :dotcom, - :allow_indexing, - DotcomWeb.ControllerHelpers.environment_allows_indexing?() - ) - - # hack to pull the STATIC_SCHEME variable out of the environment - Application.put_env( - :dotcom, - DotcomWeb.Endpoint, - update_static_url(Application.get_env(:dotcom, DotcomWeb.Endpoint)) - ) - children = [ {Application.get_env(:dotcom, :cache, Dotcom.Cache.Multilevel), []}, @@ -61,12 +49,10 @@ defmodule Dotcom.Application do [ Routes.Supervisor, Predictions.Supervisor, - {Phoenix.PubSub, name: Dotcom.PubSub}, Alerts.BusStopChangeSupervisor, - Alerts.CacheSupervisor - ] ++ - [ - {DotcomWeb.Endpoint, name: DotcomWeb.Endpoint} + Alerts.CacheSupervisor, + {Phoenix.PubSub, name: Dotcom.PubSub}, + DotcomWeb.Endpoint ] ++ if Application.get_env(:dotcom, :env) != :test do [ @@ -85,24 +71,9 @@ defmodule Dotcom.Application do # Tell Phoenix to update the endpoint configuration # whenever the application is updated. + @impl Application def config_change(changed, _new, removed) do DotcomWeb.Endpoint.config_change(changed, removed) :ok end - - defp update_static_url([{:static_url, static_url_parts} | rest]) do - static_url_parts = Keyword.update(static_url_parts, :scheme, nil, &update_static_url_scheme/1) - [{:static_url, static_url_parts} | update_static_url(rest)] - end - - defp update_static_url([first | rest]) do - [first | update_static_url(rest)] - end - - defp update_static_url([]) do - [] - end - - defp update_static_url_scheme({:system, env_var}), do: System.get_env(env_var) - defp update_static_url_scheme(scheme), do: scheme end diff --git a/lib/dotcom/trip_plan/open_street_map_reconciler.ex b/lib/dotcom/trip_plan/open_street_map_reconciler.ex index 291955d010..813362b3e3 100644 --- a/lib/dotcom/trip_plan/open_street_map_reconciler.ex +++ b/lib/dotcom/trip_plan/open_street_map_reconciler.ex @@ -58,8 +58,8 @@ defmodule Dotcom.TripPlan.OpenStreetMapReconciler do """ @spec reconcile(InputForm.t()) :: InputForm.t() @spec reconcile(arg) :: arg when arg: var - def reconcile(%{from: from, to: to} = form) do - %InputForm{form | from: reconcile_location(from), to: reconcile_location(to)} + def reconcile(%InputForm{from: from, to: to} = form) do + %{form | from: reconcile_location(from), to: reconcile_location(to)} end def reconcile(form), do: form diff --git a/lib/dotcom_web/controllers/cache_controller.ex b/lib/dotcom_web/controllers/cache_controller.ex index 16cb26ce2b..fc510d3be0 100644 --- a/lib/dotcom_web/controllers/cache_controller.ex +++ b/lib/dotcom_web/controllers/cache_controller.ex @@ -180,7 +180,7 @@ defmodule DotcomWeb.CacheController do } end) - assigns = assign(assigns, links: links) + assigns = Phoenix.Controller.assign(assigns, links: links) ~H"""