An open API service indexing awesome lists of open source software.

https://github.com/km-saifullah/hello-app

This is a repository to practice docker compose with a simple express app with mongoDB
https://github.com/km-saifullah/hello-app

docker docker-compose express mongodb

Last synced: 3 months ago
JSON representation

This is a repository to practice docker compose with a simple express app with mongoDB

Awesome Lists containing this project

README

          

# Hello Express App with MongoDB (Dockerized) πŸ’₯

A simple Express.js application using MongoDB, fully containerized with Docker and Docker Compose. This project demonstrates how to use Mongoose to store and update data inside a MongoDB container.

## πŸ“¦ Features

- Express.js server (ES Modules)
- MongoDB (running in a separate Docker container)
- One route `/api/v1/welcome` to:
- Store message `"hello universe"`
- Increment a counter each time it’s accessed
- Fully containerized using Docker Compose

## πŸ› οΈ Prerequisites

- [Docker](https://www.docker.com/)
- [Docker Compose](https://docs.docker.com/compose/)

## βš™οΈ Build and run containers

**Step-1:** Clone the Repository

```bash
git clone https://github.com/km-saifullah/hello-app.git
```

**Step-2:** Build and runs containers

```bash
docker-compose up --build
```

**Note**: This builds and runs both the express-app and mongo-db containers

**Step-3:** View Logs

```bash
docker-compose logs app
docker-compose logs mongo
```

**Step-4:** Stop and remove containers

```bash
docker-compose down
```

**Note**: When we want to stop the containers we need to run the above commnad only.

## πŸ”₯ API Endpoints

1. Root route: http://localhost:8000/
2. Welcome Message Route: http://localhost:8000/api/v1/welcome

## πŸš€ Test

```bash
curl http://localhost:8000/api/v1/welcome
```

## πŸ™‹β€β™‚οΈ Author

Khaled Md Saifullah

Backend Developer

Follow me on:

- [Linkedin](https://www.linkedin.com/in/kmsaifullah)
- [Github](https://github.com/km-saifullah)