From 1a697b5573eaf2d0a1620524ba2a1c83d3c39621 Mon Sep 17 00:00:00 2001 From: Sidd <106573517+sidd-mckz@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:37:52 +0530 Subject: [PATCH 1/2] Update Dockerfile Updating the docker file configuration for advance level --- Dockerfile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1769b59..ad38b417 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,15 @@ -FROM node:4.2 -COPY . /src -RUN cd /src && npm install -EXPOSE 4000 -CMD ["node", "/src/server.js"] +# Stage 1: Build the application +FROM node:18-alpine AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# Stage 2: Create the production image +FROM alpine:latest +WORKDIR /app +COPY --from=builder /app/dist . +COPY start.sh . +EXPOSE 3000 +CMD ["./start.sh"] From 1c1e38a87a5c18bde983f163cac7a60a720c4ddd Mon Sep 17 00:00:00 2001 From: Sidd <106573517+sidd-mckz@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:39:18 +0530 Subject: [PATCH 2/2] Update package.json Added packages --- package.json | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 3e27d499..d0816604 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,37 @@ { - "name": "docker-test", + "name": "my-complex-app", "version": "1.0.0", - "description": "", - "main": "server.js", + "description": "A complex Node.js application for node docker test", + "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js" + "start": "node index.js", + "dev": "nodemon index.js", + "build": "webpack --mode production", + "test": "jest", + "lint": "eslint .", + "format": "prettier --write .", + "deploy": "npm run build && pm2 deploy ecosystem.config.js prod" }, - "author": "Dana Woodman (http://danawoodman.com/)", - "license": "ISC" + "author": "Sidd", + "license": "MIT", + "dependencies": { + "express": "^4.18.2", + "mongoose": "^6.9.2", + "lodash": "^4.17.21" + }, + "devDependencies": { + "nodemon": "^2.0.22", + "webpack": "^5.75.5", + "webpack-cli": "^4.10.0", + "jest": "^29.6.4", + "eslint": "^8.45.0", + "prettier": "^2.8.8", + "pm2": "^5.4.2" + }, + "engines": { + "node": ">=16.14.0" + }, + "config": { + "port": 3000 + } }