Database
Instructions for running the application's database
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.git3. Access the created folder
$ cd geos-database4. 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)
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:
db.createUser(
  {
      user: "geos",
      pwd: "<password-default>",
      roles: [
          {
              role: "readWrite",
              db: "guia_edutec"
          }
      ]
  }
);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 --drop6. To start the database, only the first time, run the docker command, as shown below:
~/geos-database$ docker-compose up -d --build7. 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 mongoAttention!
If the application is deployed on the Windows operating system, it is necessary to use the Windows Subsystem for Linux (WSL) 2
Last updated
Was this helpful?