Skip to content

Commit

Permalink
Add dev mode with regular Docker (#4514)
Browse files Browse the repository at this point in the history
* add env files for dev

* Add docker-compose scripts for dev mode

* Fix reference links to docs

* Align with template link

* Avoid clash between django and celery commands

* Fix broken links

* Align geoserver version in compose file for devel

* Remove no longer used variable

* Set env_file from root environment variable SET_DOCKER_ENV

* Align prod and devel env files

* Align filename extension of docker-compose file

* Improve cmd logic for development

* Use a single file to override for development mode

* Add docs for developing with docker

* Install ipdb for development
  • Loading branch information
francbartoli authored Jun 30, 2019
1 parent 2073bee commit f47f752
Show file tree
Hide file tree
Showing 22 changed files with 269 additions and 32 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
COMPOSE_PROJECT_NAME=geonode
SET_DOCKER_ENV=production
2 changes: 1 addition & 1 deletion docker-compose-geoserver-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
volumes:
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/geoserver.env
ports:
- "${GEOSERVER_SERVER_PORT}:8080"
network_mode: "bridge"
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.async.yaml → docker-compose.async.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- dbdata:/var/lib/postgresql/data
- dbbackups:/pg_backups
env_file:
- ./scripts/docker/env/production/db.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/db.env

elasticsearch:
image: elasticsearch:2.4.1
Expand Down Expand Up @@ -56,7 +56,7 @@ services:
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/celery.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/celery.env

geoserver:
image: geonode/geoserver:2.14.3
Expand All @@ -75,7 +75,7 @@ services:
volumes:
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/geoserver.env

django:
restart: unless-stopped
Expand All @@ -97,7 +97,7 @@ services:
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/django.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/django.env

geonode:
image: geonode/nginx:geoserver
Expand Down
68 changes: 68 additions & 0 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: '2.2'
services:

celery:
build: .
command: celery worker --app=geonode.celery_app:app --broker=amqp://guest:guest@rabbitmq:5672/ -B -l DEBUG
depends_on:
- db
- elasticsearch
- rabbitmq
volumes:
- .:/usr/src/app
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
environment:
- DOCKER_ENV=${SET_DOCKER_ENV}
- IS_CELERY=True
- DEBUG=True
- GEONODE_LB_HOST_IP=localhost
- GEONODE_LB_PORT=80
- SITEURL=http://localhost/
- ALLOWED_HOSTS=['localhost', ]
- GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/
- GEOSERVER_WEB_UI_LOCATION=http://localhost/geoserver/

django:
build: .
command: python manage.py runserver --settings=geonode.settings 0.0.0.0:8000
volumes:
- .:/usr/src/app
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
environment:
- DOCKER_ENV=${SET_DOCKER_ENV}
- IS_CELERY=False
- DEBUG=True
- GEONODE_LB_HOST_IP=localhost
- GEONODE_LB_PORT=80
- SITEURL=http://localhost/
- ALLOWED_HOSTS=['localhost', ]
- GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/
- GEOSERVER_WEB_UI_LOCATION=http://localhost/geoserver/

geoserver:
depends_on:
- db
- elasticsearch
- rabbitmq
- data-dir-conf
environment:
- GEONODE_LB_HOST_IP=localhost
- GEONODE_LB_PORT=80

geonode:
image: geonode/nginx:${SET_DOCKER_ENV}
restart: unless-stopped
container_name: nginx4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
labels:
org.geonode.component: nginx
org.geonode.instance.name: geonode
depends_on:
- django
- celery
- geoserver
ports:
- 80:80
1 change: 0 additions & 1 deletion docker-compose.override.localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ services:
environment:
- GEONODE_LB_HOST_IP=localhost
- GEONODE_LB_PORT=80
# - NGINX_BASE_URL=
1 change: 0 additions & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ services:
environment:
- GEONODE_LB_HOST_IP=localhost
- GEONODE_LB_PORT=80
# - NGINX_BASE_URL=
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- dbdata:/var/lib/postgresql/data
- dbbackups:/pg_backups
env_file:
- ./scripts/docker/env/production/db.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/db.env

geoserver:
image: geonode/geoserver:2.14.3
Expand All @@ -31,7 +31,7 @@ services:
volumes:
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/geoserver.env

django:
restart: unless-stopped
Expand All @@ -51,7 +51,7 @@ services:
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/django.env
- ./scripts/docker/env/${SET_DOCKER_ENV}/django.env

geonode:
image: geonode/nginx:geoserver
Expand Down
58 changes: 58 additions & 0 deletions docs/devel/docker/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Start to develop with Docker
----------------------------

How to run the instance for development
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Set the variable SET_DOCKER_ENV for development
...............................................

.. code-block:: shell
vi .env
Change to

.. code-block:: shell
SET_DOCKER_ENV=development
Use dedicated docker-compose files while developing
...................................................

.. note:: In this example we are going to keep ``localhost`` as the target IP for GeoNode

.. code-block:: shell
docker-compose -f docker-compose.async.yml -f docker-compose.development.yml up
How to debug
............

.. note:: We are supposing to use ``ipdb`` for debugging which is already available as package from the container

Stop the container for the ``django`` service:

.. code-block:: shell
docker-compose stop django
Run the container again with the option for *service ports*:

.. code-block:: shell
docker-compose run \
-e DOCKER_ENV=development \
-e IS_CELERY=False \
-e DEBUG=True \
-e GEONODE_LB_HOST_IP=localhost \
-e GEONODE_LB_PORT=80 \
-e SITEURL=http://localhost/ \
-e ALLOWED_HOSTS="['localhost', ]" \
-e GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ \
-e GEOSERVER_WEB_UI_LOCATION=http://localhost/geoserver/ \
--rm --service-ports django python manage.py runserver --settings=geonode.settings 0.0.0.0:8000
Access the site on http://localhost/

.. note:: If you set an ``ipdb`` debug point with import ``ipdb ; ipdb.set_trace()`` then you should be facing its console and you can see the django server which is restarting at any change of your code from your local machine.
7 changes: 6 additions & 1 deletion docs/devel/index.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
How to Develop
==============
==============

.. toctree::
:maxdepth: 3

docker/index
27 changes: 26 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,28 @@ echo DOCKER_ENV=$DOCKER_ENV
if [ -z ${DOCKER_ENV} ] || [ ${DOCKER_ENV} = "development" ]
then

echo "Executing standard Django server $cmd for Development"
/usr/local/bin/invoke prepare
echo "prepare task done"
/usr/local/bin/invoke fixtures
echo "fixture task done"

if [ ${IS_CELERY} = "true" ] || [ ${IS_CELERY} = "True" ]
then

cmd=$cmd
echo "Executing Celery server $cmd for Development"

else

echo "install requirements for development"
/usr/local/bin/invoke devrequirements
echo "refresh static data"
/usr/local/bin/invoke statics
echo "static data refreshed"
cmd=$cmd
echo "Executing standard Django server $cmd for Development"

fi

else

Expand All @@ -38,11 +59,14 @@ else
else

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"

Expand All @@ -57,4 +81,5 @@ else

fi

echo "command to be executed is $cmd"
exec $cmd
2 changes: 1 addition & 1 deletion geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
msg = (
'Please configure OGC_SERVER when enabling geonode.geoserver.'
' More info can be found at '
'http://docs.geonode.org/en/master/reference/developers/settings.html#ogc-server')
'http://docs.geonode.org/en/master/basic/settings/index.html#ogc-server')
raise ImproperlyConfigured(msg)


