From ef5144103658b7db73792f7a76f7599355fcb46a Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 2 Dec 2015 09:31:27 +0100 Subject: [PATCH] try to simplify docker composition --- Dockerfile | 16 +++++---- app/__init__.py | 0 {examples => app}/deploy/apt-app.list | 0 {examples => app}/deploy/celery_app.sh | 9 +++-- {examples => app}/deploy/nginx-app.conf | 7 ++-- {examples => app}/deploy/start_app.sh | 15 ++++---- {examples => app}/deploy/wait.sh | 0 .../fixtures/original_format.txt | 0 {examples/sandbox => app}/manage.py | 2 +- {examples => app}/sandbox/__init__.py | 0 {examples => app}/sandbox/celery_app.py | 0 {examples => app}/sandbox/diag.sh | 0 {examples => app}/sandbox/modelviz.py | 0 {examples => app}/sandbox/robots.txt | 0 {examples => app}/sandbox/settings.py | 19 +++++----- {examples => app}/sandbox/update_schema.sh | 0 {examples => app}/sandbox/urls.py | 0 app/wsgi.py | 18 ++++++++++ doc/content/README.rst | 3 +- doc/pelicanconf.py | 22 ++++++++++-- docker-compose.yml | 35 +++++++------------ examples/sandbox/wsgi.py | 14 -------- telemeta/locale | 2 +- telemeta/pages | 2 +- .../templates/telemeta/collection_detail.html | 9 +++-- 25 files changed, 93 insertions(+), 80 deletions(-) create mode 100644 app/__init__.py rename {examples => app}/deploy/apt-app.list (100%) rename {examples => app}/deploy/celery_app.sh (75%) rename {examples => app}/deploy/nginx-app.conf (65%) rename {examples => app}/deploy/start_app.sh (64%) rename {examples => app}/deploy/wait.sh (100%) rename {examples => app}/fixtures/original_format.txt (100%) rename {examples/sandbox => app}/manage.py (70%) rename {examples => app}/sandbox/__init__.py (100%) rename {examples => app}/sandbox/celery_app.py (100%) rename {examples => app}/sandbox/diag.sh (100%) rename {examples => app}/sandbox/modelviz.py (100%) rename {examples => app}/sandbox/robots.txt (100%) rename {examples => app}/sandbox/settings.py (96%) rename {examples => app}/sandbox/update_schema.sh (100%) rename {examples => app}/sandbox/urls.py (100%) create mode 100644 app/wsgi.py delete mode 100644 examples/sandbox/wsgi.py diff --git a/Dockerfile b/Dockerfile index 138c9d35..59842d76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,13 +19,17 @@ FROM parisson/timeside:latest-dev MAINTAINER Guillaume Pellerin , Thomas fillon -# Clone app -RUN mkdir /opt/Telemeta -ADD . /opt/Telemeta -WORKDIR /opt/Telemeta - -# Install deps +RUN mkdir /opt/app RUN mkdir /opt/src + +WORKDIR /opt/app + +ADD requirements.txt /opt/app/ +ADD requirements-dev.txt /opt/app/ +ADD setup.py /opt/app/ +ADD README.rst /opt/app/ +ADD telemeta /opt/app/ + RUN pip install -r requirements.txt RUN pip install -r requirements-dev.txt --src /opt/src diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/deploy/apt-app.list b/app/deploy/apt-app.list similarity index 100% rename from examples/deploy/apt-app.list rename to app/deploy/apt-app.list diff --git a/examples/deploy/celery_app.sh b/app/deploy/celery_app.sh similarity index 75% rename from examples/deploy/celery_app.sh rename to app/deploy/celery_app.sh index ac08e3c3..87fda082 100644 --- a/examples/deploy/celery_app.sh +++ b/app/deploy/celery_app.sh @@ -1,16 +1,15 @@ #!/bin/sh # paths -app_dir='/opt/Telemeta' -sandbox='/home/sandbox' -manage=$sandbox'/manage.py' -wsgi=$sandbox'/wsgi.py' +app='/opt/app' +manage=$app'/manage.py' +wsgi=$app'/wsgi.py' # stating apps pip install django-haystack elasticsearch # waiting for other services -sh $app_dir/examples/deploy/wait.sh +sh $app/deploy/wait.sh # Starting celery worker with the --autoreload option will enable the worker to watch for file system changes # This is an experimental feature intended for use in development only diff --git a/examples/deploy/nginx-app.conf b/app/deploy/nginx-app.conf similarity index 65% rename from examples/deploy/nginx-app.conf rename to app/deploy/nginx-app.conf index 53cba5f9..d1f07b92 100644 --- a/examples/deploy/nginx-app.conf +++ b/app/deploy/nginx-app.conf @@ -13,13 +13,11 @@ server { # Django media location /media { - alias /home/sandbox/media; # your Django project's media files - amend as required - autoindex on; + alias /opt/media; # your Django project's media files - amend as required } # Django static location /static { - alias /var/www/static; # your Django project's static files - amend as required - autoindex on; + alias /opt/static; # your Django project's static files - amend as required } location / { @@ -27,4 +25,3 @@ server { include /etc/nginx/uwsgi_params; } } - diff --git a/examples/deploy/start_app.sh b/app/deploy/start_app.sh similarity index 64% rename from examples/deploy/start_app.sh rename to app/deploy/start_app.sh index 47179f85..9f6cc120 100644 --- a/examples/deploy/start_app.sh +++ b/app/deploy/start_app.sh @@ -1,17 +1,18 @@ #!/bin/sh # paths -app_dir='/opt/Telemeta' -static=$app_dir'/telemeta/static/' -sandbox='/home/sandbox' -manage=$sandbox'/manage.py' -wsgi=$sandbox'/wsgi.py' + + +app='/opt/app' +manage=$app'/manage.py' +wsgi=$app'/wsgi.py' +static='/opt/static/' # stating apps pip install django-haystack elasticsearch # waiting for other services -sh $app_dir/examples/deploy/wait.sh +sh $app/deploy/wait.sh # django init python $manage syncdb --noinput @@ -26,4 +27,4 @@ watchmedo shell-command --patterns="*.js;*.css" --recursive \ --command='python '$manage' collectstatic --noinput' $static & # app start -uwsgi --socket :8000 --wsgi-file $wsgi --chdir $sandbox --master --processes 4 --threads 2 --py-autoreload 3 +uwsgi --socket :8000 --wsgi-file $wsgi --chdir $app --master --processes 4 --threads 2 --py-autoreload 3 diff --git a/examples/deploy/wait.sh b/app/deploy/wait.sh similarity index 100% rename from examples/deploy/wait.sh rename to app/deploy/wait.sh diff --git a/examples/fixtures/original_format.txt b/app/fixtures/original_format.txt similarity index 100% rename from examples/fixtures/original_format.txt rename to app/fixtures/original_format.txt diff --git a/examples/sandbox/manage.py b/app/manage.py similarity index 70% rename from examples/sandbox/manage.py rename to app/manage.py index c632a8a3..d18fd971 100755 --- a/examples/sandbox/manage.py +++ b/app/manage.py @@ -2,7 +2,7 @@ import os, sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sandbox.settings") from django.core.management import execute_from_command_line diff --git a/examples/sandbox/__init__.py b/app/sandbox/__init__.py similarity index 100% rename from examples/sandbox/__init__.py rename to app/sandbox/__init__.py diff --git a/examples/sandbox/celery_app.py b/app/sandbox/celery_app.py similarity index 100% rename from examples/sandbox/celery_app.py rename to app/sandbox/celery_app.py diff --git a/examples/sandbox/diag.sh b/app/sandbox/diag.sh similarity index 100% rename from examples/sandbox/diag.sh rename to app/sandbox/diag.sh diff --git a/examples/sandbox/modelviz.py b/app/sandbox/modelviz.py similarity index 100% rename from examples/sandbox/modelviz.py rename to app/sandbox/modelviz.py diff --git a/examples/sandbox/robots.txt b/app/sandbox/robots.txt similarity index 100% rename from examples/sandbox/robots.txt rename to app/sandbox/robots.txt diff --git a/examples/sandbox/settings.py b/app/sandbox/settings.py similarity index 96% rename from examples/sandbox/settings.py rename to app/sandbox/settings.py index 039dcd54..271f14b2 100644 --- a/examples/sandbox/settings.py +++ b/app/sandbox/settings.py @@ -19,7 +19,7 @@ MANAGERS = ADMINS # Full filesystem path to the project. #PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) -PROJECT_ROOT = '/home/sandbox' +PROJECT_ROOT = '/opt/app/' DATABASES = { 'default': { @@ -73,10 +73,12 @@ USE_L10N = True # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = PROJECT_ROOT + '/media/' +# MEDIA_ROOT = PROJECT_ROOT + '/media/' +# +# if not os.path.exists(MEDIA_ROOT): +# os.makedirs(MEDIA_ROOT) -if not os.path.exists(MEDIA_ROOT): - os.makedirs(MEDIA_ROOT) +MEDIA_ROOT = '/opt/media/' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). @@ -87,7 +89,8 @@ MEDIA_URL = '/media/' # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" -STATIC_ROOT = '/var/www/static' +# STATIC_ROOT = '/var/www/static' +STATIC_ROOT = '/opt/static/' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" @@ -128,7 +131,7 @@ MIDDLEWARE_CLASSES = ( # 'pagination.middleware.PaginationMiddleware', ) -ROOT_URLCONF = 'urls' +ROOT_URLCONF = 'sandbox.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". @@ -278,7 +281,7 @@ LOGGING = { } # replace rabbitmq by localhost if you start your app outside docker-compose -BROKER_URL = 'amqp://guest:guest@rabbitmq//' +BROKER_URL = 'amqp://guest:guest@broker//' CELERY_IMPORTS = ("timeside.server.tasks",) CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend' @@ -299,5 +302,3 @@ HAYSTACK_CONNECTIONS = { HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' HAYSTACK_SEARCH_RESULTS_PER_PAGE = 50 - - diff --git a/examples/sandbox/update_schema.sh b/app/sandbox/update_schema.sh similarity index 100% rename from examples/sandbox/update_schema.sh rename to app/sandbox/update_schema.sh diff --git a/examples/sandbox/urls.py b/app/sandbox/urls.py similarity index 100% rename from examples/sandbox/urls.py rename to app/sandbox/urls.py diff --git a/app/wsgi.py b/app/wsgi.py new file mode 100644 index 00000000..6b05fff1 --- /dev/null +++ b/app/wsgi.py @@ -0,0 +1,18 @@ +#!/usr/bin/python2.5 +# -*- coding: utf-8 -*- + +import os +import sys + +here = os.path.dirname(__file__) +sys.path.append(here) + +# os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' +# +# import django.core.handlers.wsgi +# application = django.core.handlers.wsgi.WSGIHandler() + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sandbox.settings") + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() diff --git a/doc/content/README.rst b/doc/content/README.rst index 3b3e2d4d..7ea21365 100644 --- a/doc/content/README.rst +++ b/doc/content/README.rst @@ -5,7 +5,7 @@ Telemeta: open web audio platform with semantics :category: About :Pin: true -.. image:: /Telemeta/images/logo_telemeta_2.png +.. image:: /images/logo_telemeta_2.png :alt: Telemeta logo Overview @@ -205,4 +205,3 @@ The Telemeta project is developed by Parisson. It is sponsored by : http://www.mmsh.univ-aix.fr/ * MNHN : Museum d'Histoire Naturelle (Paris, France) http://www.mnhn.fr - diff --git a/doc/pelicanconf.py b/doc/pelicanconf.py index 2591ffa3..55f32129 100644 --- a/doc/pelicanconf.py +++ b/doc/pelicanconf.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # from __future__ import unicode_literals -AUTHOR = u'Parisson Sarl' +AUTHOR = u'Parisson SARL' SITENAME = u'Telemeta project' TIMEZONE = 'Europe/Paris' @@ -45,7 +45,10 @@ SOCIAL = (('GitHub', 'https://github.com/Parisson/Telemeta'), #RELATIVE_URLS = True PLUGIN_PATHS = ['pelican-plugins'] -PLUGINS = ['pin_to_top'] +PLUGINS = ['pin_to_top', 'sitemap', 'gallery', 'render_math', + 'liquid_tags.img', 'liquid_tags.video', + 'liquid_tags.youtube', 'liquid_tags.vimeo', + 'liquid_tags.include_code', 'liquid_tags.notebook',] STATIC_PATHS = ['images', 'css'] CUSTOM_CSS = 'css/custom.css' @@ -68,3 +71,18 @@ GITHUB_USER = 'Parisson' # Content licensing: CC-BY CC_LICENSE = "CC-BY" + +SITEMAP = { + + 'format': 'xml', + 'priorities': { + 'articles': 0.5, + 'indexes': 0.5, + 'pages': 0.5 + }, + 'changefreqs': { + 'articles': 'monthly', + 'indexes': 'daily', + 'pages': 'monthly' + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 68633642..446b5354 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,16 +22,11 @@ # Thomas Fillon -static: +media: image: debian:wheezy volumes: - - /var/www/static - command: "true" - -home: - image: debian:wheezy - volumes: - - ./examples/sandbox:/home/sandbox + - ./media/:/opt/media + - ./static/:/opt/static command: "true" db: @@ -45,7 +40,7 @@ db: - MYSQL_USER=telemeta - MYSQL_PASSWORD=iuvIlkyisFit2 -rabbitmq: +broker: image: rabbitmq:3-management ports: - "15672:15672" @@ -56,18 +51,16 @@ search: app: build: . volumes: - - .:/opt/Telemeta - - /var/log/uwsgi + - ./app/:/opt/app volumes_from: - - static - - home - command: /bin/sh /opt/Telemeta/examples/deploy/start_app.sh + - media + command: /bin/sh deploy/start_app.sh ports: - "9000:9000" expose: - "8000" links: - - rabbitmq + - broker - db - search @@ -75,10 +68,9 @@ worker: build: . volumes_from: - app - - home - command: /bin/sh /opt/Telemeta/examples/deploy/celery_app.sh + command: /bin/sh deploy/celery_app.sh links: - - rabbitmq + - broker - db nginx: @@ -86,10 +78,9 @@ nginx: ports: - "8000:80" volumes: - - ./examples/deploy/nginx-app.conf:/etc/nginx/conf.d/default.conf - - /var/log/nginx + - ./app/deploy/nginx-app.conf:/etc/nginx/conf.d/default.conf + - ./log/:/var/log/nginx volumes_from: - - static - - home + - media links: - app diff --git a/examples/sandbox/wsgi.py b/examples/sandbox/wsgi.py deleted file mode 100644 index c3642fec..00000000 --- a/examples/sandbox/wsgi.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/python2.5 -# -*- coding: utf-8 -*- - -import os -import sys - -here = os.path.dirname(__file__) -sys.path.append(here) - -os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' - -import django.core.handlers.wsgi -application = django.core.handlers.wsgi.WSGIHandler() - diff --git a/telemeta/locale b/telemeta/locale index 4534a3d4..91973b13 160000 --- a/telemeta/locale +++ b/telemeta/locale @@ -1 +1 @@ -Subproject commit 4534a3d47e7909554637e87a637b1959db277941 +Subproject commit 91973b13f9dc9405052727c0c525d342dee15562 diff --git a/telemeta/pages b/telemeta/pages index 771dfcc5..f8324093 160000 --- a/telemeta/pages +++ b/telemeta/pages @@ -1 +1 @@ -Subproject commit 771dfcc58e26f43a507c3bc48fcb5ddde55ca0b1 +Subproject commit f8324093174d077b674ac2c52eb0db6eaf815ab5 diff --git a/telemeta/templates/telemeta/collection_detail.html b/telemeta/templates/telemeta/collection_detail.html index 7184d11e..361e456d 100644 --- a/telemeta/templates/telemeta/collection_detail.html +++ b/telemeta/templates/telemeta/collection_detail.html @@ -100,10 +100,10 @@
{% trans "Document status" %}
{{ collection.document_status }}
{% if collection.description %} -
{% trans "Description" %}
-
{{ collection.description|html_line_break|safe }}
- {% endif %} - {% dl_field collection "recording_context" %} +
{% trans "Description" %}
+
{{ collection.description|html_line_break|safe }}
+ {% endif %} + {% dl_field collection "recording_context" %}
{% trans "Recording period" %}
{% if collection.recorded_from_year %}{{ collection.recorded_from_year }}{% endif %}{% if collection.recorded_from_year and collection.recorded_to_year %} - {% endif %}{% if collection.recorded_to_year %}{{ collection.recorded_to_year}}{% endif %}
{% if '_E_' in collection.public_id %} @@ -270,4 +270,3 @@ {% else %}

No such collection

{% endif %} - -- 2.39.5