From 011a3f7790badee741195f651e1733a8e2461f28 Mon Sep 17 00:00:00 2001 From: Georgiy Sitnikov Date: Fri, 14 Aug 2026 11:28:09 +0200 Subject: [PATCH] Add healthcheck to Dockerfiles for API and web services --- api/Dockerfile | 8 ++++++++ web/Dockerfile | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/api/Dockerfile b/api/Dockerfile index ee69c8a..b3b7672 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -3,6 +3,14 @@ WORKDIR /app COPY package.json package-lock.json* ./ RUN npm install --omit=dev && npm cache clean --force COPY server.js ./ + ENV NODE_ENV=production +ENV PORT=3000 + EXPOSE 3000 CMD ["node", "server.js"] + +HEALTHCHECK --interval=5m \ + --timeout=5s \ + --retries=3 \ + CMD wget --spider -q http://localhost:${PORT}/api/config \ No newline at end of file diff --git a/web/Dockerfile b/web/Dockerfile index 9b30e63..aa33b8c 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -18,3 +18,8 @@ FROM nginx:alpine COPY web/nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/dist /usr/share/nginx/html # exercise media (img/gif) is mounted at runtime from the media volume + +HEALTHCHECK --interval=5m \ + --timeout=5s \ + --retries=3 \ + CMD curl -fs http://localhost/