Database

Instructions for running the application's database

Step-by-step

2. Clone the repository to your server

$ git clone https://github.com/guiaedutec/geos-database.git

3. Access the created folder

$ cd geos-database

4. By default the exposed port for the database is 30998.

If you need to change, the settings are stored in the file.

It is necessary to create a password for the database root user (line 10)

The password must be alphanumeric with at least 6 characters

./docker-compose.yml
version: "3.4"
services:
  mongo:
    image: mongo:4.2.12
    container_name: geos-database
    environment:
      - PUID=1000
      - PGID=1000
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=<password-root-database>
      - MONGO_INITDB_DATABASE=guia_edutec
    ports:
      - "30998:27017"
    restart: unless-stopped
    networks:
      - geos-network
    volumes:
      - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
  mongo-seed:
    build: ./mongo-seed
    networks:
      - geos-network
    depends_on:
      - mongo
    links:
      - mongo
networks:
  geos-network:

5. Default User Setting: geos

Now create another password for the default user. The password must be the same in the two files below:

The password must be alphanumeric with at least 6 characters

./mongo-init.js
db.createUser(
  {
      user: "geos",
      pwd: "<password-default>",
      roles: [
          {
              role: "readWrite",
              db: "guia_edutec"
          }
      ]
  }
);

6. To start the database, only the first time, run the docker command, as shown below:

~/geos-database$ docker-compose up -d --build

7. After the database is initialized, if the container is not running, just run the docker command, as shown below:

~/geos-database$ docker-compose up -d mongo

Last updated

Was this helpful?