Skip to content

Commit

Permalink
- Improve docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jun 3, 2019
1 parent 155ac7c commit aca042e
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 68 deletions.
144 changes: 144 additions & 0 deletions docker-compose.async.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
version: '2.2'
services:

db:
image: geonode/postgis:10
restart: unless-stopped
container_name: db4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
labels:
org.geonode.component: db
org.geonode.instance.name: geonode
volumes:
- dbdata:/var/lib/postgresql/data
- dbbackups:/pg_backups
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

rabbitmq:
image: rabbitmq
restart: unless-stopped
container_name: rabbitmq4${COMPOSE_PROJECT_NAME}
stdin_open: true
tty: true
labels:
org.geonode.component: rabbitmq
org.geonode.instance.name: geonode
volumes:
- rabbitmq:/var/lib/rabbitmq

celery:
restart: unless-stopped
image: geonode/geonode:latest
container_name: celery4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
labels:
org.geonode.component: celery
org.geonode.instance.name: geonode
depends_on:
- db
- elasticsearch
- rabbitmq
# 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

geoserver:
image: geonode/geoserver:2.14.x
restart: unless-stopped
container_name: geoserver4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
labels:
org.geonode.component: geoserver
org.geonode.instance.name: geonode
depends_on:
- db
- elasticsearch
- rabbitmq
- data-dir-conf
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env

django:
restart: unless-stopped
image: geonode/geonode:latest
container_name: django4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
labels:
org.geonode.component: django
org.geonode.instance.name: geonode
depends_on:
- 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

geonode:
image: geonode/nginx:geoserver
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"
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
rabbitmq:
name: ${COMPOSE_PROJECT_NAME}-rabbitmq
48 changes: 0 additions & 48 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,6 @@ 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

rabbitmq:
image: rabbitmq
restart: unless-stopped
container_name: rabbitmq4${COMPOSE_PROJECT_NAME}
stdin_open: true
tty: true
labels:
org.geonode.component: rabbitmq
org.geonode.instance.name: geonode
volumes:
- rabbitmq:/var/lib/rabbitmq

celery:
restart: unless-stopped
image: geonode/geonode:latest
container_name: celery4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
labels:
org.geonode.component: celery
org.geonode.instance.name: geonode
depends_on:
- db
- elasticsearch
- rabbitmq
# 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

geoserver:
image: geonode/geoserver:2.14.x
restart: unless-stopped
Expand All @@ -70,8 +27,6 @@ services:
org.geonode.instance.name: geonode
depends_on:
- db
- elasticsearch
- rabbitmq
- data-dir-conf
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Expand All @@ -90,8 +45,6 @@ services:
org.geonode.instance.name: geonode
depends_on:
- db
- elasticsearch
- rabbitmq
- data-dir-conf
# command: paver start_django -b 0.0.0.0:8000
# command: uwsgi --ini uwsgi.ini
Expand All @@ -113,7 +66,6 @@ services:
org.geonode.instance.name: geonode
depends_on:
- django
- celery
- geoserver
ports:
- "80:80"
Expand Down
28 changes: 13 additions & 15 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,10 @@ echo GEOSERVER_PUBLIC_LOCATION=$GEOSERVER_PUBLIC_LOCATION
echo GEOSERVER_WEB_UI_LOCATION=$GEOSERVER_WEB_UI_LOCATION

/usr/local/bin/invoke waitfordbs >> /usr/src/app/invoke.log

echo "waitfordbs task done"

/usr/local/bin/invoke migrations >> /usr/src/app/invoke.log
echo "migrations 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="$@"

echo DOCKER_ENV=$DOCKER_ENV
Expand All @@ -52,6 +37,19 @@ 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"

echo "refresh static data"
/usr/local/bin/invoke statics
echo "static data refreshed"

cmd=$UWSGI_CMD
echo "Executing UWSGI server $cmd for Production"

Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/env/production/django.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GEONODE_DATABASE=geonode
GEONODE_DATABASE_PASSWORD=geonode
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_PASSWORD=geonode_data
ASYNC_SIGNALS=True
ASYNC_SIGNALS=False
BROKER_URL=amqp://guest:guest@rabbitmq:5672
DOCKER_ENV=production
UWSGI_CMD=uwsgi --ini /usr/src/app/uwsgi.ini
Expand Down
19 changes: 15 additions & 4 deletions uwsgi.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
[uwsgi]
uwsgi-socket = 0.0.0.0:8000
# http-socket = 0.0.0.0:8000
chdir = /usr/src/app/
logto = /var/log/geonode.log
pidfile = /tmp/geonode.pid
harakiri = 25

chdir = /usr/src/app/
module = geonode.wsgi:application
master = 1

processes = 4
threads = 2
buffer-size = 8192
enable-threads = true
master = true

buffer-size = 32768
max-requests = 500
harakiri = 300 # respawn processes taking more than 5 minutes (300 seconds)
max-requests = 500 # respawn processes after serving 5000 requests
# limit-as = 1024 # avoid Errno 12 cannot allocate memory
harakiri-verbose = true
# cron = -1 -1 -1 -1 -1 /usr/local/bin/python /usr/src/{{project_name}}/manage.py collect_metrics -n
vacuum = true
thunder-lock = true

0 comments on commit aca042e

Please sign in to comment.