diff --git a/recipes/mongodb.yml b/recipes/mongodb.yml new file mode 100644 index 00000000..40672239 --- /dev/null +++ b/recipes/mongodb.yml @@ -0,0 +1,7 @@ +title: "Mongodb" + +actions: + - merge: database/mongodb.yml + dst: docker-compose.yml + - merge: scripts/mongodb.yml + dst: kool.yml diff --git a/recipes/pick-db.yml b/recipes/pick-db.yml index 9f8574f4..884d2b8d 100644 --- a/recipes/pick-db.yml +++ b/recipes/pick-db.yml @@ -14,4 +14,7 @@ actions: - name: 'PostgreSQL 13.0' actions: - recipe: postgresql-13 + - name: 'Mongodb' + actions: + - recipe: mongodb - name: 'None - do not use a database' diff --git a/templates/database/mongodb.yml b/templates/database/mongodb.yml new file mode 100644 index 00000000..9edfbd26 --- /dev/null +++ b/templates/database/mongodb.yml @@ -0,0 +1,17 @@ +services: + mongodb: + image: mongodb/mongodb-community-server:latest + ports: + - "${KOOL_DATABASE_PORT:-27017}:27017" + environment: + MONGODB_INITDB_ROOT_USERNAME: "${DB_USERNAME-root}" + MONGODB_INITDB_ROOT_PASSWORD: "${DB_PASSWORD-root}" + MONGO_INITDB_DATABASE: "${DB_DATABASE-database}" + healthcheck: + test: ["CMD", "mongo", "--eval", "db.adminCommand('ping')"] + + volumes: + - database:/data/db:delegated + networks: + - kool_local + - kool_global diff --git a/templates/scripts/mongodb.yml b/templates/scripts/mongodb.yml new file mode 100644 index 00000000..44deff20 --- /dev/null +++ b/templates/scripts/mongodb.yml @@ -0,0 +1,3 @@ +scripts: + # CLI access to MongoDB + mongodb: kool exec database mongosh --port=27017 --username=root --password=root