diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 74fddc8..d3f1179 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + # Stage 1: Install dependencies (cached if package-lock.json unchanged) FROM node:24-alpine AS deps @@ -9,7 +11,8 @@ ENV NODE_OPTIONS="--max-old-space-size=1024" # Copy package files first for better layer caching COPY package.json package-lock.json* ./ -RUN npm ci +RUN --mount=type=cache,target=/root/.npm \ + npm ci # Stage 2: Run tests (fails the build if tests fail) FROM deps AS test @@ -37,5 +40,13 @@ WORKDIR /app COPY --from=builder /app/dist /usr/share/nginx/html COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf +RUN chown -R nginx:nginx /usr/share/nginx/html + +USER nginx + EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=3s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1 + CMD ["nginx", "-g", "daemon off;"]