SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

Why single node replica set is needed on docker-compose? #386

Closed eercanayar closed 4 years ago

eercanayar commented 4 years ago

I'm using restheart with the template provided in docker-compose.yml on prod. What I didn't understand is why we need single node replica set here? Isn't it possible to interact restheart with mongo directly?

Expected Behavior

Docker containers: restheart + mongod

Current Behavior

Docker containers: restheart + mongod + single node replica

Context

This make infrastructure more complex. I want to throw away unnecessary parts of my infra.

Environment

Steps to Reproduce

Possible Implementation

ujibang commented 4 years ago

Hi @eercanayar

the docker-compose.yml uses a MongoDB replica set, because MongoDB supports Change Streams and Transactions only for Replica Sets.

Consequently RESTHeart supports Change Streams and Transactions when connected to a Replica Set.

If you don't need changes streams or transactions, you can safely connect to a normal MongoDB deployment.

eercanayar commented 4 years ago

Thanks a lot! Changed my docker-compose.yml to this. Sharing here if someone else needs a reference.

services:
    restheart:
        image: softinstigate/restheart:5.1.1
        container_name: restheart
        environment:
            MONGO_URI: mongodb://restheart:R3ste4rt!@mongodb
        command: ["--envFile", "/opt/restheart/etc/default.properties"]
        depends_on:
            - mongodb
        networks:
            - restheart-backend
        ports:
            - "8080:8080"

    mongodb:
        image: mongo:4.2
        container_name: mongodb
        command: ["--bind_ip", "mongodb", "--auth", "--setParameter", "diagnosticDataCollectionEnabled=false"]
        environment:
            MONGO_INITDB_ROOT_USERNAME: restheart
            MONGO_INITDB_ROOT_PASSWORD: R3ste4rt!
        volumes:
            - ./mongo-data/:/data/db
        networks:
            - restheart-backend