dockerfile: replace built-in healthcheck with tiny-health-checker for container healthchecks (#54)

* Revert "Add Image healthcheck. (#48)"

This reverts commit f7c81687b5.

* dockerfile: replace built-in healthcheck with tiny-health-checker for healthchecks

* dockerfile: support for ARM64 builds of thc
This commit is contained in:
Fijxu 2025-03-02 19:11:02 -03:00 committed by GitHub
parent a68c27dcdd
commit 5c8a975a04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 22 deletions

View file

@ -16,6 +16,11 @@ RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION
--output /tini \
&& chmod +x /tini
RUN arch=$(uname -m) && \
curl -fsSL https://github.com/dmikusa/tiny-health-checker/releases/download/v0.36.0/thc-${arch}-unknown-linux-musl \
--output /thc \
&& chmod +x /thc
RUN deno task compile
# Stage for creating the non-privileged user
@ -26,12 +31,16 @@ RUN adduser -u 10001 -S appuser
FROM gcr.io/distroless/cc
COPY --from=builder /app/invidious_companion /app/
COPY --from=builder /thc /thc
COPY ./config/ /app/config/
COPY --from=builder /tini /tini
ENV PORT=8282 \
HOST=0.0.0.0
ENV THC_PORT=${PORT} \
THC_PATH=/healthz
# Copy passwd file for the non-privileged user from the user-stage
COPY --from=user-stage /etc/passwd /etc/passwd
@ -46,4 +55,4 @@ USER appuser
ENTRYPOINT ["/tini", "--", "/app/invidious_companion"]
HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=3 CMD ["/tini", "--", "/app/invidious_companion", "healthcheck"]
HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=5 CMD ["/thc"]

View file

@ -15,31 +15,13 @@ if (Deno.env.get("GET_FETCH_CLIENT_LOCATION")) {
) as string;
}
}
const args = Deno.args;
const konfigStore = await konfigLoader();
const host = Deno.env.get("HOST") || konfigStore.get("server.host") as string;
const port = Deno.env.get("PORT") || konfigStore.get("server.port") as string;
if (args?.[0] == "healthcheck") {
try {
const response = await fetch(`http://${host}:${port}/healthz`);
if (response.status === 200) {
Deno.exit(0);
} else {
Deno.exit(1);
}
} catch (_) {
Deno.exit(1);
}
}
const { getFetchClient } = await import(getFetchClientLocation);
declare module "hono" {
interface ContextVariableMap extends HonoVariables {}
}
const app = new Hono();
const konfigStore = await konfigLoader();
let innertubeClient: Innertube;
let innertubeClientFetchPlayer = true;
@ -136,6 +118,7 @@ app.use("*", async (c, next) => {
routes(app, konfigStore);
Deno.serve({
port: Number(port),
hostname: host,
port: Number(Deno.env.get("PORT")) ||
konfigStore.get("server.port") as number,
hostname: Deno.env.get("HOST") || konfigStore.get("server.host") as string,
}, app.fetch);