Skip to content

Commit

Permalink
- Aligning and improving the docker-compose settings
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Nov 28, 2018
1 parent 9059412 commit 6d40aff
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 23 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"]
31 changes: 20 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,11 @@ services:
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.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

geoserver:
image: geonode/geoserver:2.14.x
restart: unless-stopped
Expand Down Expand Up @@ -99,10 +90,12 @@ services:
- db
- elasticsearch
- rabbitmq
- data-dir-conf
# command: paver start_django -b 0.0.0.0:8000
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
6 changes: 3 additions & 3 deletions scripts/docker/env/production/celery.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ASYNC_SIGNALS=True
BROKER_URL=amqp://guest:guest@rabbitmq:5672
DOCKER_ENV=production
CELERY_CMD=celery worker --app=geonode.celery_app:app --broker=amqp://guest:guest@rabbitmq:5672/ -B -l INFO
IS_CELERY=True
IS_CELERY=true
C_FORCE_ROOT=1
SITEURL=http=//localhost/
# replaced with defaults in settings
Expand All @@ -21,8 +21,8 @@ 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 Down
6 changes: 3 additions & 3 deletions scripts/docker/env/production/django.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ASYNC_SIGNALS=True
BROKER_URL=amqp://guest:guest@rabbitmq:5672
DOCKER_ENV=production
UWSGI_CMD=uwsgi --ini /usr/src/app/uwsgi.ini
IS_CELERY=False
IS_CELERY=false
C_FORCE_ROOT=1
SITEURL=http=//localhost/
# replaced with defaults in settings
Expand All @@ -21,8 +21,8 @@ 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 Down
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 6d40aff

Please sign in to comment.