Skip to content

Commit

Permalink
Merge pull request #77 from aninda052/main
Browse files Browse the repository at this point in the history
Update `README` for running docker command
  • Loading branch information
foyzulkarim authored Aug 16, 2023
2 parents 849c6b8 + 54e59f0 commit 4f5f136
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 59 deletions.
64 changes: 8 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,75 +79,27 @@ To run the project locally, follow these steps:
git clone [email protected]:foyzulkarim/mern-video-streaming.git
```

### 2. Install dependencies using npm

#### 2.1 Server dependencies
### 2. Run project locally using docker-compose

```bash
cd server
npm install
```

#### 2.2 Client dependencies

```bash
cd client
yarn
```

### 3. Start the database and Redis

Navigate to the `server` directory and then run `docker-compose up` command like
below. It will spin up the databases as daemon mode.

```bash
cd server
docker-compose up -d
or
npm run db
```

Otherwise the updated `npm run start` script will start the database and web
servers altogether.

### 4. Start the application

#### 4.1 Create `.env` file

Create a `.env` file inside `server` directory and copy paste all the key-values from `.env.template` file.

#### 4.2 Create `uploads` directory

This will create `uploads` directory inside `server` directory.

```bash
npm i -g zx
npm run init-directories
```

#### 4.3 Set the value of `API_SERVER` & `VIDEO_SERVER` for localhost

To run this project locally just set `http://localhost:4000` as `API_SERVER` and `http://localhost:4001` as `VIDEO_SERVER` in `client/src/constants.js`.

Make sure your server(`server/src/server.js`) running on port `4000` and your video-server(`server/src/video-server.js`) running on port `4001`

#### 4.4 Start the server

This will start all the backend services and database together.
#### 2.1 Run the `server` app
From project directory run bellow commands

```bash
cd server
npm run start
```

#### 4.5 Start the client
#### 2.2 Run the `client` app
From project directory run bellow commands

```bash
cd client
yarn start
npm run docker
```

### 5. Usage

### 3. Usage

You can now access the application at http://localhost:3000.

Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ RUN npm install
COPY . .
EXPOSE 4000
EXPOSE 4001
CMD [ "npm", "start"]
CMD [ "npm", "run", "server"]
2 changes: 1 addition & 1 deletion server/src/modules/models/video/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const setupRoutes = (app) => {
const { videoDuration } = await getVideoDurationAndResolution(
`./${req.file.path}`
);
console.log('videoDuration', videoDuration);
// console.log('videoDuration', videoDuration);

const dbPayload = {
...req.body,
Expand Down
3 changes: 2 additions & 1 deletion server/src/modules/models/video/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ const search = async (searchObject) => {
? {
title: new RegExp(searchObject.keyword),
isDeleted: false,
status: VIDEO_STATUS.PUBLISHED
}
: {
isDeleted: false,
status: VIDEO_STATUS.PUBLISHED
};

const projection = {
Expand All @@ -44,7 +46,6 @@ const search = async (searchObject) => {

const sort = searchObject.sort || { viewCount: -1 };
const pageNumber = searchObject.pageNumber || 1;
console.log('search', searchObject);

const videos = await Video.search({ filter, projection, sort, pageNumber });
return videos;
Expand Down

0 comments on commit 4f5f136

Please sign in to comment.