Skip to content

Commit

Permalink
🐳 : add scripts to initiate mongo database
Browse files Browse the repository at this point in the history
  • Loading branch information
cdubuisson committed Aug 13, 2019
1 parent cdf3d2e commit 3aff994
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Dockerfile-db
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mongo

COPY /src/test/resources/db/*.js /docker-entrypoint-initdb.d/
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ Building Gaia with docker is simple :
docker build -t gaia .
```

We provide a simple `docker-compose.yml` to allow you to start gaia with a mongo database.
To build mongo database with initiated data :

```bash
docker build -f Dockerfile-db -t gaia-db .
```

Either, we provide a simple `docker-compose.yml` to allow you to start gaia with the mongo database.

Just run `docker-compose up -d`

Expand Down
13 changes: 9 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
version: "3"
services:
gaia:
image: gaia
build: .
image: gaia
ports:
- '8080:8080'
- '8080:8080'
environment:
- "GAIA_MONGODB_URI=mongodb://mongo/gaia"
- "GAIA_MONGODB_URI=mongodb://mongo/gaia"

mongo:
image: mongo
build:
context: .
dockerfile: ./Dockerfile-db
image: gaia-db
10 changes: 10 additions & 0 deletions src/test/resources/db/00_team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let gaia = db.getSiblingDB('gaia');
gaia.team.drop();
gaia.team.insert([
{
"_id": "Ze Team"
},
{
"_id": "Not Ze Team"
}
]);
12 changes: 12 additions & 0 deletions src/test/resources/db/10_user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
gaia = db.getSiblingDB('gaia');
gaia.user.drop();
gaia.user.insert([
{
"_id": "admin",
"team": {"$ref": "team", "$id": "Ze Team"}
},
{
"_id": "Mary J",
"team": {"$ref": "team", "$id": "Not Ze Team"}
}
]);
43 changes: 43 additions & 0 deletions src/test/resources/db/20_module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
gaia = db.getSiblingDB('gaia');
gaia.terraformModule.drop();
gaia.terraformModule.insert([
{
"_id": "e01f9925-a559-45a2-8a55-f93dc434c676",
"name": "terraform-docker-mongo",
"description": "A sample terraform 🌍 module for running a mongodb 🍃 database inside a docker 🐳 container",
"gitRepositoryUrl": "https://github.com/juwit/terraform-docker-mongo.git",
"directory": null,
"gitBranch": "master",
"cliVersion": "0.11.14",
"authorizedTeams": [{"$ref": "team", "$id": "Ze Team"}],
"estimatedMonthlyCost": 0.99,
"estimatedMonthlyCostDescription": "Kamoulox",
"variables": [
{
"name": "mongo_container_name",
"description": "the name of the docker container",
"defaultValue": null,
"editable": true
},
{
"name": "mongo_exposed_port",
"description": "the exposed port of the mongo container",
"defaultValue": null,
"editable": true
}
]
},
{
"_id": "845543d0-20a5-466c-8978-33c9a4661606",
"name": "terraform-docker-mongo-limited",
"description": "A module only visible by admin and team Not Ze Team",
"gitRepositoryUrl": "https://github.com/juwit/terraform-docker-mongo.git",
"directory": null,
"gitBranch": "master",
"cliVersion": "0.11.14",
"authorizedTeams": [{"$ref": "team", "$id": "Not Ze Team"}],
"estimatedMonthlyCost": 9.99,
"estimatedMonthlyCostDescription": "Not Ze Team! Not Ze Team!",
"variables": []
},
]);
52 changes: 52 additions & 0 deletions src/test/resources/db/30_stack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
gaia = db.getSiblingDB('gaia');
gaia.stack.drop();
gaia.stack.insert([
{
"_id": "5a215b6b-fe53-4afa-85f0-a10175a7f264",
"moduleId": "e01f9925-a559-45a2-8a55-f93dc434c676",
"name": "mongo-instance-1",
"description": "first instance of mongo module",
"variableValues": {
"mongo_container_name": "test",
"mongo_exposed_port": "27117"
},
"providerSpec": "provider \"docker\" {\n host = \"unix:///var/run/docker.sock\"\n}",
"state": "NEW",
"ownerTeam": {"$ref": "team", "$id": "Ze Team"},
"estimatedRunningCost": null,
"createdBy": {"$ref": "user", "$id": "admin"},
"createdAt": new Date(),
"updatedBy": null,
"updatedAt": null
},
{
"_id": "143773fa-4c2e-4baf-a7fb-79d23e01c5ca",
"moduleId": "e01f9925-a559-45a2-8a55-f93dc434c676",
"name": "mongo-instance-2",
"description": "second instance of mongo module",
"variablesValues": {},
"providerSpec": null,
"state": "NEW",
"ownerTeam": {"$ref": "team", "$id": "Ze Team"},
"estimatedRunningCost": null,
"createdBy": {"$ref": "user", "$id": "admin"},
"createdAt": new Date(),
"updatedBy": null,
"updatedAt": null
},
{
"_id": "845543d0-20a5-466c-8978-33c9a4661606",
"moduleId": "845543d0-20a5-466c-8978-33c9a4661606",
"name": "mongo-instance-limited",
"description": "instance of mongo module for team Not Ze Team",
"variablesValues": {},
"providerSpec": null,
"state": "NEW",
"ownerTeam": {"$ref": "team", "$id": "Not Ze Team"},
"estimatedRunningCost": null,
"createdBy": {"$ref": "user", "$id": "Mary J"},
"createdAt": new Date(),
"updatedBy": null,
"updatedAt": null
}
]);

0 comments on commit 3aff994

Please sign in to comment.