From dbd94e071ac6a7adca60943d0abd79cf47be5f44 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Wed, 11 Mar 2015 23:32:08 -0400 Subject: [PATCH] moved django inside new directoy for docker organization. --- Dockerfile | 18 +++++++++--------- manage.py => roadmap/manage.py | 0 {project => roadmap/project}/__init__.py | 0 {project => roadmap/project}/admin.py | 0 {project => roadmap/project}/api/__init__.py | 0 .../project}/api/serializers.py | 0 {project => roadmap/project}/api/viewsets.py | 0 {project => roadmap/project}/helpers.py | 0 {project => roadmap/project}/models.py | 0 {project => roadmap/project}/tests.py | 0 {project => roadmap/project}/views.py | 0 requirements.txt => roadmap/requirements.txt | 0 roadmap/{ => roadmap}/__init__.py | 0 roadmap/{ => roadmap}/drf_settings.py | 0 roadmap/{ => roadmap}/settings.py | 0 roadmap/{ => roadmap}/urls.py | 0 roadmap/{ => roadmap}/user_api_views.py | 0 roadmap/{ => roadmap}/wsgi.py | 0 startup.sh | 16 ++++++++++++++++ 19 files changed, 25 insertions(+), 9 deletions(-) rename manage.py => roadmap/manage.py (100%) rename {project => roadmap/project}/__init__.py (100%) rename {project => roadmap/project}/admin.py (100%) rename {project => roadmap/project}/api/__init__.py (100%) rename {project => roadmap/project}/api/serializers.py (100%) rename {project => roadmap/project}/api/viewsets.py (100%) rename {project => roadmap/project}/helpers.py (100%) rename {project => roadmap/project}/models.py (100%) rename {project => roadmap/project}/tests.py (100%) rename {project => roadmap/project}/views.py (100%) rename requirements.txt => roadmap/requirements.txt (100%) rename roadmap/{ => roadmap}/__init__.py (100%) rename roadmap/{ => roadmap}/drf_settings.py (100%) rename roadmap/{ => roadmap}/settings.py (100%) rename roadmap/{ => roadmap}/urls.py (100%) rename roadmap/{ => roadmap}/user_api_views.py (100%) rename roadmap/{ => roadmap}/wsgi.py (100%) create mode 100755 startup.sh diff --git a/Dockerfile b/Dockerfile index 85a9c6d..2a26cad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,22 +20,22 @@ RUN apt-get -y install mysql-server # Add and install Python modules -ADD requirements.txt /roadmap/requirements.txt +ADD roadmap/requirements.txt /roadmap/requirements.txt RUN cd /roadmap; pip install -r requirements.txt # Bundle app source -ADD . /roadmap +ADD roadmap /roadmap +ADD startup.sh /opt/startup.sh + + +# Change Mysql BindAddress +RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf +RUN /bin/bash /opt/startup.sh +RUN cd /roadmap; python manage.py migrate # Expose EXPOSE 8000 EXPOSE 3306 -# Run -CMD ["/usr/bin/mysqld_safe"] -CMD ["python", "/roadmap/manage.py", "test"] - - - - # http://txt.fliglio.com/2013/11/creating-a-mysql-docker-container/ # http://blogs.aws.amazon.com/application-management/post/Tx1ZLAHMVBEDCOC/Dockerizing-a-Python-Web-App diff --git a/manage.py b/roadmap/manage.py similarity index 100% rename from manage.py rename to roadmap/manage.py diff --git a/project/__init__.py b/roadmap/project/__init__.py similarity index 100% rename from project/__init__.py rename to roadmap/project/__init__.py diff --git a/project/admin.py b/roadmap/project/admin.py similarity index 100% rename from project/admin.py rename to roadmap/project/admin.py diff --git a/project/api/__init__.py b/roadmap/project/api/__init__.py similarity index 100% rename from project/api/__init__.py rename to roadmap/project/api/__init__.py diff --git a/project/api/serializers.py b/roadmap/project/api/serializers.py similarity index 100% rename from project/api/serializers.py rename to roadmap/project/api/serializers.py diff --git a/project/api/viewsets.py b/roadmap/project/api/viewsets.py similarity index 100% rename from project/api/viewsets.py rename to roadmap/project/api/viewsets.py diff --git a/project/helpers.py b/roadmap/project/helpers.py similarity index 100% rename from project/helpers.py rename to roadmap/project/helpers.py diff --git a/project/models.py b/roadmap/project/models.py similarity index 100% rename from project/models.py rename to roadmap/project/models.py diff --git a/project/tests.py b/roadmap/project/tests.py similarity index 100% rename from project/tests.py rename to roadmap/project/tests.py diff --git a/project/views.py b/roadmap/project/views.py similarity index 100% rename from project/views.py rename to roadmap/project/views.py diff --git a/requirements.txt b/roadmap/requirements.txt similarity index 100% rename from requirements.txt rename to roadmap/requirements.txt diff --git a/roadmap/__init__.py b/roadmap/roadmap/__init__.py similarity index 100% rename from roadmap/__init__.py rename to roadmap/roadmap/__init__.py diff --git a/roadmap/drf_settings.py b/roadmap/roadmap/drf_settings.py similarity index 100% rename from roadmap/drf_settings.py rename to roadmap/roadmap/drf_settings.py diff --git a/roadmap/settings.py b/roadmap/roadmap/settings.py similarity index 100% rename from roadmap/settings.py rename to roadmap/roadmap/settings.py diff --git a/roadmap/urls.py b/roadmap/roadmap/urls.py similarity index 100% rename from roadmap/urls.py rename to roadmap/roadmap/urls.py diff --git a/roadmap/user_api_views.py b/roadmap/roadmap/user_api_views.py similarity index 100% rename from roadmap/user_api_views.py rename to roadmap/roadmap/user_api_views.py diff --git a/roadmap/wsgi.py b/roadmap/roadmap/wsgi.py similarity index 100% rename from roadmap/wsgi.py rename to roadmap/roadmap/wsgi.py diff --git a/startup.sh b/startup.sh new file mode 100755 index 0000000..7b05021 --- /dev/null +++ b/startup.sh @@ -0,0 +1,16 @@ +#/bin/bash + +if [ ! -f /var/lib/mysql/roadmap ]; then + mysql_install_db + + /usr/bin/mysqld_safe & + sleep 10s + + echo "GRANT ALL ON *.* TO django@'%' IDENTIFIED BY 'django' WITH GRANT OPTION; FLUSH PRIVILEGES" | mysql + echo "CREATE DATABASE roadmap" | mysql + + killall mysqld + sleep 10s +fi + +/usr/bin/mysqld_safe &