diff --git a/Dockerfile b/Dockerfile index 1792859d..2e4965fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,34 @@ FROM python:2.7.13 -ENV http_proxy http://gatekeeper.mitre.org:80/ -ENV https_proxy http://gatekeeper.mitre.org:80/ +# set appropriately if needed for your environment +ARG http_proxy +ARG https_proxy +ENV http_proxy $http_proxy +ENV https_proxy $https_proxy RUN apt-get update && apt-get -y upgrade RUN apt-get -y install python-gdbm python-tk -RUN apt-get -y install binutils libproj-dev gdal-bin nodejs nodejs-dev npm postgresql-client-common postgresql-client +RUN apt-get -y install binutils libproj-dev gdal-bin nodejs nodejs-dev npm postgresql-client-common postgresql-client netcat +RUN apt-get -y install nginx RUN npm install -g less RUN ln -s /usr/bin/nodejs /usr/bin/node ADD . /usr/src/geoq WORKDIR /usr/src/geoq -RUN pip install -r geoq/requirements.txt --proxy=http://gatekeeper.mitre.org:80/ +RUN pip install -r geoq/requirements.txt --proxy=$http_proxy -EXPOSE 8000 +RUN dpkg -i ./geoq/tools/geographiclib_1.36-2_amd64.deb +RUN apt-get install -f + +EXPOSE 80 COPY ./docker-entrypoint.sh / +COPY ./django_nginx.conf /etc/nginx/sites-available/django_nginx.conf +RUN ln -s /etc/nginx/sites-available/django_nginx.conf /etc/nginx/sites-enabled +RUN echo "daemon off;" >> /etc/nginx/nginx.conf + +ENV http_proxy "" +ENV https_proxy "" ENTRYPOINT ["/docker-entrypoint.sh"] \ No newline at end of file diff --git a/django_nginx.conf b/django_nginx.conf new file mode 100644 index 00000000..90569c53 --- /dev/null +++ b/django_nginx.conf @@ -0,0 +1,14 @@ +server { + listen 80; + server_name ~^(.+)$; + + location = /favicon.ico { access_log off; log_not_found off; } + location /static/ { + root /var/www; + } + + location / { + include proxy_params; + proxy_pass http://unix:/usr/src/geoq/django_app.sock; + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1acda326..22a7878e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: volumes: - /usr/local/src/geoq/geoq:/usr/src/geoq ports: - - "8000:8000" + - "8000:80" command: sh -c 'python app.py' depends_on: - db \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index e88e2e8a..c1bc80b6 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,5 +6,25 @@ export DJANGO_SETTINGS_MODULE=geoq.settings export PATH=$PATH:/usr/lib/postgresql/9.4/bin +python manage.py migrate +python manage.py collectstatic --noinput +paver install_dev_fixtures -python manage.py runserver 0.0.0.0:8000 \ No newline at end of file +# Prepare log files +touch /var/log/gunicorn.log +touch /var/log/access.log +tail -n 0 -f /var/log/gunicorn.log /var/log/access.log & + + +# Start Gunicorn +echo Starting Gunicorn +exec gunicorn geoq.wsgi:application \ + --name geoq \ + --bind unix:django_app.sock \ + --workers 3 \ + --log-level=info \ + --log-file=/var/log/gunicorn.log \ + --access-logfile=/var/log/access.log & + +echo Starting nginx +exec service nginx start \ No newline at end of file diff --git a/docker-production.yml b/docker-production.yml index 88ce5b83..7650ebc7 100644 --- a/docker-production.yml +++ b/docker-production.yml @@ -9,9 +9,8 @@ services: POSTGRES_DB: geoq web: - image: stephenrjones/geoq-django10 + image: stephenrjones/geoq-django10:production ports: - - "80:80" - command: sh -c './wait-for db:5432 -- python app.py' + - "8000:80" depends_on: - db \ No newline at end of file diff --git a/geoq/core/kml_view.py b/geoq/core/kml_view.py index 18a81e22..936041ce 100644 --- a/geoq/core/kml_view.py +++ b/geoq/core/kml_view.py @@ -212,7 +212,7 @@ def get(self, request, *args, **kwargs): output += ' \n' output += '' - return HttpResponse(output, mimetype="application/vnd.google-earth.kml+xml", status=200) + return HttpResponse(output, content_type="application/vnd.google-earth.kml+xml", status=200) def get_cookie_trailer(request): @@ -283,5 +283,5 @@ def get(self, request, *args, **kwargs): output += ' \n' output += '' - return HttpResponse(output, mimetype="application/vnd.google-earth.kml+xml", status=200) + return HttpResponse(output, content_type="application/vnd.google-earth.kml+xml", status=200) diff --git a/geoq/core/static/core/js/create-aois.js b/geoq/core/static/core/js/create-aois.js index c348c3ef..aebb1929 100644 --- a/geoq/core/static/core/js/create-aois.js +++ b/geoq/core/static/core/js/create-aois.js @@ -638,23 +638,23 @@ create_aois.mapWasZoomed = function (e) { var $mgrs = $("#option_mgrs"); var $poly = $("#option_polygon"); - var isCONUS = true; - if (typeof maptools != "undefined") { - var ll = e.target.getCenter(); - var pt = maptools.locationInfoString({lat: ll.lat, lng: ll.lng, separator: "
", boldTitles: true}); - - isCONUS = (pt.country && pt.state && pt.country.abbr == "USA" && pt.state.name != "Hawaii" && pt.state.name != "Alaska"); - } +// var isCONUS = true; +// if (typeof maptools != "undefined") { +// var ll = e.target.getCenter(); +// var pt = maptools.locationInfoString({lat: ll.lat, lng: ll.lng, separator: "
", boldTitles: true}); +// +// isCONUS = (pt.country && pt.state && pt.country.abbr == "USA" && pt.state.name != "Hawaii" && pt.state.name != "Alaska"); +// } if (zoom > 8) { //Hide USNG Menu if it's outside CONUS - $usng.attr('disabled', !isCONUS).text('USNG Cells (US only)'); +// $usng.attr('disabled', !isCONUS).text('USNG Cells (US only)'); $mgrs.attr('disabled', false).text('MGRS Cells'); } else { if ($usng.hasClass("active") || $mgrs.hasClass("active")) { $poly.click(); } - $usng.attr('disabled', true).text('Zoom in to use USNG/MGRS'); +// $usng.attr('disabled', true).text('Zoom in to use USNG/MGRS'); $mgrs.attr('disabled', true).text('>'); } }; diff --git a/geoq/core/templates/core/job_batch_create_aois.html b/geoq/core/templates/core/job_batch_create_aois.html index 5e1e5e47..3b089e7e 100644 --- a/geoq/core/templates/core/job_batch_create_aois.html +++ b/geoq/core/templates/core/job_batch_create_aois.html @@ -203,6 +203,7 @@ $('div.leaflet-right div.leaflet-draw.leaflet-control').find('a').popover({trigger: "hover", placement: "left"}); create_aois.map_updates(); + create_aois.mapWasZoomed(); } function highlightFeature(e) { @@ -277,13 +278,13 @@

Add workcells to Job #{{ object.id }} ({{ object.name }})

Name workcells:
-
- Draw using: - - - - +
+ + + +
+ Draw using: