From 09bc9c6b42d61ac9d29300ead081af955765c165 Mon Sep 17 00:00:00 2001 From: Hydroxycarbamide Date: Sun, 20 Oct 2024 17:39:24 +0200 Subject: [PATCH] Fix hostname binding and add healthcheck to docker --- Dockerfile | 8 +++++--- docker-compose.yml | 4 +--- package.json | 4 ++-- src/index.ts | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f9fb29..8d5a5b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ - FROM oven/bun:alpine +ENV HOSTNAME localhost + WORKDIR /startpage COPY assets ./assets COPY src ./src +COPY package.json ./ -EXPOSE 8080/tcp +HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD wget --spider -q http://0.0.0.0/healthcheck || exit 1 -ENTRYPOINT [ "bun", "run", "./src/index.ts" ] +ENTRYPOINT [ "bun", "start" ] diff --git a/docker-compose.yml b/docker-compose.yml index 8172c59..e31e179 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,4 @@ services: build: . restart: unless-stopped ports: - - "8080:8080" - environment: - PORT: 8080 + - "8080:80" diff --git a/package.json b/package.json index 1a6ad5b..ef1b5ed 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "startpage", "module": "./src/index.ts", "type": "module", - "script": { - "start": "bun run index.ts" + "scripts": { + "start": "bun run ./src/index.ts" }, "devDependencies": { "bun-types": "^1.1.31" diff --git a/src/index.ts b/src/index.ts index f9c51c0..37cf779 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,9 +16,8 @@ const fetch = (req: Request) => { Bun.serve({ port: Bun.env.PORT || 80, - hostname: Bun.env.HOSTNAME || "localhost", static: { - "/api/healthcheck": new Response("All good!"), + "/healthcheck": new Response("All good!"), "/": new Response(await Bun.file("./src/index.html").bytes(), { headers: { "Content-Type": "text/html",