mirror of
https://github.com/tale/headplane.git
synced 2026-07-26 07:48:14 +00:00
feat: gate the healthcheck listen file to docker only
This commit is contained in:
@@ -57,6 +57,11 @@ COPY --from=go-base /bin/hp_healthcheck /bin/hp_healthcheck
|
|||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||||
CMD ["/bin/hp_healthcheck"]
|
CMD ["/bin/hp_healthcheck"]
|
||||||
|
|
||||||
|
# Tells Headplane to publish its loopback healthcheck URL to this
|
||||||
|
# file on startup; `hp_healthcheck` reads it. Docker-only — native
|
||||||
|
# installs don't ship a consumer.
|
||||||
|
ENV HEADPLANE_LISTEN_FILE=/tmp/headplane-listen
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
CMD [ "/app/build/server/index.js" ]
|
CMD [ "/app/build/server/index.js" ]
|
||||||
|
|
||||||
@@ -73,5 +78,7 @@ COPY --from=go-base /bin/hp_healthcheck /bin/hp_healthcheck
|
|||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||||
CMD ["/bin/hp_healthcheck"]
|
CMD ["/bin/hp_healthcheck"]
|
||||||
|
|
||||||
|
ENV HEADPLANE_LISTEN_FILE=/tmp/headplane-listen
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
CMD [ "node", "/app/build/server/index.js" ]
|
CMD [ "node", "/app/build/server/index.js" ]
|
||||||
|
|||||||
+15
-6
@@ -42,17 +42,26 @@ if (certPath || keyPath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read by the bundled Docker healthcheck. Includes the basename
|
// `HEADPLANE_LISTEN_FILE` is a Docker-specific contract: the
|
||||||
// (`__PREFIX__`) so the Go binary can stay completely dumb — just
|
// Dockerfile sets it to `/tmp/headplane-listen` so the bundled
|
||||||
// GET whatever URL is in this file. `/tmp` is writable in
|
// `hp_healthcheck` binary can discover the URL to probe. Native
|
||||||
// distroless and in every dev shell we care about.
|
// installs don't ship a consumer, so we just skip writing anything
|
||||||
const healthURL = `${tls ? "https" : "http"}://127.0.0.1:${config.server.port}${__PREFIX__}/healthz`;
|
// if the var isn't set.
|
||||||
|
const listenFilePath = process.env.HEADPLANE_LISTEN_FILE;
|
||||||
|
const listenFile = listenFilePath
|
||||||
|
? {
|
||||||
|
path: listenFilePath,
|
||||||
|
// Full URL including `__PREFIX__` so the Go binary can GET it
|
||||||
|
// verbatim — no path joining, no basename knowledge needed.
|
||||||
|
url: `${tls ? "https" : "http"}://127.0.0.1:${config.server.port}${__PREFIX__}/healthz`,
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
|
||||||
startHttpServer({
|
startHttpServer({
|
||||||
host: config.server.host,
|
host: config.server.host,
|
||||||
port: config.server.port,
|
port: config.server.port,
|
||||||
tls,
|
tls,
|
||||||
listenFile: { path: "/tmp/headplane-listen", url: healthURL },
|
listenFile,
|
||||||
listener: composeListener({
|
listener: composeListener({
|
||||||
basename: __PREFIX__,
|
basename: __PREFIX__,
|
||||||
staticRoot: clientDir,
|
staticRoot: clientDir,
|
||||||
|
|||||||
Reference in New Issue
Block a user