Skip to content

Commit

Permalink
- Finalize: Update docker compose files and refresh of JS assets
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Nov 28, 2018
1 parent 66873e9 commit b4d6ccf
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 61 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
20 changes: 11 additions & 9 deletions docker-compose.override.localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 11 additions & 9 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
59 changes: 34 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -77,7 +68,7 @@ services:
org.geonode.instance.name: geonode
depends_on:
- db
# - elasticsearch
- elasticsearch
- rabbitmq
- data-dir-conf
volumes:
Expand All @@ -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
Expand All @@ -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

20 changes: 15 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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="$@"

Expand All @@ -33,7 +43,7 @@ then

else

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

cmd=$CELERY_CMD
Expand Down
12 changes: 6 additions & 6 deletions scripts/docker/env/production/celery.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
12 changes: 6 additions & 6 deletions scripts/docker/env/production/django.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
15 changes: 15 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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***************************"
Expand All @@ -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,
Expand Down

0 comments on commit b4d6ccf

Please sign in to comment.