From 6e5b738f0ff732c9dabd08ae10a4164d87f65b69 Mon Sep 17 00:00:00 2001 From: Belinda Marion Kobusingye <46527380+Codebmk@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:36:44 +0300 Subject: [PATCH] Update Dockerfile --- netmanager-app/Dockerfile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/netmanager-app/Dockerfile b/netmanager-app/Dockerfile index a67f97c6c2..1e755865ee 100644 --- a/netmanager-app/Dockerfile +++ b/netmanager-app/Dockerfile @@ -1,20 +1,31 @@ # Use the official Node.js image as a base -FROM node:18 +FROM node:18-alpine AS builder # Set the working directory WORKDIR /app +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package*.json ./ + # Copy package.json and package-lock.json COPY package*.json ./ -# Install dependencies -RUN npm install +RUN npm ci # Copy the rest of the application code COPY . . +RUN npm run build + +# Add healthcheck +HEALTHCHECK --interval=30s --timeout=3s \ + CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1 + +USER node + # Expose the application port EXPOSE 3000 # Command to run the application -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "run", "start"] \ No newline at end of file