diff --git a/docker-compose.yml b/docker-compose.yml index a374b91..9d543b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,4 +9,9 @@ services: - .:/app ports: - "$PORT:$PORT" - command: sh -c "npm i -g pnpm && pnpm install && pnpm dev" \ No newline at end of file + command: sh -c "npm i -g pnpm && pnpm install && pnpm dev" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:$PORT/health"] + interval: 30s + timeout: 10s + retries: 1 \ No newline at end of file diff --git a/src/web/health.ts b/src/web/health.ts new file mode 100644 index 0000000..26f1b19 --- /dev/null +++ b/src/web/health.ts @@ -0,0 +1,7 @@ +import { Express } from 'express'; + +export default function healthRoute(app: Express) { + app.get('/health', (req, res) => { + res.status(200).send('ok'); + }); +} diff --git a/src/webserver.ts b/src/webserver.ts index 1e86c04..e663c26 100644 --- a/src/webserver.ts +++ b/src/webserver.ts @@ -26,7 +26,7 @@ export default async function webserver() { }); const IgnoredPaths = ['/favicon.ico', '/robots.txt', "/", "/hello"]; - const KnownPaths = ["/git-commit", "/"]; + const KnownPaths = ["/git-commit", "/", "/health"]; // log all incoming requests app.use((req, res, next) => {