diff options
| author | jc0b <j.burley@vu.nl> | 2020-05-11 20:43:03 +0200 |
|---|---|---|
| committer | jc0b <j.burley@vu.nl> | 2020-06-09 14:51:50 +0200 |
| commit | 4f8612501ed5cf9653aa6ab14c8455605f56464b (patch) | |
| tree | 754a3ae7e1822184be5a195a90e30108bcebe24f | |
| parent | 3e182d0476637fca2ee618d26aa6776f0e20b2c7 (diff) | |
Added mongodb dockerfile, removed tests being added to sql db
| -rw-r--r-- | database/Dockerfile | 2 | ||||
| -rw-r--r-- | docker-compose.yml | 8 | ||||
| -rw-r--r-- | mongodb/Dockerfile | 3 | ||||
| -rw-r--r-- | mongodb/mongo-init-opendc-db.sh | 50 | ||||
| -rw-r--r-- | mongodb/mongo-opendc-schema.sh | 7 |
5 files changed, 55 insertions, 15 deletions
diff --git a/database/Dockerfile b/database/Dockerfile index 0e933b40..e30aed51 100644 --- a/database/Dockerfile +++ b/database/Dockerfile @@ -5,4 +5,4 @@ MAINTAINER Fabian Mastenbroek <f.s.mastenbroek@student.tudelft.nl> ADD schema.sql /docker-entrypoint-initdb.d # Add test data into database -ADD test.sql /docker-entrypoint-initdb.d +#ADD test.sql /docker-entrypoint-initdb.d diff --git a/docker-compose.yml b/docker-compose.yml index a7c3698f..9f3cf805 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -61,6 +61,8 @@ services: OPENDC_DB_PASSWORD: opendcpassword ports: - 27017:27017 + #volumes: + # - mongo-volume:/data/db mongo-express: image: mongo-express @@ -69,4 +71,8 @@ services: - 8082:8081 environment: ME_CONFIG_MONGODB_ADMINUSERNAME: root - ME_CONFIG_MONGODB_ADMINPASSWORD: rootpassword
\ No newline at end of file + ME_CONFIG_MONGODB_ADMINPASSWORD: rootpassword + +volumes: + mongo-volume: + external: false
\ No newline at end of file diff --git a/mongodb/Dockerfile b/mongodb/Dockerfile index e8dd98bc..b4eb9dd1 100644 --- a/mongodb/Dockerfile +++ b/mongodb/Dockerfile @@ -2,5 +2,4 @@ FROM mongo:4.2.5 MAINTAINER Jacob Burley <j.burley@vu.nl> # Import init script -ADD mongo-init-opendc-db.sh /docker-entrypoint-initdb.d -ADD mongo-opendc-schema.sh /docker-entrypoint-initdb.d
\ No newline at end of file +ADD mongo-init-opendc-db.sh /docker-entrypoint-initdb.d
\ No newline at end of file diff --git a/mongodb/mongo-init-opendc-db.sh b/mongodb/mongo-init-opendc-db.sh index 55e9ec68..ed33e955 100644 --- a/mongodb/mongo-init-opendc-db.sh +++ b/mongodb/mongo-init-opendc-db.sh @@ -2,11 +2,53 @@ echo 'Creating opendc user and db' -mongo opendc \ - --host localhost \ +mongo opendc --host localhost \ --port 27017 \ -u $MONGO_INITDB_ROOT_USERNAME \ -p $MONGO_INITDB_ROOT_PASSWORD \ --authenticationDatabase admin \ - --eval "db.createUser({user: 'opendc', pwd: 'opendcpassword', roles:[{role:'dbOwner', db: 'opendc'}]});" -$MONGO_CMD = "mongo opendc --host localhost --port 27017 -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin"
\ No newline at end of file + --eval "db.createUser({user: '$OPENDC_DB_USERNAME', pwd: '$OPENDC_DB_PASSWORD', roles:[{role:'dbOwner', db: '$OPENDC_DB'}]});" +MONGO_ROOT_CMD="mongo $OPENDC_DB --host localhost --port 27017 -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin" + +#echo 'Creating opendc db schema...' +MONGO_CMD="mongo $OPENDC_DB -u $OPENDC_DB_USERNAME -p $OPENDC_DB_PASSWORD --authenticationDatabase $OPENDC_DB" +$MONGO_CMD --eval 'db.createCollection("environments", { + validator: { + $jsonSchema: { + bsonType: "object", + required: ["name"], + properties: { + name: { + bsonType: "string", + description: "The name of the environment i.e. Production, or Compute Cluster" + }, + datacenters: { + bsonType: "object", + required: ["name, location, length, width, height"], + properties: { + name: { + bsonType: "string", + description: "The name of the datacenter i.e. eu-west-1, or Science Building" + }, + location: { + bsonType: "string", + description: "The location of the datacenter i.e. Frankfurt, or De Boelelaan 1105" + }, + length: { + bsonType: "double", + description: "The physical length of the datacenter, in centimetres" + }, + width: { + bsonType: "double", + description: "The physical width of the datacenter, in centimetres" + }, + height: { + bsonType: "double", + description: "The physical height of the datacenter, in centimetres" + } + } + } + } + } + } +});'
\ No newline at end of file diff --git a/mongodb/mongo-opendc-schema.sh b/mongodb/mongo-opendc-schema.sh deleted file mode 100644 index 7fd9d10f..00000000 --- a/mongodb/mongo-opendc-schema.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -echo 'Creating opendc db schema...' - -$MONGO_CMD = "mongo opendc --host localhost --port 27017 -u $OPENDC_DB_USERNAME -p $OPENDC_DB_PASSWORD --authenticationDatabase opendc" - -eval $MONGO_COMMAND --eval "db.createCollection('environments'); db.createCollection('rooms'); db.createCollection('datacenters');"
\ No newline at end of file |
