This will guide you through setting up a replica set in a docker environment using.
- Docker Compose
- MongoDB Replica Sets
- Mongoose
- Mongoose Transactions
Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!
| AWSTemplateFormatVersion: "2010-09-09" | |
| Description: "Static Website: server-side redirects with headers set on files found." | |
| Metadata: | |
| "AWS::CloudFormation::Interface": | |
| ParameterGroups: | |
| - Label: | |
| default: "Required Parameters" | |
| Parameters: | |
| - DomainName | |
| - Label: |
| AWSTemplateFormatVersion: "2010-09-09" | |
| Description: "Gatsby Static Website client only routes 'server-side' redirects." | |
| Metadata: | |
| "AWS::CloudFormation::Interface": | |
| ParameterGroups: | |
| - Label: | |
| default: "Required Parameters" | |
| Parameters: | |
| - DomainName | |
| - Label: |
| // Request origin Lambda@Edge function | |
| // As shown in https://www.youtube.com/watch?v=pFean2aj_8I AWS Online Tech Talk | |
| // Deploying JAMStack Applications Using S3, CloudFront and Lambda@Edge | |
| exports.handler = async (event) => { | |
| const request = event.Records[0].cf.request; | |
| const uri = request.uri; | |
| if(uri.endsWith('/')) { | |
| request.uri += 'index.html'; | |
| } else if (!uri.includes('.')) { |
| import R from 'ramda' | |
| import mongoose from 'mongoose' | |
| export function newObjectFromArgs(args, model, options) { | |
| const fields = R.compose( | |
| R.omit([]), | |
| R.pathOr({}, ['schema', 'paths']) | |
| )(model) | |
| const newObject = R.reduce((acc, k) => { |
| // load the AWS SDK | |
| const AWS = require('aws-sdk') | |
| // load CloudFront key pair from environment variables | |
| // Important: when storing your CloudFront private key as an environment variable string, | |
| // you'll need to replace all line breaks with \n, like this: | |
| // CF_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIE...1Ar\nwLW...2eL\nFOu...k2E\n-----END RSA PRIVATE KEY-----" | |
| const cloudfrontAccessKeyId = process.env.CF_ACCESS_KEY_ID | |
| const cloudFrontPrivateKey = process.env.CF_PRIVATE_KEY | |
| const signer = new AWS.CloudFront.Signer(cloudfrontAccessKeyId, cloudFrontPrivateKey) |
This will guide you through setting up a replica set in a docker environment using.
Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!
Short (72 chars or less) summary
More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).
Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
| version: '2.4' | |
| services: | |
| db: | |
| image: mongo:4.0.10-xenial | |
| restart: 'always' | |
| command: --wiredTigerCacheSizeGB 1 --auth --directoryperdb | |
| volumes: | |
| - dbData:/data/db | |
| environment: |
| version: '2.4' | |
| services: | |
| db: | |
| image: mongo:4.0.10-xenial | |
| restart: 'always' | |
| command: --wiredTigerCacheSizeGB 1 --auth --directoryperdb | |
| volumes: | |
| - dbData:/data/db | |
| environment: |
| // a list of useful queries for profiler analysis. Starting with the most basic. | |
| // 2.4 compatible | |
| // | |
| // output explained: | |
| // | |
| { | |
| "ts" : ISODate("2012-09-14T16:34:00.010Z"), // date it occurred | |
| "op" : "query", // the operation type | |
| "ns" : "game.players", // the db and collection |