Skip to content

Commit

Permalink
[Closes #37] Align the check of first start between geonode-project a…
Browse files Browse the repository at this point in the history
…nd geonode
  • Loading branch information
afabiani committed Jan 15, 2021
1 parent c5d35cc commit 919c32f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 30 deletions.
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
COMPOSE_PROJECT_NAME={{project_name}}
BACKUPS_VOLUME_DRIVER=local

DOCKER_HOST_IP=
DOCKER_ENV=production
# 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"
BACKUPS_VOLUME_DRIVER=local

C_FORCE_ROOT=1
IS_CELERY=false
IS_FIRST_START=true
FORCE_REINIT=false

SITEURL=http://localhost/
Expand Down
28 changes: 14 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-k

# This section is borrowed from the official Django image but adds GDAL and others
RUN apt-get update && apt-get install -y \
libpq-dev python-dev libxml2-dev \
libxml2 libxslt1-dev zlib1g-dev libjpeg-dev \
libmemcached-dev libldap2-dev libsasl2-dev libffi-dev
libpq-dev python-dev libxml2-dev \
libxml2 libxslt1-dev zlib1g-dev libjpeg-dev \
libmemcached-dev libldap2-dev libsasl2-dev libffi-dev

RUN apt-get update && apt-get install -y \
gcc zip gettext geoip-bin cron \
postgresql-client-11 \
sqlite3 spatialite-bin libsqlite3-mod-spatialite \
python3-gdal python3-psycopg2 python3-ldap \
python3-pip python3-pil python3-lxml python3-pylibmc \
python3-dev libgdal-dev \
uwsgi uwsgi-plugin-python3 \
gcc zip gettext geoip-bin cron \
postgresql-client-11 \
sqlite3 spatialite-bin libsqlite3-mod-spatialite \
python3-gdal python3-psycopg2 python3-ldap \
python3-pip python3-pil python3-lxml python3-pylibmc \
python3-dev libgdal-dev \
uwsgi uwsgi-plugin-python3 \
--no-install-recommends && rm -rf /var/lib/apt/lists/*

# add bower and grunt command
Expand Down Expand Up @@ -48,11 +48,11 @@ RUN apt-get update && apt-get install -y devscripts build-essential debhelper pk

# Install pip packages
RUN pip install pip --upgrade
RUN pip install --upgrade --no-cache-dir --src /usr/src -r requirements.txt \
RUN pip install --upgrade --no-cache-dir --src /usr/src -r requirements.txt \
&& pip install pygdal==$(gdal-config --version).* \
&& pip install flower==0.9.4

RUN pip install --upgrade -e .
RUN pip install --upgrade -e .

# Activate "memcached"
RUN apt install memcached
Expand All @@ -62,7 +62,7 @@ RUN pip install pylibmc \
# Install "geonode-contribs" apps
RUN cd /usr/src; git clone https://github.com/GeoNode/geonode-contribs.git -b master
# Install logstash and centralized dashboard dependencies
RUN cd /usr/src/geonode-contribs/geonode-logstash; pip install --upgrade -e . \
cd /usr/src/geonode-contribs/ldap; pip install --upgrade -e .
RUN cd /usr/src/geonode-contribs/geonode-logstash; pip install --upgrade -e . \
cd /usr/src/geonode-contribs/ldap; pip install --upgrade -e .

ENTRYPOINT service cron restart && service memcached restart && /usr/src/{{project_name}}/entrypoint.sh
43 changes: 30 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
#!/bin/bash

# Exit script in case of error
set -e

/usr/local/bin/invoke update >> /usr/src/{{project_name}}/invoke.log

echo $"\n\n\n"
echo "-----------------------------------------------------"
echo "STARTING DJANGO ENTRYPOINT $(date)"
echo "-----------------------------------------------------"

/usr/local/bin/invoke update > /usr/src/{{project_name}}/invoke.log 2>&1

source $HOME/.bashrc
source $HOME/.override_env

echo DOCKER_API_VERSION=$DOCKER_API_VERSION
echo POSTGRES_USER=$POSTGRES_USER
echo POSTGRES_PASSWORD=$POSTGRES_PASSWORD
echo DATABASE_URL=$DATABASE_URL
echo GEODATABASE_URL=$GEODATABASE_URL
echo SITEURL=$SITEURL
Expand All @@ -16,11 +27,11 @@ echo MONITORING_HOST_NAME=$MONITORING_HOST_NAME
echo MONITORING_SERVICE_NAME=$MONITORING_SERVICE_NAME
echo MONITORING_DATA_TTL=$MONITORING_DATA_TTL

/usr/local/bin/invoke waitfordbs >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke waitfordbs > /usr/src/{{project_name}}/invoke.log 2>&1
echo "waitfordbs task done"

echo "running migrations"
/usr/local/bin/invoke migrations >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke migrations > /usr/src/{{project_name}}/invoke.log 2>&1
echo "migrations task done"

cmd="$@"
Expand All @@ -37,33 +48,39 @@ else
echo "Executing Celery server $cmd for Production"
else

/usr/local/bin/invoke prepare >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke prepare > /usr/src/{{project_name}}/invoke.log 2>&1
echo "prepare task done"

if [ ${IS_FIRST_START} = "true" ] || [ ${IS_FIRST_START} = "True" ] || [ ${FORCE_REINIT} = "true" ] || [ ${FORCE_REINIT} = "True" ] || [ ! -e "/mnt/volumes/statics/geonode_init.lock" ]; then
/usr/local/bin/invoke updategeoip >> /usr/src/{{project_name}}/invoke.log
if [ ${FORCE_REINIT} = "true" ] || [ ${FORCE_REINIT} = "True" ] || [ ! -e "/mnt/volumes/statics/geonode_init.lock" ]; then
/usr/local/bin/invoke updategeoip > /usr/src/{{project_name}}/invoke.log 2>&1
echo "updategeoip task done"
/usr/local/bin/invoke fixtures >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke fixtures > /usr/src/{{project_name}}/invoke.log 2>&1
echo "fixture task done"
/usr/local/bin/invoke monitoringfixture >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke monitoringfixture > /usr/src/{{project_name}}/invoke.log 2>&1
echo "monitoringfixture task done"
/usr/local/bin/invoke initialized >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke initialized > /usr/src/{{project_name}}/invoke.log 2>&1
echo "initialized"
fi

echo "refresh static data"
/usr/local/bin/invoke statics >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke statics > /usr/src/{{project_name}}/invoke.log 2>&1
echo "static data refreshed"
/usr/local/bin/invoke waitforgeoserver >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke waitforgeoserver > /usr/src/{{project_name}}/invoke.log 2>&1
echo "waitforgeoserver task done"
/usr/local/bin/invoke geoserverfixture >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke geoserverfixture > /usr/src/{{project_name}}/invoke.log 2>&1
echo "geoserverfixture task done"
/usr/local/bin/invoke updateadmin >> /usr/src/{{project_name}}/invoke.log
/usr/local/bin/invoke updateadmin > /usr/src/{{project_name}}/invoke.log 2>&1
echo "updateadmin task done"

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

echo "-----------------------------------------------------"
echo "FINISHED DJANGO ENTRYPOINT --------------------------"
echo "-----------------------------------------------------"

# Run the CMD
echo "got command $cmd"
exec $cmd

0 comments on commit 919c32f

Please sign in to comment.