diff options
| author | jc0b <j.burley@vu.nl> | 2020-06-09 14:19:54 +0200 |
|---|---|---|
| committer | jc0b <j.burley@vu.nl> | 2020-06-09 14:19:54 +0200 |
| commit | 3ad2c696003294d8f49fac14d2dc56e81426c3c3 (patch) | |
| tree | 162b3a61fc17964eec4666d9dbcf73a97d820f7e | |
| parent | 3e4233c0d8b8d76b0f407341560ed84de38323ec (diff) | |
progress so far (for remote)
| -rw-r--r-- | Dockerfile | 14 | ||||
| -rwxr-xr-x | build/configure.sh | 20 | ||||
| -rw-r--r-- | docker-compose.yml | 15 | ||||
| -rw-r--r-- | mongodb/mongo-init-opendc-db.sh | 65 |
4 files changed, 54 insertions, 60 deletions
@@ -1,12 +1,18 @@ FROM node:14.2.0 MAINTAINER Sacheendra Talluri <sacheendra.t@gmail.com> +# Adding the mongodb repo and installing the client +RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - \ + && echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list \ + && apt-get update \ + && apt-get install -y mongodb-org + # Installing python and web-server dependencies RUN echo "deb http://ftp.debian.org/debian stretch main" >> /etc/apt/sources.list \ && apt-get update \ - && apt-get install -y python python-pip yarn git sed mysql-client \ - && pip install oauth2client eventlet flask-socketio flask-compress mysql-connector-python-rf \ - && pip install --upgrade pyasn1-modules \ + && apt-get install -y python3 python3-pip yarn git sed mysql-client pymongo \ + && pip3 install oauth2client eventlet flask-socketio flask-compress mysql-connector-python-rf \ + && pip3 install --upgrade pyasn1-modules \ && rm -rf /var/lib/apt/lists/* # Copy OpenDC directory @@ -24,4 +30,4 @@ RUN chmod 555 /opendc/build/configure.sh \ # Set working directory WORKDIR /opendc -CMD ["sh", "-c", "./build/configure.sh && python2.7 opendc-web-server/main.py keys.json"] +CMD ["sh", "-c", "./build/configure.sh && python3 opendc-web-server/main.py keys.json"] diff --git a/build/configure.sh b/build/configure.sh index eb7324d2..fcb33b1a 100755 --- a/build/configure.sh +++ b/build/configure.sh @@ -22,20 +22,20 @@ done echo "MariaDB available" -NUM_TABLES=$(eval "$MYSQL_COMMAND -B --disable-column-names -e \"SELECT count(*) FROM information_schema.tables WHERE table_schema='$MYSQL_DATABASE';\"") +#NUM_TABLES=$(eval "$MYSQL_COMMAND -B --disable-column-names -e \"SELECT count(*) FROM information_schema.tables WHERE table_schema='$MYSQL_DATABASE';\"") # Check if database is empty -if [ "$NUM_TABLES" -eq 0 ]; then - eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/schema.sql - eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/test.sql -fi +#if [ "$NUM_TABLES" -eq 0 ]; then +# eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/schema.sql +# eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/test.sql +#fi # Writing databse config values to keys.json cat keys.json | python -c "import os, sys, json; ks = json.load(sys.stdin); \ - ks['MYSQL_HOST'] = 'mariadb'; \ - ks['MYSQL_PORT'] = '3306'; \ - ks['MYSQL_DATABASE'] = os.environ['MYSQL_DATABASE']; \ - ks['MYSQL_USER'] = os.environ['MYSQL_USER']; \ - ks['MYSQL_PASSWORD'] = os.environ['MYSQL_PASSWORD']; \ + ks['MONGODB_HOST'] = 'mongo'; \ + ks['MONGODB_PORT'] = '27017'; \ + ks['MONGODB_DATABASE'] = os.environ['MONGO_DB']; \ + ks['MYSQL_USER'] = os.environ['MONGO_DB_USER']; \ + ks['MYSQL_PASSWORD'] = os.environ['MONGO_DB_PASSWORD']; \ print json.dumps(ks, indent=4)" > new_keys.json mv new_keys.json keys.json diff --git a/docker-compose.yml b/docker-compose.yml index 4331a5a8..52c43ee7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,9 @@ services: - MYSQL_DATABASE=opendc - MYSQL_USER=opendc - MYSQL_PASSWORD=opendcpassword + - MONGO_DB=opendc + - MONGO_DB_USERNAME=opendc + - MONGO_DB_PASSWORD=opendcpassword simulator: build: context: ./opendc-simulator @@ -48,12 +51,12 @@ services: context: ./mongodb restart: on-failure environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: rootpassword - MONGO_INITDB_DATABASE: admin - OPENDC_DB: opendc - OPENDC_DB_USERNAME: opendc - OPENDC_DB_PASSWORD: opendcpassword + - MONGO_INITDB_ROOT_USERNAME=root + - MONGO_INITDB_ROOT_PASSWORD=rootpassword + - MONGO_INITDB_DATABASE=admin + - OPENDC_DB=opendc + - OPENDC_DB_USERNAME=opendc + - OPENDC_DB_PASSWORD=opendcpassword ports: - 27017:27017 #volumes: diff --git a/mongodb/mongo-init-opendc-db.sh b/mongodb/mongo-init-opendc-db.sh index 965698e7..38a8d85d 100644 --- a/mongodb/mongo-init-opendc-db.sh +++ b/mongodb/mongo-init-opendc-db.sh @@ -105,43 +105,28 @@ $MONGO_CMD --eval 'db.prefabs.insertOne( ] });' -# $MONGO_CMD --eval 'db.createCollection("prefabs", { -# 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 +$MONGO_CMD --eval 'db.createCollection("topologies");' + +$MONGO_CMD --eval 'db.createCollection("users");' + +$MONGO_CMD --eval 'db.users.insertOne( + { + "google_id": "23483578932789231", + "email": "jorgos.andreadis@gmail.com", + "given_name": "Jorgos", + "family_name": "Andreadis", + "authorizations": [ + { + "simulation_id": 1, + "authorization_level": "OWN" + }, + { + "simulation_id": 2, + "authorization_level": "READ" + }, + { + "simulation_id": 3, + "authorization_level": "READWRITE" + } + ] + });'
\ No newline at end of file |
