diff --git a/backend/CHECKS b/backend/CHECKS new file mode 100644 index 0000000..4ebe978 --- /dev/null +++ b/backend/CHECKS @@ -0,0 +1 @@ +/health OK \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index 85d2cff..0a51e1d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -46,6 +46,7 @@ ENV APP_NAME=backend COPY --from=build /app/_build/prod/rel/${APP_NAME} ./ COPY Procfile ./ +COPY CHECKS ./ RUN chown -R nobody: /app USER nobody diff --git a/backend/lib/backend_web/endpoint.ex b/backend/lib/backend_web/endpoint.ex index 339fe95..29baf62 100644 --- a/backend/lib/backend_web/endpoint.ex +++ b/backend/lib/backend_web/endpoint.ex @@ -1,6 +1,8 @@ defmodule BackendWeb.Endpoint do use Phoenix.Endpoint, otp_app: :backend + plug BackendWeb.Healthcheck + socket("/socket", BackendWeb.UserSocket, websocket: true, longpoll: false diff --git a/backend/lib/backend_web/healthcheck.ex b/backend/lib/backend_web/healthcheck.ex new file mode 100644 index 0000000..d64a1e1 --- /dev/null +++ b/backend/lib/backend_web/healthcheck.ex @@ -0,0 +1,13 @@ +defmodule BackendWeb.Healthcheck do + import Plug.Conn + + def init(opts), do: opts + + def call(%Plug.Conn{request_path: "/health"} = conn, _opts) do + conn + |> send_resp(200, "OK") + |> halt() + end + + def call(conn, _opts), do: conn +end