From cb4c03949e95ce749f135dc8ae02d54b4c8498fb Mon Sep 17 00:00:00 2001 From: "SG\\jerry.sun" Date: Wed, 21 Feb 2018 17:04:03 +0800 Subject: [PATCH 01/30] update docker file --- .gitignore | 2 ++ Dockerfile | 9 +++++++++ README.md | 5 +++++ src/service/start_services.sh | 2 ++ 4 files changed, 18 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae945fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +venv/ diff --git a/Dockerfile b/Dockerfile index 77837fc..b87e1be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,22 @@ FROM ubuntu:latest RUN apt-get update RUN apt-get install -y python-pip RUN apt-get install -y apache2 +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install libmysqlclient-dev RUN pip install -U pip RUN pip install -U flask RUN pip install -U flask-cors +RUN pip install flask-sqlalchemy +RUN pip install mysqlclient RUN echo "ServerName localhost " >> /etc/apache2/apache2.conf RUN echo "$user hard nproc 20" >> /etc/security/limits.conf + +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server +RUN mkdir /var/run/mysqld + ADD ./src/service /service ADD ./src/html /var/www/html EXPOSE 80 EXPOSE 8080 +EXPOSE 3306 +CMD ["mysqld"] CMD ["/bin/bash", "/service/start_services.sh"] diff --git a/README.md b/README.md index 9a814e3..015fc26 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +Please check out develop branch +``` +git checkout -b develop origin/develop +``` + # rest-api-development CS5331 Assignment 1 Project Reference Repository diff --git a/src/service/start_services.sh b/src/service/start_services.sh index a970fe8..7a0c1be 100644 --- a/src/service/start_services.sh +++ b/src/service/start_services.sh @@ -1,4 +1,6 @@ #!/bin/bash +chown -R mysql:mysql /var/lib/mysql /var/run/mysqld +service mysql start apachectl start python /service/app.py From 46b8d46ff91c5b03687105a33e2efb4f4a4cbe2a Mon Sep 17 00:00:00 2001 From: SunZelun Date: Wed, 21 Feb 2018 11:43:17 +0000 Subject: [PATCH 02/30] enable debug mode --- src/service/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/app.py b/src/service/app.py index ade6772..7ae2cb9 100644 --- a/src/service/app.py +++ b/src/service/app.py @@ -10,7 +10,7 @@ CORS(app) # Remember to update this list -ENDPOINT_LIST = ['/', '/meta/heartbeat', '/meta/members'] +ENDPOINT_LIST = ['/', '/meta/heartbeat', '/meta/members', '/meta/all'] def make_json_response(data, status=True, code=200): """Utility function to create the JSON responses.""" @@ -58,4 +58,4 @@ def meta_members(): os.chdir(dname) # Run the application - app.run(debug=False, port=8080, host="0.0.0.0") + app.run(debug=True, port=8080, host="0.0.0.0") From 097a09ccebfebc9d503eb4d820800d51ad3e7eaf Mon Sep 17 00:00:00 2001 From: "SG\\jerry.sun" Date: Fri, 23 Feb 2018 17:33:57 +0800 Subject: [PATCH 03/30] add user module --- Dockerfile | 14 +-- README.md | 6 ++ run.sh | 3 +- src/html/index.html | 2 +- src/service/app.py | 164 +++++++++++++++++++++++++++++++++- src/service/app.pyc | Bin 0 -> 6621 bytes src/service/config.py | 7 ++ src/service/diary.sqlite | Bin 0 -> 5120 bytes src/service/start_services.sh | 2 - src/service/team_members.txt | 7 +- 10 files changed, 188 insertions(+), 17 deletions(-) create mode 100644 src/service/app.pyc create mode 100644 src/service/config.py create mode 100644 src/service/diary.sqlite diff --git a/Dockerfile b/Dockerfile index b87e1be..69bbf3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,22 +2,22 @@ FROM ubuntu:latest RUN apt-get update RUN apt-get install -y python-pip RUN apt-get install -y apache2 -RUN DEBIAN_FRONTEND=noninteractive apt-get -y install libmysqlclient-dev +RUN apt-get install -y vim +RUN apt-get install -y build-essential libffi-dev RUN pip install -U pip RUN pip install -U flask RUN pip install -U flask-cors RUN pip install flask-sqlalchemy -RUN pip install mysqlclient +RUN pip install flask_marshmallow +RUN pip install bcrypt +RUN pip install marshmallow-sqlalchemy + RUN echo "ServerName localhost " >> /etc/apache2/apache2.conf RUN echo "$user hard nproc 20" >> /etc/security/limits.conf -RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server -RUN mkdir /var/run/mysqld - ADD ./src/service /service ADD ./src/html /var/www/html EXPOSE 80 EXPOSE 8080 -EXPOSE 3306 -CMD ["mysqld"] + CMD ["/bin/bash", "/service/start_services.sh"] diff --git a/README.md b/README.md index 015fc26..ea6e7f0 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,12 @@ Please check out develop branch git checkout -b develop origin/develop ``` +Init database +``` +from app import db +db.create_all() +``` + # rest-api-development CS5331 Assignment 1 Project Reference Repository diff --git a/run.sh b/run.sh index 97e50da..4b10ad0 100755 --- a/run.sh +++ b/run.sh @@ -9,4 +9,5 @@ TEAMID=`md5sum README.md | cut -d' ' -f 1` docker kill $(docker ps -q) docker rm $(docker ps -a -q) docker build . -t $TEAMID -docker run -p 80:80 -p 8080:8080 -t $TEAMID +#docker run -p 3306:3306 -p 80:80 -p 8080:8080 -v /home/vagrant/public/public/rest-api-development/src/html:/var/www/html -v /home/vagrant/public/public/rest-api-development/src/service:/service -t $TEAMID +docker run -p 80:80 -p 8080:8080 -v /home/vagrant/public/public/rest-api-development/src/html:/var/www/html -v /home/vagrant/public/public/rest-api-development/src/service:/service -t $TEAMID diff --git a/src/html/index.html b/src/html/index.html index 2a847c7..303b751 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -2,7 +2,7 @@ -

Secret Diary Front End

+

Secret Diary Front End Update

Requirements for the front end are as follows: