diff --git a/Dockerfile b/Dockerfile index b75b366..9f5960f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,41 +1,38 @@ ####################################### #Dockerfile to build a ganetimgr image# -#Uses Deban packages instead of pip # +# Uses Deban packages instead of pip # ####################################### # We use wheezy as a base (for now) FROM debian:wheezy MAINTAINER GRNET_NOC ENV GANETIMGR_UPSTREAM_URL https://github.com/grnet/ganetimgr.git # First layer - only system packages, nothing from the stack RUN apt-get update -q2 && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -q2 git procps apt-utils # Django and rest of python dependencies for the project RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -q2 python-django python-redis python-mysqldb python-django-south python-django-registration python-paramiko python-simplejson python-daemon python-setproctitle python-pycurl python-recaptcha python-ipaddr python-bs4 python-requests python-markdown python-gevent # Daemon dependencies RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -q2 gunicorn beanstalkd nginx redis-server -# This is a workaound for a project dependency that has no Debian package -ADD python-django-markdown_0.6.1-1_all.deb / -RUN dpkg -i /python-django-markdown_0.6.1-1_all.deb -# Can be removed when the commit that removes the dep is on master - -# Get the repository and switch context inside it +# Create a placeholder dir for the repo and switch context inside it ENV GANETIMGR_INSTALLDIR=/srv/ganetimgr -RUN git clone --quiet $GANETIMGR_UPSTREAM_URL $GANETIMGR_INSTALLDIR +RUN mkdir -p $GANETIMGR_INSTALLDIR WORKDIR $GANETIMGR_INSTALLDIR # Predifined Settings for use inside the container COPY settings.py $GANETIMGR_INSTALLDIR/ganetimgr/settings.py # Helper function to get the db connection info from envvars -COPY dj_database_url.py ganetimgr/dj_database_url.py - +COPY dj_database_url.py $GANETIMGR_INSTALLDIR/ganetimgr/dj_database_url.py +# Fixture to autoadd the cluster from the ganeti container (hardcoded for now) +COPY cluster_insert.json $GANETIMGR_INSTALLDIR/cluster_insert.json COPY ganetimgr.nginx.conf /etc/nginx/nginx.conf # nginx run inside the container EXPOSE 80 + COPY entrypoint.sh / # Set this as a CMD instead of ENTRYPOINT in order to be able to override it CMD ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 722e876..54a5b8e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,33 +1,30 @@ #!/bin/bash -# Create a dummy file, until this is no longer needed -touch templates/includes/analytics.html - - -/srv/ganetimgr/manage.py loaddata /dumpdata.json - - - +GANETIMGR_REPO=${GANETIMGR_REPO-https://github.com/grnet/ganetimgr.git} +GANETIMGR_CHECKOUT=${GANETIMGR_CHECKOUT-master} +cd /srv/ganetimgr +git init > /dev/null +git remote add origin "$GANETIMGR_REPO" +git pull origin master # Django init commands python manage.py syncdb --noinput -v0 --migrate python manage.py collectstatic --noinput -v0 -l - +python manage.py loaddata cluster_insert.json if [ -n "$GANETIMGR_ADMIN_PASS" ]; then echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', '$GANETIMGR_ADMIN_PASS')" | python manage.py shell - echo "from django.contrib.auth.models import User; User.objects.create_user('user', 'user@example.com', '$GANETIMGR_ADMIN_PASS')" | python manage.py shell + echo "from django.contrib.auth.models import User; User.objects.create_user('user', 'user@example.com', '$GANETIMGR_ADMIN_PASS')" | python manage.py shell fi # Start background services sed -i 's/#START=yes/START=yes/' /etc/default/beanstalkd /etc/init.d/beanstalkd start -/etc/init.d/redis-server start -/etc/init.d/nginx start +mkdir /var/log/ganetimgr/ +python watcher.py --foreground --log-file=- & -mkdir /srv/logs -touch /srv/logs/gunicorn.log /srv/logs/access.log -tail -f /srv/logs/*.log & +#/etc/init.d/redis-server start +/etc/init.d/nginx start > /dev/null -echo "Starting Gunicorn." -gunicorn ganetimgr.wsgi:application --name ganetimgr --bind 0.0.0.0:8000 --workers=1 --log-level=info --log-file=/srv/logs/gunicorn.log --access-logfile=/srv/logs/access.log "$@" +#gunicorn ganetimgr.wsgi:application --name ganetimgr --bind 0.0.0.0:8000 --workers=1 --log-level=info --log-file=/srv/logs/gunicorn.log --access-logfile=/srv/logs/access.log "$@" +gunicorn ganetimgr.wsgi:application --name ganetimgr --bind 0.0.0.0:8000 --workers=1 --log-level=info --log-file=- --access-logfile=- "$@"