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 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
|
||||
FROM ${RUNNER_IMAGE}
|
||||
|
|
@ -78,5 +79,5 @@ LABEL org.opencontainers.image.vendor="APRS.me" \
|
|||
security.nonroot="true"
|
||||
|
||||
# Run the server
|
||||
ENTRYPOINT ["/app/bin/aprs"]
|
||||
ENTRYPOINT ["/app/bin/server"]
|
||||
EXPOSE $PORT
|
||||
|
|
|
|||
22
app.json
22
app.json
|
|
@ -7,17 +7,23 @@
|
|||
"postdeploy": ""
|
||||
}
|
||||
},
|
||||
"checks": {
|
||||
"healthchecks": {
|
||||
"web": [
|
||||
{
|
||||
"type": "http",
|
||||
"name": "web-health",
|
||||
"path": "/health",
|
||||
"attempts": 3,
|
||||
"timeout": 5,
|
||||
"wait": 10,
|
||||
"initial_delay": 10
|
||||
"type": "startup",
|
||||
"name": "web process check",
|
||||
"description": "Checking web process startup",
|
||||
"path": "/ready",
|
||||
"attempts": 5,
|
||||
"timeout": 10,
|
||||
"wait": 5,
|
||||
"initial_delay": 15
|
||||
}
|
||||
]
|
||||
},
|
||||
"formation": {
|
||||
"web": {
|
||||
"quantity": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,46 @@ defmodule AprsWeb.PageController do
|
|||
end
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ defmodule AprsWeb.Router do
|
|||
scope "/", AprsWeb do
|
||||
pipe_through :api
|
||||
get "/health", PageController, :health
|
||||
get "/ready", PageController, :ready
|
||||
end
|
||||
|
||||
scope "/", AprsWeb do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue