Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Application-Code/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
FROM node:14
WORKDIR /usr/src/app
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .
CMD ["node", "index.js"]

CMD ["node", "index.js"]

19 changes: 16 additions & 3 deletions Application-Code/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
FROM node:14
WORKDIR /usr/src/app

WORKDIR /app

COPY package*.json ./
RUN npm install

RUN npm install --only=production

# Install 'serve' globally (for serving static files)
RUN npm install -g serve

COPY . .
CMD [ "npm", "start" ]

RUN npm run build

Comment on lines +7 to +15
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Build will likely fail: devDependencies are not installed before npm run build.

npm install --only=production excludes devDependencies (e.g., react-scripts), which are required for the build step. This will break npm run build. Also, Node 14 is EOL; consider upgrading and using a multi-stage build to reduce image size and improve security.

Apply this multi-stage refactor:

-FROM node:14
-
-WORKDIR /app
-
-COPY package*.json ./
-
-RUN npm install --only=production
-
-# Install 'serve' globally (for serving static files)
-RUN npm install -g serve
-
-COPY . .
-
-RUN npm run build
-
-EXPOSE 3000
-
-CMD ["serve", "-s", "build", "-l", "3000"]
+FROM node:18-alpine AS builder
+WORKDIR /app
+COPY package*.json ./
+# Install all deps (including dev) for build determinism and speed
+RUN npm ci
+COPY . .
+RUN npm run build
+
+# Runtime stage
+FROM node:18-alpine AS runtime
+WORKDIR /app
+RUN npm install -g serve@14
+# Copy only the built assets
+COPY --from=builder /app/build /app/build
+EXPOSE 3000
+# Drop root
+USER node
+CMD ["serve", "-s", "build", "-l", "3000"]

Also applies to: 1-20

🤖 Prompt for AI Agents
In Application-Code/frontend/Dockerfile around lines 7 to 15, the Dockerfile
runs npm install --only=production before npm run build which omits
devDependencies (like build toolchains) and will break the build; refactor to a
multi-stage build: use a modern Node LTS base (e.g., node:18) in the builder
stage, copy package.json and package-lock.json, run npm install (full dev deps)
and run npm run build, then create a smaller production stage (node:18-alpine or
nginx) that copies only the build output, installs only production deps if
needed, and does not include devDependencies; optionally install a lightweight
static server in the final stage or use nginx and avoid global serve in builder
to minimize image size and surface attack surface.

EXPOSE 3000

CMD ["serve", "-s", "build", "-l", "3000"]

113 changes: 0 additions & 113 deletions Jenkins-Pipeline-Code/Jenkinsfile-Backend

This file was deleted.

113 changes: 0 additions & 113 deletions Jenkins-Pipeline-Code/Jenkinsfile-Frontend

This file was deleted.

25 changes: 0 additions & 25 deletions Jenkins-Server-TF/.terraform.lock.hcl

This file was deleted.

16 changes: 0 additions & 16 deletions Jenkins-Server-TF/backend.tf

This file was deleted.

16 changes: 0 additions & 16 deletions Jenkins-Server-TF/ec2.tf

This file was deleted.

10 changes: 0 additions & 10 deletions Jenkins-Server-TF/gather.tf

This file was deleted.

4 changes: 0 additions & 4 deletions Jenkins-Server-TF/iam-instance-profile.tf

This file was deleted.

5 changes: 0 additions & 5 deletions Jenkins-Server-TF/iam-policy.tf

This file was deleted.

17 changes: 0 additions & 17 deletions Jenkins-Server-TF/iam-role.tf

This file was deleted.

3 changes: 0 additions & 3 deletions Jenkins-Server-TF/provider.tf

This file was deleted.

Loading