Expand Down
4 changes: 2 additions & 2 deletions geonode/locale/ar/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6266,8 +6266,8 @@ msgid "GeoNode is an open source platform for sharing geospatial data and maps."
msgstr "GeoNode هو منصة مفتوحة المصدر لتبادل البيانات الجغرافية والخرائط."

#: geonode/templates/index.html:23
msgid "http://docs.geonode.org/en/master/tutorials/users/index.html"
msgstr "http://docs.geonode.org/en/master/tutorials/users/index.html"
msgid "http://docs.geonode.org/en/master/usage"
msgstr "http://docs.geonode.org/en/master/usage"

#: geonode/templates/index.html:23
msgid "Get Started »"
Expand Down
4 changes: 2 additions & 2 deletions geonode/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,8 @@ msgstr "GeoNode ist eine Open-Source-Plattform zur Veröffentlichung von Geodate

#: geonode/contrib/geosites/site_template/templates/site_index.html:14
#: geonode/contrib/geosites/templates/master_index.html:15 geonode/templates/index.html:23
msgid "http://docs.geonode.org/en/master/tutorials/users/index.html"
msgstr "http://docs.geonode.org/en/master/tutorials/users/index.html"
msgid "http://docs.geonode.org/en/master/usage"
msgstr "http://docs.geonode.org/en/master/usage"

#: geonode/contrib/geosites/site_template/templates/site_index.html:15
#: geonode/contrib/geosites/templates/master_index.html:16 geonode/templates/index.html:23
Expand Down
2 changes: 1 addition & 1 deletion geonode/locale/el/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ msgstr ""
#: geonode/contrib/geosites/site_template/templates/site_index.html:14
#: geonode/contrib/geosites/templates/master_index.html:15
#: geonode/templates/index.html:23
msgid "http://docs.geonode.org/en/master/tutorials/users/index.html"
msgid "http://docs.geonode.org/en/master/usage"
msgstr ""

#: geonode/contrib/geosites/site_template/templates/site_index.html:15
Expand Down
2 changes: 1 addition & 1 deletion geonode/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7827,7 +7827,7 @@ msgid "home"
msgstr ""

#: geonode/templates/index.html:23
msgid "http://docs.geonode.org/en/master/tutorials/users/index.html"
msgid "http://docs.geonode.org/en/master/usage"
msgstr ""

#: geonode/templates/index.html:23
Expand Down
2 changes: 1 addition & 1 deletion geonode/locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7459,7 +7459,7 @@ msgid "home"
msgstr ""

#: geonode/templates/index.html:23
msgid "http://docs.geonode.org/en/master/tutorials/users/index.html"
msgid "http://docs.geonode.org/en/master/usage"
msgstr ""

#: geonode/templates/index.html:23
Expand Down
3 changes: 1 addition & 2 deletions geonode/tests/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ def zip_dir(basedir, archivename):
r"""
HOW TO RUN THE TESTS
--------------------
(https://github.com/GeoNode/geonode/blob/master/docs/tutorials/devel/testing.txt)

1)
(https://github.com/GeoNode/geonode/blob/master/docs/tutorials/devel/envsetup/paver.txt)
(http://docs.geonode.org/en/master/install/core/index.html?highlight=paver#run-geonode-for-the-first-time-in-debug-mode)

$ paver setup

Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ipdb
43 changes: 43 additions & 0 deletions scripts/docker/env/development/celery.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
DJANGO_SETTINGS_MODULE=geonode.settings
GEONODE_INSTANCE_NAME=geonode
GEONODE_LB_HOST_IP
GEONODE_LB_PORT
DEFAULT_BACKEND_DATASTORE=datastore
GEONODE_DATABASE=geonode
GEONODE_DATABASE_PASSWORD=geonode
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_PASSWORD=geonode_data
ASYNC_SIGNALS=True
BROKER_URL=amqp://guest:guest@rabbitmq:5672
DOCKER_ENV=development
IS_CELERY=True
DEBUG=True
C_FORCE_ROOT=1
SITEURL=http://localhost/
# replaced with defaults in settings
GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/
GEOSERVER_WEB_UI_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
DEFAULT_BACKEND_UPLOADER=geonode.importer
TIME_ENABLED=True
MOSAIC_ENABLED=False
GEOGIG_ENABLED=False
HAYSTACK_SEARCH=False
HAYSTACK_ENGINE_URL=http://elasticsearch:9200/
HAYSTACK_ENGINE_INDEX_NAME=haystack
HAYSTACK_SEARCH_RESULTS_PER_PAGE=200


ALLOWED_DOCUMENT_TYPES=['doc', 'docx', 'gif', 'jpg', 'jpeg', 'ods', 'odt', 'odp', 'pdf', 'png','ppt', 'pptx', 'rar', 'sld', 'tif', 'tiff', 'txt', 'xls', 'xlsx', 'xml', 'zip', 'gz', 'qml']
MAX_DOCUMENT_SIZE=2

# GEOSERVER_ADMIN_PASSWORD=admin
# 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"
Loading

0 comments on commit f47f752

Please sign in to comment.