distroless
This commit is contained in:
parent
40eeb2f4aa
commit
8a4189ad74
4 changed files with 59 additions and 11 deletions
|
|
@ -48,7 +48,8 @@ RUN mix compile
|
||||||
COPY config/runtime.exs config/
|
COPY config/runtime.exs config/
|
||||||
|
|
||||||
COPY rel rel
|
COPY rel rel
|
||||||
RUN mix release
|
RUN mix release && \
|
||||||
|
chmod +x /app/_build/prod/rel/aprs/bin/server /app/_build/prod/rel/aprs/bin/aprs
|
||||||
|
|
||||||
# Final distroless stage
|
# Final distroless stage
|
||||||
FROM ${RUNNER_IMAGE}
|
FROM ${RUNNER_IMAGE}
|
||||||
|
|
@ -78,5 +79,5 @@ LABEL org.opencontainers.image.vendor="APRS.me" \
|
||||||
security.nonroot="true"
|
security.nonroot="true"
|
||||||
|
|
||||||
# Run the server
|
# Run the server
|
||||||
ENTRYPOINT ["/app/bin/aprs"]
|
ENTRYPOINT ["/app/bin/server"]
|
||||||
EXPOSE $PORT
|
EXPOSE $PORT
|
||||||
|
|
|
||||||
22
app.json
22
app.json
|
|
@ -7,17 +7,23 @@
|
||||||
"postdeploy": ""
|
"postdeploy": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"checks": {
|
"healthchecks": {
|
||||||
"web": [
|
"web": [
|
||||||
{
|
{
|
||||||
"type": "http",
|
"type": "startup",
|
||||||
"name": "web-health",
|
"name": "web process check",
|
||||||
"path": "/health",
|
"description": "Checking web process startup",
|
||||||
"attempts": 3,
|
"path": "/ready",
|
||||||
"timeout": 5,
|
"attempts": 5,
|
||||||
"wait": 10,
|
"timeout": 10,
|
||||||
"initial_delay": 10
|
"wait": 5,
|
||||||
|
"initial_delay": 15
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"formation": {
|
||||||
|
"web": {
|
||||||
|
"quantity": 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,46 @@ defmodule AprsWeb.PageController do
|
||||||
end
|
end
|
||||||
|
|
||||||
def health(conn, _params) do
|
def health(conn, _params) do
|
||||||
json(conn, %{status: "ok", version: Application.spec(:aprs, :vsn)})
|
# Check database connection
|
||||||
|
db_healthy =
|
||||||
|
try do
|
||||||
|
Aprs.Repo.query!("SELECT 1")
|
||||||
|
true
|
||||||
|
rescue
|
||||||
|
_ -> false
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get application version
|
||||||
|
version = :aprs |> Application.spec(:vsn) |> List.to_string()
|
||||||
|
|
||||||
|
if db_healthy do
|
||||||
|
json(conn, %{
|
||||||
|
status: "ok",
|
||||||
|
version: version,
|
||||||
|
database: "connected",
|
||||||
|
timestamp: DateTime.utc_now()
|
||||||
|
})
|
||||||
|
else
|
||||||
|
conn
|
||||||
|
|> put_status(503)
|
||||||
|
|> json(%{
|
||||||
|
status: "error",
|
||||||
|
version: version,
|
||||||
|
database: "disconnected",
|
||||||
|
timestamp: DateTime.utc_now()
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def ready(conn, _params) do
|
||||||
|
# Simple readiness check without database dependency
|
||||||
|
# This is faster for startup health checks
|
||||||
|
version = :aprs |> Application.spec(:vsn) |> List.to_string()
|
||||||
|
|
||||||
|
json(conn, %{
|
||||||
|
status: "ready",
|
||||||
|
version: version,
|
||||||
|
timestamp: DateTime.utc_now()
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ defmodule AprsWeb.Router do
|
||||||
scope "/", AprsWeb do
|
scope "/", AprsWeb do
|
||||||
pipe_through :api
|
pipe_through :api
|
||||||
get "/health", PageController, :health
|
get "/health", PageController, :health
|
||||||
|
get "/ready", PageController, :ready
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", AprsWeb do
|
scope "/", AprsWeb do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue