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 - diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c672e5 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# A simple MERN stack application + +**Note** - To run this project using `docker compose`, follow the below steps. + +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 Client + +``` +cd mern/client +npm install +npm run dev +``` + +Screenshot 2024-08-31 at 11 07 58 PM diff --git a/mern/backend/Dockerfile b/mern/backend/Dockerfile index c6d703b..5c07de8 100644 --- a/mern/backend/Dockerfile +++ b/mern/backend/Dockerfile @@ -10,5 +10,4 @@ COPY . . EXPOSE 5050 -CMD ["npm", "start"] - +CMD ["npm","start"] \ No newline at end of file diff --git a/docker-compose.yaml b/mern/docker-compose.yaml similarity index 79% rename from docker-compose.yaml rename to mern/docker-compose.yaml index fecb786..6b3fc22 100644 --- a/docker-compose.yaml +++ b/mern/docker-compose.yaml @@ -1,6 +1,6 @@ services: backend: - build: ./mern/backend + build: C:/Users/Reshma/MERN-docker-compose/mern/backend ports: - "5050:5050" networks: @@ -11,7 +11,7 @@ services: - mongodb frontend: - build: ./mern/frontend + build: C:/Users/Reshma/MERN-docker-compose/mern/frontend ports: - "5173:5173" networks: @@ -34,5 +34,4 @@ networks: volumes: mongo-data: - driver: local # Persist MongoDB data locally - + driver: local diff --git a/mern/frontend/Dockerfile b/mern/frontend/Dockerfile index 0b34905..c46b1f8 100644 --- a/mern/frontend/Dockerfile +++ b/mern/frontend/Dockerfile @@ -1,23 +1,13 @@ -# 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"] +EXPOSE 5173 + +CMD ["npm","run","dev"] \ No newline at end of file