Hi team, Is there anyway where I can run growthbo...
# ask-questions
c
Hi team, Is there anyway where I can run growthbook in a docker-compose with pre-configured feature flags setup?I think this might be a use of config.yml but not sure how to implement this.. any suggestions? (This is to avoid to use the web app to have to setup everything each time.)
f
config.yml won't be flexible enough for that use case, it doesn't describe features
(just data sources and metrics)
state is only stored in mongo, so you could distribute it with mongo that has the state defined, with flags etc.
👍 1
c
For those who had a similar issue, on how to save state. Here is my solution on how to save Growthbook state. With
docker-compose up
, use the
mongodump
command to create a backup and output it to the mounted directory:
Copy code
docker exec -it mongo mongodump --out /backup -u root -p develop --authenticationDatabase admin
docker-compose.yml
Copy code
...
mongo:
    container_name: mongo
    image: "mongo:latest"
    ports:
      - 27017:27017
    volumes:
      - mongodata:/data/db
      - ./.growthbook/data:/backup
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
      interval: 10s
      timeout: 5s
      retries: 3
  mongo-restore:
    image: mongo
    depends_on:
      - mongo
    volumes:
      - ./.growthbook/data:/backup
    entrypoint: ["bash", "-c", "mongorestore --drop /backup -u <root_user_here> -p <root_password_here> --authenticationDatabase admin --host mongo:27017"]
 growthbook:
    container_name: growthbook
    image: "growthbook/growthbook:latest"
    ports:
      - "4000:3000"
      - "3100:3100"
    depends_on:
      mongo:
        condition: service_healthy
...
Disclaimer: This is a localhost example(not tested) and not a production implementation or guideline. Please consider your relevant changes. Thank you and hope it helps others also please let me know your thoughts.
Also thank you @fresh-football-47124 for your prompt answer.