From dd393deeb9eb806cb0bf2b730ab43ad6069f7f22 Mon Sep 17 00:00:00 2001 From: iam-veeramalla Date: Sat, 31 Aug 2024 22:53:57 +0530 Subject: [PATCH 1/6] feat: A simple mern stack app --- docker-compose.yaml | 38 -------------------------------------- mern/backend/Dockerfile | 14 -------------- mern/frontend/Dockerfile | 23 ----------------------- 3 files changed, 75 deletions(-) delete mode 100644 docker-compose.yaml delete mode 100644 mern/backend/Dockerfile delete mode 100644 mern/frontend/Dockerfile diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index fecb786..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,38 +0,0 @@ -services: - backend: - build: ./mern/backend - ports: - - "5050:5050" - networks: - - mern_network - environment: - MONGO_URI: mongodb://mongo:27017/mydatabase - depends_on: - - mongodb - - frontend: - build: ./mern/frontend - ports: - - "5173:5173" - networks: - - mern_network - environment: - REACT_APP_API_URL: http://backend:5050 - - mongodb: - image: mongo:latest - ports: - - "27017:27017" - networks: - - mern_network - volumes: - - mongo-data:/data/db - -networks: - mern_network: - driver: bridge - -volumes: - mongo-data: - driver: local # Persist MongoDB data locally - diff --git a/mern/backend/Dockerfile b/mern/backend/Dockerfile deleted file mode 100644 index c6d703b..0000000 --- a/mern/backend/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM node:18.9.1 - -WORKDIR /app - -COPY package.json . - -RUN npm install - -COPY . . - -EXPOSE 5050 - -CMD ["npm", "start"] - diff --git a/mern/frontend/Dockerfile b/mern/frontend/Dockerfile deleted file mode 100644 index 0b34905..0000000 --- a/mern/frontend/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# Use the official image as a parent image -# Description: Dockerfile for the client side of the MERN stack application - -# Use the official image as a parent image -FROM node:18.9.1 - -# Set the working directory -WORKDIR /app - -# Copy the file from your host to your current location -COPY package.json . - -# Run the command inside your image filesystem -RUN npm install - -# Inform Docker that the container is listening on the specified port at runtime -EXPOSE 5173 - -# Copy the rest of your app's source code from your host to your image filesystem -COPY . . - -# Run the specified command within the container -CMD ["npm", "run", "dev"] From ba5abcf48f336a1abd007d76a99930388ec4b70a Mon Sep 17 00:00:00 2001 From: Abhishek Veeramalla Date: Sat, 31 Aug 2024 23:13:18 +0530 Subject: [PATCH 2/6] Create README.md --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..977ff57 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# A simple MERN stack application + +## Note - Run as containers using + +Switch to the `compose` branch to learn the + +1. Implementation of `Dockerfile` for `client` and `server`. +2. Run the containers using `Docker Compose`. + +## Run it local without Docker + +### Prerequisite + +- Install `npm` + +#### Start server: + +``` +cd mern/server +npm install +npm start +``` + +#### Start Web server + +``` +cd mern/client +npm install +npm run dev +``` + +Screenshot 2024-08-31 at 11 07 58 PM From bdc0e5c77e4f9eee52aa2b70c438e7b4e7424919 Mon Sep 17 00:00:00 2001 From: Abhishek Veeramalla Date: Sat, 31 Aug 2024 23:14:12 +0530 Subject: [PATCH 3/6] Delete .github/workflows directory --- .github/workflows/main.yaml | 58 ------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index ad88952..0000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,58 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ $default-branch ] - pull_request: - branches: [ $default-branch ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - environment: Testing - strategy: - matrix: - node-version: [14.x , 16.x] - max-parallel: 1 - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - with: - ref: 'main-test' - - - name: Install server npm packages - uses: bahmutov/npm-install@v1 - with: - working-directory: mern/server - - - name: Install client npm packages - uses: bahmutov/npm-install@v1 - with: - working-directory: mern/client - - - name: Start server in the background - env: - ATLAS_URI: ${{ secrets.ATLAS_URI }} - run: (cd mern/server && echo "ATLAS_URI=$ATLAS_URI" > config.env && npm start &) - - - name: Start React app in the background - run: (cd mern/client && npm start &) - - - name: Install Cypress and run tests - uses: cypress-io/github-action@v2 - with: - working-directory: mern/client - From 05f9e82038a57aadca22a05b0f2815c6c28e33ac Mon Sep 17 00:00:00 2001 From: Abhishek Veeramalla Date: Sat, 31 Aug 2024 23:15:40 +0530 Subject: [PATCH 4/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 977ff57..1cb2510 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # A simple MERN stack application -## Note - Run as containers using +**Note** - To run this project using `docker compose`, follow the below steps. Switch to the `compose` branch to learn the From c60ab8f6e38b24fd20602896d8b5f96d228572bb Mon Sep 17 00:00:00 2001 From: Abhishek Veeramalla Date: Sun, 1 Sep 2024 09:25:22 +0530 Subject: [PATCH 5/6] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1cb2510..2c672e5 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Switch to the `compose` branch to learn the - Install `npm` -#### Start server: +#### Start Server: ``` cd mern/server @@ -21,7 +21,7 @@ npm install npm start ``` -#### Start Web server +#### Start Client ``` cd mern/client From 73124501e90dcbeea2f3928f96c6a26f468a9bec Mon Sep 17 00:00:00 2001 From: Reshmareshu786 Date: Wed, 23 Oct 2024 21:01:56 +0530 Subject: [PATCH 6/6] Added docker compose --- mern/backend/Dockerfile | 13 +++++++++++++ mern/docker-compose.yaml | 37 +++++++++++++++++++++++++++++++++++++ mern/frontend/Dockerfile | 13 +++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 mern/backend/Dockerfile create mode 100644 mern/docker-compose.yaml create mode 100644 mern/frontend/Dockerfile diff --git a/mern/backend/Dockerfile b/mern/backend/Dockerfile new file mode 100644 index 0000000..5c07de8 --- /dev/null +++ b/mern/backend/Dockerfile @@ -0,0 +1,13 @@ +FROM node:18.9.1 + +WORKDIR /app + +COPY package.json . + +RUN npm install + +COPY . . + +EXPOSE 5050 + +CMD ["npm","start"] \ No newline at end of file diff --git a/mern/docker-compose.yaml b/mern/docker-compose.yaml new file mode 100644 index 0000000..6b3fc22 --- /dev/null +++ b/mern/docker-compose.yaml @@ -0,0 +1,37 @@ +services: + backend: + build: C:/Users/Reshma/MERN-docker-compose/mern/backend + ports: + - "5050:5050" + networks: + - mern_network + environment: + MONGO_URI: mongodb://mongo:27017/mydatabase + depends_on: + - mongodb + + frontend: + build: C:/Users/Reshma/MERN-docker-compose/mern/frontend + ports: + - "5173:5173" + networks: + - mern_network + environment: + REACT_APP_API_URL: http://backend:5050 + + mongodb: + image: mongo:latest + ports: + - "27017:27017" + networks: + - mern_network + volumes: + - mongo-data:/data/db + +networks: + mern_network: + driver: bridge + +volumes: + mongo-data: + driver: local diff --git a/mern/frontend/Dockerfile b/mern/frontend/Dockerfile new file mode 100644 index 0000000..c46b1f8 --- /dev/null +++ b/mern/frontend/Dockerfile @@ -0,0 +1,13 @@ +FROM node:18.9.1 + +WORKDIR /app + +COPY package.json . + +RUN npm install + +COPY . . + +EXPOSE 5173 + +CMD ["npm","run","dev"] \ No newline at end of file