Skip to content

Commit e7d3078

Browse files
author
Alexandros Coutsicos
committed
New Healthcheck
1 parent f11fed9 commit e7d3078

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

directus/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ USER root
44
RUN corepack enable
55
USER node
66

7-
RUN pnpm install directus-extension-blurhasher
7+
WORKDIR /directus
8+
9+
COPY healthcheck.mjs ./healthcheck.mjs
10+
11+
RUN pnpm install directus-extension-blurhasher
12+
13+
HEALTHCHECK --interval=12s --timeout=12s --start-period=30s CMD node healthcheck.mjs

directus/healthcheck.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import https from "https";
2+
3+
https.get("https://www.data.rabe.ch/server/health", res => {
4+
console.log(`STATUS: ${res.statusCode}`);
5+
return process.exit(
6+
res.statusCode === 200 ? 0 : 1
7+
)}
8+
).on("error", (err) => {
9+
console.log('ERROR: ', err);
10+
process.exit(1)
11+
}
12+
);

docker-compose.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ services:
2020
depends_on:
2121
directus:
2222
condition: service_healthy
23-
healthcheck:
24-
test: wget --no-verbose --tries=1 --spider ${NEXT_PUBLIC_FE_URL}/api/healthcheck || exit 1
25-
start_period: 15s
26-
interval: 15s
27-
timeout: 15s
28-
retries: 3
2923

3024
directus:
3125
container_name: rabe-directus
@@ -41,9 +35,3 @@ services:
4135
- ./directus/migrations:/directus/migrations
4236
env_file: .env
4337
restart: unless-stopped
44-
healthcheck:
45-
test: wget --no-verbose --tries=1 --spider ${NEXT_PUBLIC_BE_URL}/server/health || exit 1
46-
start_period: 15s
47-
interval: 15s
48-
timeout: 15s
49-
retries: 3

next/Dockerfile.prod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ ENV PORT=3000
6767
# server.js is created by next build from the standalone output
6868
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
6969
ENV HOSTNAME="0.0.0.0"
70-
CMD ["node", "server.js"]
70+
CMD ["node", "server.js"]
71+
72+
COPY healthcheck.mjs ./healthcheck.mjs
73+
HEALTHCHECK --interval=12s --timeout=12s --start-period=30s CMD node healthcheck.mjs

next/healthcheck.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import https from "https";
2+
3+
https.get("https://www.rabe.ch/api/healthcheck", res => {
4+
console.log(`STATUS: ${res.statusCode}`);
5+
return process.exit(
6+
res.statusCode === 200 ? 0 : 1
7+
)}
8+
).on("error", (err) => {
9+
console.log('ERROR: ', err);
10+
process.exit(1)
11+
}
12+
);

0 commit comments

Comments
 (0)