diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..71cb11d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:latest + + +# RUN apt-get update && apt-get install -y nginx python3 python3-pip python python-pip supervisor + +# COPY poc.conf /etc/nginx/sites-available/poc.conf +# RUN rm /etc/nginx/sites-enabled/default && ln -s /etc/nginx/sites-available/poc.conf /etc/nginx/sites-enabled/ && sleep 2 && service nginx start + +COPY pocwww /root/www/pocwww +COPY setup.py /root/www/setup.py +COPY README.txt /root/www/README.txt +COPY CHANGES.txt /root/www/CHANGES.txt +COPY MANIFEST.in /root/www/MANIFEST.in +COPY generate_cert.sh /root/www/generate_cert.sh +RUN chmod +x /root/www/generate_cert.sh +RUN /root/www/generate_cert.sh + +RUN pip3 install /root/www/ + +COPY production.ini /root/www/production.ini +COPY development.ini /root/www/development.ini + +RUN apt-get clean +RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +EXPOSE 6543 + +CMD ["pserve", "/root/www/production.ini", "http_port=6543"] diff --git a/development.ini b/development.ini index 8c67182..c487804 100644 --- a/development.ini +++ b/development.ini @@ -18,8 +18,7 @@ pyramid.includes = # '127.0.0.1' and '::1'. # debugtoolbar.hosts = 127.0.0.1 ::1 -mongo_uri = mongodb://poc_www:HenryPump1903@localhost:27017/poc -# mongo_uri = mongodb://10.20.155.202:27017/poc +mongo_uri = mongodb://poc_www:HenryPump1903@172.17.0.2:27017/poc ### diff --git a/mongo.Dockerfile b/mongo.Dockerfile deleted file mode 100644 index 796541d..0000000 --- a/mongo.Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -FROM ubuntu:latest - -# Install MongoDB - -RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 -RUN echo "deb http://repo.mongodb.org/apt/ubuntu $(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list -RUN apt-get update && apt-get install -y mongodb-org - -RUN mkdir -p /data/db -COPY setup_mongo_admin.js /tmp/setup_mongo_admin.js -RUN mongod --fork --logpath=/var/log/mongodb.log && sleep 5 && mongo < /tmp/setup_mongo_admin.js -# COPY mongod.conf /etc/mongod.conf -EXPOSE 27107 - -CMD ["/usr/bin/mongod"] - -# nginx python3 python3-pip python python-pip supervisor -# RUN service mongod restart -# COPY setup_mongo_users.js /tmp/setup_mongo_users.js -# RUN mongo -u "admin" -p "HenryPump@1903" --authenticationDatabase admin < /tmp/setup_mongo_users.js && service mongod restart -# -# COPY poc.conf /etc/nginx/sites-available/poc.conf -# RUN rm /etc/nginx/sites-endabled/default && ln -s /etc/nginx/sites-available/poc.conf /etc/nginx/sites-endabled/ && service nginx restart -# -# COPY pocwww /root/www/pocwww -# COPY production.ini /root/www/production.ini -# COPY setup.py /root/www/setup.py -# COPY README.txt /root/www/README.txt -# COPY CHANGES.txt /root/www/CHANGES.txt -# COPY generate_cert.sh /root/www/generate_cert.sh -# RUN chmod +x /root/www/generate_cert.sh -# RUN /root/www/generate_cert.sh -# -# RUN pip3 install /root/www/ -# RUN pserve /root/www/development.ini http_port=6543 -# -# -# -# RUN apt-get clean -# RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# -# EXPOSE 27017 -# -# CMD ["pserve", "/root/www/development.ini", "http_port=6543"] diff --git a/mongod.conf b/mongod.conf deleted file mode 100644 index 0b87cf3..0000000 --- a/mongod.conf +++ /dev/null @@ -1,42 +0,0 @@ -# mongod.conf - -# for documentation of all options, see: -# http://docs.mongodb.org/manual/reference/configuration-options/ - -# Where and how to store data. -storage: - dbPath: /var/lib/mongodb - journal: - enabled: true -# engine: -# mmapv1: -# wiredTiger: - -# where to write logging data. -systemLog: - destination: file - logAppend: true - path: /var/log/mongodb/mongod.log - -# network interfaces -net: - port: 27017 - bindIp: 127.0.0.1 - - -#processManagement: - -security: - authorization: enabled - -#operationProfiling: - -#replication: - -#sharding: - -## Enterprise-Only Options: - -#auditLog: - -#snmp: diff --git a/pocwww/__init__.py b/pocwww/__init__.py index b64b882..6bd82a6 100644 --- a/pocwww/__init__.py +++ b/pocwww/__init__.py @@ -179,7 +179,6 @@ def main(global_config, **settings): config.add_route('users_register', '/register', factory='pocwww.security.UserLoginFactory') config.add_route("users_json", "/json/users", factory='pocwww.security.UserLoginFactory') - # POC Interface config.add_route("poc_updateconfig_json", "/json/updateconfig", factory='pocwww.security.UserLoginFactory') config.add_route("poc_shake_json", '/json/cmd/shake', factory='pocwww.security.UserLoginFactory') # Shake command is separate for allowing all access @@ -189,8 +188,5 @@ def main(global_config, **settings): config.add_route('poc_mode_json', '/json/mode', factory='pocwww.security.UserLoginFactory') config.add_route('poc_setpoints', '/setpoints', factory='pocwww.security.UserLoginFactory') - - - config.scan() return config.make_wsgi_app() diff --git a/production.ini b/production.ini index 5a3e70f..b7aad12 100644 --- a/production.ini +++ b/production.ini @@ -10,7 +10,7 @@ pyramid.debug_authorization = false pyramid.debug_notfound = false pyramid.debug_routematch = false pyramid.default_locale_name = en -mongo_uri = mongodb://poc_www:HenryPump1903@localhost:27017/poc +mongo_uri = mongodb://poc_www:HenryPump1903@10.10.10.10:27017/poc #---------- Pipeline Configuration ---------- @@ -28,7 +28,7 @@ pipeline = [server:main] use = egg:waitress#main -host = 127.0.0.1 +host = 0.0.0.0 port = %(http_port)s diff --git a/setup_mongo_admin.js b/setup_mongo_admin.js index ebf0140..756f097 100644 --- a/setup_mongo_admin.js +++ b/setup_mongo_admin.js @@ -13,8 +13,21 @@ poc.createUser({ roles: [ { role: "readWrite", db: "poc" } ] }); +poc = db.getSiblingDB('poc'); poc.createUser({ user: "poc_java", pwd: "HenryPump@1903", roles: [ { role: "readWrite", db: "poc" } ] }); + +// db.createUser({ +// user: "poc_www", +// pwd: "HenryPump1903", +// roles: [ { role: "readWrite", db: "poc" } ] +// }); +// +// db.createUser({ +// user: "poc_java", +// pwd: "HenryPump@1903", +// roles: [ { role: "readWrite", db: "poc" } ] +// });