diff --git a/docker/dockerfile.md b/docker/dockerfile.md new file mode 100644 index 0000000..d7419fd --- /dev/null +++ b/docker/dockerfile.md @@ -0,0 +1,129 @@ +# Build Dockerfile + +* Dockerfile for nodejs app (Size: 250MB) + + ```sh + FROM node:12-alpine + + # Create app directory + WORKDIR /app + + # Install app dependencies + # A wildcard is used to ensure both package.json AND package-lock.json are copied + # where available (npm@5+) + COPY package*.json ./ + + RUN npm install --only=production + # If you are building your code for production + # RUN npm ci --only=production + + # Bundle app source + COPY . . + + EXPOSE 5009 + CMD [ "node", "server.js" ] + ``` + + + +* use multi-stage (Size: 195MB) + + ```sh + # in comparison with node:12-alpine image build, this will reduce by further 50MB + # node:12-alpine : 257MB + # multistage alpine:3.12 : 195MB + # + # ------base node------ + FROM alpine:3.12 AS base + # install node + RUN apk add --no-cache nodejs nodejs-npm + # Create app directory + WORKDIR /app + + # Install app dependencies + # A wildcard is used to ensure both package.json AND package-lock.json are copied + # where available (npm@5+) + COPY package*.json ./ + + # ------dependencies------- + FROM base AS dependencies + RUN npm install --only=production + # If you are building your code for production + # RUN npm ci --only=production + # copy production node_modules aside + RUN cp -R node_modules prod_node_modules + + # -----test------ + # add npm run test if needed + + # -----release-------- + FROM base AS release + # copy production node_modules + COPY --from=dependencies /app/prod_node_modules ./node_modules + # Bundle app source + COPY . . + + EXPOSE 5009 + CMD [ "node", "server.js" ] + + ``` + + + +* build + + ```sh + $ docker build [-f Dockerfile] . -t razerpay/visa-backend-api + + // push image + $ docker push razerpay/visa-backend-api + + ``` + + + +* run + + ```sh + $ docker run razerpay/visa-backend-api + + // enter shell + $ docker exec -it sh + ``` + + + +* docker-compose + + ```yaml + version: '2' + services: + api: + image: razerpay/visa-backend-api-multi:latest + #build: . + #command: npm server.js + volumes: + - ./runconfig/default.json:/app/config/default.json + - ./runconfig/ca.crt:/app/config/ca.crt + - ./runconfig/root.crt:/app/config/root.crt + ports: + - "5009:5009" + #depends_on: + # - postgres + #environment: + # DATABASE_URL: postgres://todoapp@postgres/todos + #postgres: + # image: postgres:9.6.2-alpine + # environment: + # POSTGRES_USER: todoapp + # POSTGRES_DB: todos + ``` + +* run docker-compose + + ```sh + $ docker-compose up -d + ``` + + + diff --git a/tomcat/FE.PNG b/tomcat/FE.PNG new file mode 100644 index 0000000..e371661 Binary files /dev/null and b/tomcat/FE.PNG differ diff --git a/tomcat/README.md b/tomcat/README.md new file mode 100644 index 0000000..58fb927 --- /dev/null +++ b/tomcat/README.md @@ -0,0 +1,42 @@ +# Quick Guide for Tomcat + +* [Download](https://tomcat.apache.org/download-80.cgi) and install the Tomcat server + +* Tomcat management [page](http://localhost:8080/manager) + + * ![](./tomcat-manager.PNG) + +* Build the java spring boot project `gradle build`. Artifacts in `build\libs\something.war` + +* Copy java `something.WAR` file to `C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\ROOT.war` + +* run the server on CLI + + ```sh + // "jpda" to allow remote attach to debug java code @ port 8000 + /// + C:\Program Files\Apache Software Foundation\Tomcat 8.5\bin> .\catalina.bat jpda start + ``` + +* Tomcat will extract WAR file to `C:\Program Files\Apache Software Foundation\Tomcat 8.5\ROOT` + +* Build vueJS FE `npm run-script build`. Build artifacts will be created under `dist` + +* Copy vueJS build artifacts contents `dist` to `C:\Program Files\Apache Software Foundation\Tomcat 8.5\ROOT\WEB-INF\classes\public` + +* Reload tomcat to refresh the FE component + + * ![](./FE.PNG) + +* Now you can access the web from browser + + * FE page : `http://localhost:8080` + * BE api : `http://localhost:8080/v1/merchant/...` + +# Remote Debugging (IntelliJ) + +* Setup remote debugging configuration for + * localhost:8000 + +* ![](./intelliJ-remotedebug.PNG) +* ![](./tomcat-start.PNG) \ No newline at end of file diff --git a/tomcat/intelliJ-remotedebug.PNG b/tomcat/intelliJ-remotedebug.PNG new file mode 100644 index 0000000..ed08c02 Binary files /dev/null and b/tomcat/intelliJ-remotedebug.PNG differ diff --git a/tomcat/tomcat-manager.PNG b/tomcat/tomcat-manager.PNG new file mode 100644 index 0000000..3858ab0 Binary files /dev/null and b/tomcat/tomcat-manager.PNG differ diff --git a/tomcat/tomcat-start.PNG b/tomcat/tomcat-start.PNG new file mode 100644 index 0000000..0924f3b Binary files /dev/null and b/tomcat/tomcat-start.PNG differ