Skip to content

Mongo-Express implemented in Docker using the Autopilot Pattern

License

Notifications You must be signed in to change notification settings

autopilotpattern/mongo-express

Repository files navigation

AutoPilot Pattern Mongo Express

An example implementation of a simple MongoDB application (Mongo Express) on top of AutoPilot Pattern MongoDB

Architecture

A running cluster includes the following components:

  • AutoPilot Pattern MongoDB: for auto-scaling MongoDB via replica sets
  • ContainerPilot: included in our Mongo Express container to coordinate runtime configuration rewriting after cluster changes
  • Consul: used to coordinate replication and failover
  • Mongo Express: a simple MongoDB application for browsing/editing the data stored in our cluster

Running the cluster

Starting a new cluster is easy once you have your _env file set with the configuration details

Triton

  • ./setup.sh
  • docker-compose up -d
  • open http://$(triton ip mongoexpress_mongo-express_1):8081

Local (or Non-Triton)

  • docker-compose up -f local-compose.yml -d
  • open http://localhost:8081

The setup.sh script will check that your environment is setup correctly and will create an _env file that includes injecting an environment variable for the Consul hostname into the Mongo and Mongo-Express containers so we can take advantage of Triton Container Name Service (CNS).

The MongoDB cluster will be initialized according to the process outlined in the AutoPilot Pattern MongoDB README, and Mongo Express will be configured to point at all active MongoDB nodes in the cluster (via Consul and ContainerPilot).

Run docker-compose -f local-compose.yml scale mongodb=2 to add a replica (or more than one!). The replicas will automatically be added to the replica set on the master and will register themselves in Consul as replicas once they're ready, and the Mongo Express configuration will be reloaded to point to the new replicas.

Configuration

The configuration items noted for AutoPilot Pattern MongoDB apply for this image as well as the following explicit parameters for this implementation (passed in via _env file next to docker-compose.yml and local-compose.yml):

  • CONSUL (optional): when using local-compose.yml, this will default to consul (and thus use the DNS provided by Docker), but for deploying on Triton via docker-compose.yml, this should be set to the CNS path of the consul service (consul.svc.XXX...)
  • any Mongo Express environment variables, such as ME_CONFIG_OPTIONS_EDITORTHEME or ME_CONFIG_MONGODB_ENABLE_ADMIN; see the Mongo Express documentation for a more complete list

Sponsors

Initial development of this project was sponsored by Joyent.

About

Mongo-Express implemented in Docker using the Autopilot Pattern

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages