Skip to content

Commit

Permalink
docs: add instructions for the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizendae committed Dec 25, 2023
1 parent c59e75b commit d7ec6a8
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
1. Create a local mongodb instance in Docker.
## 1. Create a local mongodb instance in Docker.
`docker run -d -p 27017:27017 --name movies-mongo mongo:latest`

You're connection string is `mongodb://localhost:27017/?retryWrites=true&w=majority`
2. Clone this repo that helps us populate sample movies data
## 2. Clone this repo that helps us populate sample movies data

https://github.com/neelabalan/mongodb-sample-dataset

Expand Down Expand Up @@ -36,4 +36,31 @@ sample_mflix
2023-12-22T19:53:35.554+0100 connected to: mongodb://localhost:27017/
2023-12-22T19:53:35.555+0100 dropping: sample_mflix.users
2023-12-22T19:53:35.564+0100 185 document(s) imported successfully. 0 document(s) failed to import.
```

## 3. create a Dockerfile for the movies app

Get inspired from https://itnext.io/lets-dockerize-a-nodejs-express-api-22700b4105e4

Create the Dockerfile. with the right CMD command to start the app.

Try to understand each line of the Dockerfile.

## 4. Build the docker image
```bash
docker build -t movies-backend:1.0 .
```

## 5. Run the docker image
```bash
docker run -d -p 5000:5000 --env-file=.env --name movies-backend movies-backend:1.0

# be careful with the env file. it should be in the same directory as the Dockerfile
# be careful with the IP adress of mongoDB in the .env file. it should be the IP address of your running mongo docker container
```

## 6. Test the app
```bash
# from your local machine since you used 5000:5000 in the docker run command this should work.
curl http://localhost:5000/healthcheck
```

1 comment on commit d7ec6a8

@vercel
Copy link

@vercel vercel bot commented on d7ec6a8 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.