diff --git a/Dockerfile b/Dockerfile index 354deac27ae..b7e7136ccec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,5 @@ EXPOSE 8000 # CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] # CMD ["paver", "start_django", "-b", "0.0.0.0:8000"] -CMD ["uwsgi", "--ini", "uwsgi.ini"] +# CMD ["uwsgi", "--ini", "uwsgi.ini"] +ENTRYPOINT ["/usr/src/app/entrypoint.sh"] diff --git a/docker-compose.override.localhost.yml b/docker-compose.override.localhost.yml index c67ce3a700f..57b597979e6 100644 --- a/docker-compose.override.localhost.yml +++ b/docker-compose.override.localhost.yml @@ -16,15 +16,17 @@ services: - ALLOWED_HOSTS=['localhost', ] - GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ - # celery: - # build: . - # # Loading the app is defined here to allow for - # # autoreload on changes it is mounted on top of the - # # old copy that docker added when creating the image - # volumes: - # - '.:/usr/src/app' - # environment: - # - DEBUG=True + celery: + build: . + volumes: + - '.:/usr/src/app' + environment: + - DEBUG=False + - GEONODE_LB_HOST_IP=localhost + - GEONODE_LB_PORT=80 + - SITEURL=http://localhost/ + - ALLOWED_HOSTS=['localhost', ] + - GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ geoserver: environment: diff --git a/docker-compose.override.yml b/docker-compose.override.yml index c67ce3a700f..57b597979e6 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -16,15 +16,17 @@ services: - ALLOWED_HOSTS=['localhost', ] - GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ - # celery: - # build: . - # # Loading the app is defined here to allow for - # # autoreload on changes it is mounted on top of the - # # old copy that docker added when creating the image - # volumes: - # - '.:/usr/src/app' - # environment: - # - DEBUG=True + celery: + build: . + volumes: + - '.:/usr/src/app' + environment: + - DEBUG=False + - GEONODE_LB_HOST_IP=localhost + - GEONODE_LB_PORT=80 + - SITEURL=http://localhost/ + - ALLOWED_HOSTS=['localhost', ] + - GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ geoserver: environment: diff --git a/docker-compose.yml b/docker-compose.yml index bc8f63e38b2..55de964d250 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,15 +16,15 @@ services: env_file: - ./scripts/docker/env/production/db.env - # elasticsearch: - # image: elasticsearch:2.4.1 - # restart: unless-stopped - # container_name: elasticsearch4${COMPOSE_PROJECT_NAME} - # stdin_open: true - # # tty: true - # labels: - # org.geonode.component: elasticsearch - # org.geonode.instance.name: geonode + elasticsearch: + image: elasticsearch:2.4.1 + restart: unless-stopped + container_name: elasticsearch4${COMPOSE_PROJECT_NAME} + stdin_open: true + # tty: true + labels: + org.geonode.component: elasticsearch + org.geonode.instance.name: geonode rabbitmq: image: rabbitmq @@ -47,25 +47,16 @@ services: org.geonode.instance.name: geonode depends_on: - db - # - elasticsearch + - elasticsearch - rabbitmq - command: celery worker --app=geonode.celery_app:app -B -l INFO + # command: celery worker --app=geonode.celery_app:app -B -l INFO volumes: - /var/run/docker.sock:/var/run/docker.sock + - statics:/mnt/volumes/statics + - geoserver-data-dir:/geoserver_data/data env_file: - ./scripts/docker/env/production/celery.env - data-dir-conf: - image: geonode/geoserver_data:2.13.x - restart: on-failure - container_name: gsconf4${COMPOSE_PROJECT_NAME} - labels: - org.geonode.component: conf - org.geonode.instance.name: geonode - command: /bin/true - volumes: - - geoserver-data-dir:/geoserver_data/data - geoserver: image: geonode/geoserver:2.13.x restart: unless-stopped @@ -77,7 +68,7 @@ services: org.geonode.instance.name: geonode depends_on: - db - # - elasticsearch + - elasticsearch - rabbitmq - data-dir-conf volumes: @@ -97,12 +88,14 @@ services: org.geonode.instance.name: geonode depends_on: - db - # - elasticsearch + - elasticsearch - rabbitmq + - data-dir-conf # command: paver start_django -b 0.0.0.0:8000 - command: uwsgi --ini uwsgi.ini + # command: uwsgi --ini uwsgi.ini volumes: - /var/run/docker.sock:/var/run/docker.sock + - statics:/mnt/volumes/statics - geoserver-data-dir:/geoserver_data/data env_file: - ./scripts/docker/env/production/django.env @@ -122,11 +115,27 @@ services: - geoserver ports: - "80:80" + volumes: + - statics:/mnt/volumes/statics + + data-dir-conf: + image: geonode/geoserver_data:2.14.x + restart: on-failure + container_name: gsconf4${COMPOSE_PROJECT_NAME} + labels: + org.geonode.component: conf + org.geonode.instance.name: geonode + command: /bin/true + volumes: + - geoserver-data-dir:/geoserver_data/data volumes: + statics: + name: ${COMPOSE_PROJECT_NAME}-statics geoserver-data-dir: name: ${COMPOSE_PROJECT_NAME}-gsdatadir dbdata: name: ${COMPOSE_PROJECT_NAME}-dbdata dbbackups: name: ${COMPOSE_PROJECT_NAME}-dbbackups + diff --git a/entrypoint.sh b/entrypoint.sh index fcd1e88e578..79cac1aba50 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,7 @@ set -e source $HOME/.override_env +echo IS_CELERY=$IS_CELERY echo DATABASE_URL=$DATABASE_URL echo GEODATABASE_URL=$GEODATABASE_URL echo SITEURL=$SITEURL @@ -17,10 +18,19 @@ echo "waitfordbs task done" /usr/local/bin/invoke migrations >> /usr/src/app/invoke.log echo "migrations task done" -/usr/local/bin/invoke prepare >> /usr/src/app/invoke.log -echo "prepare task done" -/usr/local/bin/invoke fixtures >> /usr/src/app/invoke.log -echo "fixture task done" + +if [ ! -e "/mnt/volumes/statics/geonode_init.lock" ]; then + /usr/local/bin/invoke prepare + echo "prepare task done" + /usr/local/bin/invoke fixtures + echo "fixture task done" +fi +/usr/local/bin/invoke initialized +echo "initialized" + +echo "refresh static data" +/usr/local/bin/invoke statics +echo "static data refreshed" cmd="$@" @@ -33,7 +43,7 @@ then else - if [ ${IS_CELERY} = "true" ] + if [ ${IS_CELERY} = "true" ] || [ ${IS_CELERY} = "True" ] then cmd=$CELERY_CMD diff --git a/scripts/docker/env/production/celery.env b/scripts/docker/env/production/celery.env index e3c876875cb..2b176aa170d 100644 --- a/scripts/docker/env/production/celery.env +++ b/scripts/docker/env/production/celery.env @@ -13,16 +13,16 @@ DOCKER_ENV=production CELERY_CMD=celery worker --app=geonode.celery_app:app --broker=amqp://guest:guest@rabbitmq:5672/ -B -l INFO IS_CELERY=True C_FORCE_ROOT=1 -SITEURL=http=//localhost/ +SITEURL=http://localhost/ # replaced with defaults in settings -GEOSERVER_PUBLIC_LOCATION=http=//localhost/geoserver/ -GEOSERVER_LOCATION=http=//geoserver:8080/geoserver/ +GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ +GEOSERVER_LOCATION=http://geoserver:8080/geoserver/ OGC_REQUEST_TIMEOUT=300 STATIC_ROOT=/mnt/volumes/statics/static/ MEDIA_ROOT=/mnt/volumes/statics/uploaded/ GEOIP_PATH=/mnt/volumes/statics/geoip.db -ALLOWED_HOSTS="['django', '*']" -ADMIN_EMAILS="" +ALLOWED_HOSTS=['django', '*'] +ADMIN_EMAILS DEFAULT_BACKEND_UPLOADER=geonode.importer TIME_ENABLED=True MOSAIC_ENABLED=False @@ -33,6 +33,6 @@ HAYSTACK_ENGINE_INDEX_NAME=haystack HAYSTACK_SEARCH_RESULTS_PER_PAGE=200 # GEOSERVER_ADMIN_PASSWORD=admin -# See https=//github.com/geosolutions-it/geonode-generic/issues/28 +# See https://github.com/geosolutions-it/geonode-generic/issues/28 # to see why we force API version to 1.24 DOCKER_API_VERSION="1.24" diff --git a/scripts/docker/env/production/django.env b/scripts/docker/env/production/django.env index 85dbe124062..a68387162df 100644 --- a/scripts/docker/env/production/django.env +++ b/scripts/docker/env/production/django.env @@ -13,16 +13,16 @@ DOCKER_ENV=production UWSGI_CMD=uwsgi --ini /usr/src/app/uwsgi.ini IS_CELERY=False C_FORCE_ROOT=1 -SITEURL=http=//localhost/ +SITEURL=http://localhost/ # replaced with defaults in settings -GEOSERVER_PUBLIC_LOCATION=http=//localhost/geoserver/ -GEOSERVER_LOCATION=http=//geoserver:8080/geoserver/ +GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ +GEOSERVER_LOCATION=http://geoserver:8080/geoserver/ OGC_REQUEST_TIMEOUT=300 STATIC_ROOT=/mnt/volumes/statics/static/ MEDIA_ROOT=/mnt/volumes/statics/uploaded/ GEOIP_PATH=/mnt/volumes/statics/geoip.db -ALLOWED_HOSTS="['django', '*']" -ADMIN_EMAILS="" +ALLOWED_HOSTS=['django', '*'] +ADMIN_EMAILS DEFAULT_BACKEND_UPLOADER=geonode.importer TIME_ENABLED=True MOSAIC_ENABLED=False @@ -33,6 +33,6 @@ HAYSTACK_ENGINE_INDEX_NAME=haystack HAYSTACK_SEARCH_RESULTS_PER_PAGE=200 # GEOSERVER_ADMIN_PASSWORD=admin -# See https=//github.com/geosolutions-it/geonode-generic/issues/28 +# See https://github.com/geosolutions-it/geonode-generic/issues/28 # to see why we force API version to 1.24 DOCKER_API_VERSION="1.24" diff --git a/tasks.py b/tasks.py index fc71ee96710..8ca4af9d77e 100755 --- a/tasks.py +++ b/tasks.py @@ -83,6 +83,15 @@ def migrations(ctx): ), pty=True) +@task +def statics(ctx): + print "**************************migrations*******************************" + ctx.run('mkdir -p /mnt/volumes/statics/{static,uploads}') + ctx.run("python manage.py collectstatic --noinput --clear --settings={0}".format( + _localsettings() + ), pty=True) + + @task def prepare(ctx): print "**********************prepare fixture***************************" @@ -101,6 +110,12 @@ def fixtures(ctx): --settings={0}".format(_localsettings()), pty=True) +@task +def initialized(ctx): + print "**************************init file********************************" + ctx.run('date > /mnt/volumes/statics/geonode_init.lock') + + def _docker_host_ip(): client = docker.from_env(version='1.24') ip_list = client.containers.run(BOOTSTRAP_IMAGE_CHEIP,