Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/anhcaooo/electric-mongo

Primary database for electric application
https://github.com/anhcaooo/electric-mongo

docker-image mongodb

Last synced: about 1 month ago
JSON representation

Primary database for electric application

Awesome Lists containing this project

README

        

# electric-mongo

A database for electric application

## Prerequisite
- Make sure you have [Mongosh](https://www.mongodb.com/docs/mongodb-shell/install/) installed on your machine.
- Docker in your machine or environment is up and running

## Useful commands
### Access to MongoDB
In order to access to MongoDB, you can use the following command
```bash
docker exec -it mongosh -u -p
```

### Navigate to specific database - collection
1. After access to MongoDB successfully, navigate to specific database
```bash
use
```

2. If you want to navigate to a specific collection inside database
```bash
use
```

### More options
If you are looking for more options, please see the [Run commands documentation](https://www.mongodb.com/docs/mongodb-shell/run-commands/)

## Build Docker image
**Note**: in case you are planning to push your docker image, you first need to log in Docker (only in case you have not logged in)

```bash
docker login -u "" -p "" docker.io
```

#### Step 1
Build image locally
```bash
# Option 1 (not recommended)
docker build --tag : .

# Option 2 (not recommended)
docker build -t : .

# Option 3 (recommended)
# this command by default will build image with tag version 'latest'.
# this is an enhancement when before the image is built, all unit tests will be executed
make docker
```

#### Step 2
**Note**: firstly need to log in Docker (only in case you have not logged in)

```bash
docker login -u "" -p "" docker.io
```

Tag image
```bash
docker tag : /:
```

#### Step 3
Push image to Docker hub
```bash
docker push /:
```

## Run Docker image locally
```bash
docker run --name electric-mongo -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME= -e MONGO_INITDB_ROOT_PASSWORD= :
```