👷
Guia Edutec DevOps
Guia Edutec by CIEB
English
English
  • Introduction
  • Database
  • Back-end
  • Front-end
Powered by GitBook
On this page
  • Step-by-step
  • 1. Access the repository on GitHub via the link
  • 2. Clone the repository to your server
  • 3. Access the created folder
  • 4. By default the exposed port for the database is 30998.
  • 5. Default User Setting: geos
  • 6. To start the database, only the first time, run the docker command, as shown below:
  • 7. After the database is initialized, if the container is not running, just run the docker command, as shown below:

Was this helpful?

Edit on GitHub

Database

Instructions for running the application's database

PreviousIntroductionNextBack-end

Last updated 3 years ago

Was this helpful?

Step-by-step

1. Access the repository on GitHub via the link

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"
          }
      ]
  }
);
./mongo-seed/Dockerfile
FROM mongo:4.2.12

COPY database/guia_edutec /guia_edutec
CMD  mongorestore --host=mongo --db=guia_edutec -u geos -p <password-default> --authenticationMechanism SCRAM-SHA-256 /guia_edutec --gzip --drop

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

Attention!

If the application is deployed on the Windows operating system, it is necessary to use the

https://github.com/guiaedutec/geos-database
Windows Subsystem for Linux (WSL) 2