From 08c4be4f7eb8e985114d1f87a8bd69a7bad0a9ee Mon Sep 17 00:00:00 2001 From: whoswhip Date: Tue, 30 Dec 2025 22:00:20 -0500 Subject: [PATCH] feat: add health checks for backend and frontend services in docker-compose.yml --- SharpbinV3.Client/Dockerfile | 1 + SharpbinV3.Server/Dockerfile | 2 ++ docker-compose.yml | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/SharpbinV3.Client/Dockerfile b/SharpbinV3.Client/Dockerfile index e383019..c1d8241 100644 --- a/SharpbinV3.Client/Dockerfile +++ b/SharpbinV3.Client/Dockerfile @@ -9,5 +9,6 @@ RUN npm run build FROM node:20-alpine as runner WORKDIR /app COPY --from=build /app . +RUN apk add --no-cache wget EXPOSE 5173 CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "5173"] diff --git a/SharpbinV3.Server/Dockerfile b/SharpbinV3.Server/Dockerfile index e25a7ef..8bd9678 100644 --- a/SharpbinV3.Server/Dockerfile +++ b/SharpbinV3.Server/Dockerfile @@ -8,5 +8,7 @@ RUN dotnet publish SharpbinV3.Server.csproj -c Release -o /app/out FROM mcr.microsoft.com/dotnet/aspnet:10.0 WORKDIR /app COPY --from=build /app/out . +RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/* +ENV ASPNETCORE_URLS=http://+:8080 EXPOSE 8080 ENTRYPOINT ["dotnet", "SharpbinV3.Server.dll"] diff --git a/docker-compose.yml b/docker-compose.yml index 09dcdf0..2bf1984 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,8 +14,12 @@ services: - ./SharpbinV3.Server/appsettings.json:/app/appsettings.json networks: - sharpbin-net - expose: - - "8080" + healthcheck: + test: 'wget --no-verbose --spider http://localhost:8080/health || exit 1' + interval: 30s + timeout: 30s + retries: 5 + start_period: 30s restart: unless-stopped frontend: @@ -30,6 +34,12 @@ services: - "5173:5173" networks: - sharpbin-net + healthcheck: + test: 'wget --no-verbose --spider http://localhost:5173/health || exit 1' + interval: 30s + timeout: 30s + retries: 5 + start_period: 30s restart: unless-stopped volumes: