# HG changeset patch # User ymh # Date 1487633393 -3600 # Node ID 3a80a07f13000e3854122142a3c91fcd3f68344e # Parent cedbb7804a7bcbc3a660fff8ffd53d8b479ffdd6 add dev env with docker compose diff -r cedbb7804a7b -r 3a80a07f1300 .hgignore --- a/.hgignore Wed Jan 25 22:21:48 2017 +0100 +++ b/.hgignore Tue Feb 21 00:29:53 2017 +0100 @@ -32,3 +32,4 @@ syntax: regexp ^web/static/media/metadatacomposer$ ^src/.vscode +^dev/data diff -r cedbb7804a7b -r 3a80a07f1300 dev/docker-compose.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/docker-compose.yml Tue Feb 21 00:29:53 2017 +0100 @@ -0,0 +1,25 @@ +version: '3' +services: + db: + image: postgres + volumes: + - ./data/db:/var/lib/postgresql/data + es: + image: elasticsearch:alpine + volumes: + - ./data/es:/usr/share/elasticsearch/data + web: + build: + context: ../ + dockerfile: dev/web/Dockerfile + volumes: + - ../:/code/platform_web + - ../../platform/src/ldt:/code/platform + - ../../hashcut/src:/code/hashcut + - ../../metadatacomposer/src:/code/metadatacomposer + ports: + - "8000:8000" + depends_on: + - db + - es + \ No newline at end of file diff -r cedbb7804a7b -r 3a80a07f1300 dev/web/Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/web/Dockerfile Tue Feb 21 00:29:53 2017 +0100 @@ -0,0 +1,14 @@ +FROM python:2.7 +ENV PYTHONUNBUFFERED 1 +RUN mkdir -p /code +RUN mkdir /var/virtualenv +RUN mkdir /tmp/virtualenv +ADD virtualenv/ /tmp/virtualenv/ +WORKDIR /tmp/virtualenv/web +RUN python create_python_env.py +RUN python project-boot.py --no-site-packages --clear --ignore-packages=MYSQL --type-install=local /var/virtualenv/ldt +ENV PYTHONPATH=/code/platform/:/code/platform_web/src/:/code/hashcut:/code/metadatacomposer +ENV DJANGO_SETTINGS_MODULE=ldtplatform.settings_docker +WORKDIR /code/platform_web/src +ENTRYPOINT ["/var/virtualenv/ldt/bin/python", "manage.py"] +CMD ["runserver","0.0.0.0:8000"] diff -r cedbb7804a7b -r 3a80a07f1300 src/ldtplatform/config_docker.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldtplatform/config_docker.py Tue Feb 21 00:29:53 2017 +0100 @@ -0,0 +1,167 @@ +# -*- coding: utf-8 -*- +import os, logging + +SITE_ID = 1 + + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)).rstrip("/")+"/" +BASE_URL = '/' +PLATFORM_BASE_URL = '/' +LOGIN_REDIRECT_URL = '/ldt' +LOGOUT_REDIRECT_URL = '/ldt' +WEB_URL = '' +WEB_AUTH = [] # example [{'REGEX': 'localhost/~ymh/platform', 'NAME': 'ymh', 'PASSWORD': 'ymh'}] +STATIC_URL = BASE_URL + 'static/site/' + + +STREAM_SRC_PREFIX = "" + +BASE_STATIC_URL = WEB_URL + BASE_URL + 'static/' +BASE_STATIC_ROOT = os.path.abspath(BASE_DIR + "../../web/static/").rstrip("/")+"/" + +STREAM_URL = BASE_STATIC_URL + "/content/" + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = BASE_STATIC_ROOT + "media/" + + +# Absolute path to the directory that static files (js, css, swf...) +# DO NOT forget to do command line ./manage.py collectstatic to gather static media into the web/static folder +STATIC_ROOT = BASE_STATIC_ROOT + "site/" + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'vu6choo7ahk4loaj4lie1thiegh0cae4quohtohnee7ooshaN1' + +# PATH to the ffmpeg executable, used to know automatically the media file duration +FFMPEG_PATH = "" + + +CONTENT_ROOT = BASE_STATIC_ROOT + "content/" + +# PATH where uploaded media are put. +STREAM_PATH = CONTENT_ROOT + +LDT_MEDIA_PREFIX = STATIC_URL + 'ldt/' + + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'postgres', # Or path to database file if using sqlite3. + 'USER': 'postgres', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': 'db', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', + } +} + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/log.txt")) +LOG_LEVEL = logging.DEBUG +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'formatters' : { + 'simple' : { + 'format': "%(asctime)s - %(levelname)s : %(message)s", + }, + 'semi-verbose': { + 'format': '%(levelname)s %(asctime)s %(module)s %(message)s' + }, + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + }, + 'stream_to_console': { + 'level': LOG_LEVEL, + 'class': 'logging.StreamHandler' + }, + 'file': { + 'level': LOG_LEVEL, + 'class': 'logging.FileHandler', + 'filename': LOG_FILE, + 'formatter': 'semi-verbose', + }, + }, + 'loggers': { + 'django.db.backends':{ + 'handlers': ['file'], + 'level': LOG_LEVEL, + 'propagate': True, + }, + 'django.request': { + 'handlers': ['file'], + 'level': LOG_LEVEL, + 'propagate': True, + }, + 'ldt': { + 'handlers': ['file'], + 'level': LOG_LEVEL, + 'propagate': True, + }, + } +} + + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + +GOOGLE_ANALYTICS_CODE = '%(google_analytics_code)s' + +EMAIL_USE_TLS = False +EMAIL_HOST = '' +EMAIL_HOST_USER = '' +EMAIL_HOST_PASSWORD = '' +EMAIL_PORT = 25 + +ACCOUNT_ACTIVATION_DAYS = 7 +REGISTRATION_OPEN = False + +LDT_MAX_SEARCH_NUMBER = 50 +LDT_MAX_FRAGMENT_PER_SEARCH = 3 +LDT_RESULTS_PER_PAGE = 1 +LDT_JSON_DEFAULT_INDENT = 0 +LDT_MAX_CONTENTS_PER_PAGE = 5 +LDT_MAX_PROJECTS_PER_PAGE = 5 +LDT_FRONT_MEDIA_PER_PAGE = 9 + +EMPTY_MEDIA_EXTERNALID = None + +AUTO_INDEX_AFTER_SAVE = True + +FORBIDDEN_STREAM_URL = "%(forbidden_stream_url)s" + +AUDIO_RECORD_URL = "%(audio_record_url)s" + +FRONT_TAG_LIST = [u"Enmi 2011", u"film", u"conférence"] + +HAYSTACK_CONNECTIONS = { + 'default': { + #for elasticsearch use ldt.indexation.backends.elasticsearch_backend.ElasticsearchSearchEngine + 'ENGINE': 'ldt.indexation.backends.elasticsearch_backend.ElasticsearchSearchEngine', + 'URL': 'es:9200/', + 'INDEX_NAME': 'ldt', + }, +} + +LDT_INDEXATION_INSERT_BATCH_SIZE = 5000 \ No newline at end of file diff -r cedbb7804a7b -r 3a80a07f1300 src/ldtplatform/settings_docker.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldtplatform/settings_docker.py Tue Feb 21 00:29:53 2017 +0100 @@ -0,0 +1,272 @@ +# -*- coding: utf-8 -*- +#@PydevCodeAnalysisIgnore +import os.path +import ldtplatform +# Django settings for project. + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': '', # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'UTC' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'fr-fr' + +ugettext = lambda s: s + +LANGUAGES = ( + ('fr', ugettext('French')), + ('en', ugettext('English')), + ('ja', ugettext('Japanese')), +) + + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +#MEDIA_ROOT = '' + +# Root of static files used by each app, generated by code or uploaded by users +#STATIC_URL = '/static/' + +# 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). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +#MEDIA_URL = '' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". + + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 't^lii5_z@tho$%6t&b#dm#t9nz$$ylyclxvkdiyqbl+(dnt(ma' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.cache.UpdateCacheMiddleware', + 'corsheaders.middleware.CorsMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.cache.FetchFromCacheMiddleware', + 'django.middleware.gzip.GZipMiddleware', + 'ldt.ldt_utils.middleware.swfupload.SWFUploadMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + #'django.middleware.locale.LocaleMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + #'django_openid_consumer.middleware.OpenIDMiddleware', + 'ldt.ldt_utils.middleware.userprofile.LanguageMiddleware', + 'ldt.security.middleware.SecurityMiddleware', +) + +TEMPLATE_CONTEXT_PROCESSORS = ( + "django.core.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.core.context_processors.debug", + "django.core.context_processors.i18n", + "django.core.context_processors.media", + "django.core.context_processors.static", + "ldt.utils.context_processors.ldt_context", +) + + +ROOT_URLCONF = 'ldtplatform.urls' + +TEMPLATE_DIRS = ( + # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. + os.path.join(os.path.basename(__file__), 'templates'), + os.path.join(os.path.dirname(__file__), 'templates'), +) + +FIXTURES_DIRS = ( + os.path.join(os.path.basename(__file__), 'fixtures'), +) + +INSTALLED_APPS = ( + 'django_extensions', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.admin', + 'django.contrib.staticfiles', + 'haystack', + 'corsheaders', + 'tastypie', + 'guardian', + 'taggit', + 'taggit_templatetags', + 'registration', + 'oauth_provider', + #'django_openid_consumer', + 'social.apps.django_app.default', + 'sorl.thumbnail', + 'ldt', + 'ldt.core', + 'ldt.security', + 'ldt.user', + 'ldt.ldt_utils', + 'ldt.text', + 'ldt.management', + 'ldt.indexation', + 'hashcut', + 'chunked_uploads', + 'ldtplatform', + 'metadatacomposer', +) + + +#AUTH_PROFILE_MODULE = 'user.UserProfile' +AUTH_USER_MODEL = 'user.LdtUser' +#INITIAL_CUSTOM_USER_MIGRATION = "0009_rename_auth_user_to_user_ldt_user" + +DECOUPAGE_BLACKLIST = ( + "de_PPP", +) + +ZIP_BLACKLIST = ( + "__MACOSX", +) + +AUTHENTICATION_BACKENDS = ( + 'guardian.backends.ObjectPermissionBackend', + 'django.contrib.auth.backends.ModelBackend', +) +#SOCIAL_AUTH_IMPORT_BACKENDS = ( +# 'myproy.social_auth_extra_services', +#) + +ACCOUNT_ACTIVATION_DAYS = 7 + +LDT_MAX_SEARCH_NUMBER = 50 +LDT_JSON_DEFAULT_INDENT = 0 +LDT_MAX_FRAGMENT_PER_SEARCH = 3 +LDT_RESULTS_PER_PAGE = 10 +LDT_MAX_CONTENTS_PER_PAGE = 10 +LDT_MAX_PROJECTS_PER_PAGE = 10 +LDT_FRONT_MEDIA_PER_PAGE = 9 +LDT_FRONT_PROJECTS_PER_PAGE = 12 +LDT_MEDIA_IN_RESULTS_PAGE = 6 + +OAUTH_PROVIDER_KEY_SIZE = 32 +OAUTH_PROVIDER_SECRET_SIZE = 32 +OAUTH_PROVIDER_VERIFIER_SIZE = 10 +OAUTH_PROVIDER_CONSUMER_KEY_SIZE = 256 +OAUTH_AUTHORIZE_VIEW = 'oauth_provider.views.fake_authorize_view' +OAUTH_CALLBACK_VIEW = 'oauth_provider.views.fake_callback_view' +TEST_WEBSERVER_ADDRPORT = "127.0.0.1:8888" + + +SOCIAL_AUTH_COMPLETE_URL_NAME = 'complete' +SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'associate_complete' + +AUTO_INDEX_AFTER_SAVE = True + +ANONYMOUS_USER_ID = -1 + +WEB_VERSION = ldtplatform.get_version() + +DIVISIONS_FOR_STAT_ANNOTATION = 64 + +FRONT_TAG_LIST = [] + +DEFAULT_CONTENT_ICON = "thumbnails/contents/content_default_icon.png" +DEFAULT_PROJECT_ICON = "thumbnails/projects/project_default_icon.png" +DEFAULT_USER_ICON = "thumbnails/users/user_default_icon.png" +DEFAULT_GROUP_ICON = "thumbnails/groups/group_default_icon.png" +PROFILE_IMG_MAX_SIZE = 1000000 + +USE_GROUP_PERMISSIONS = ['Project', 'Content', 'Media'] +FORBIDDEN_STREAM_URL = "rtmp://media.iri.centrepompidou.fr/ddc_player/mp4:video/forbidden_stream.mp4?old_path=" +PUBLIC_GROUP_NAME = 'everyone' +MAX_USERS_SEARCH = 20 + +SYNTAX = { + '++' : 'OK', + '--' : 'KO', + '==' : 'REF', + '??' : 'Q' + } + +EXTERNAL_STREAM_SRC = ['youtube.com', 'dailymotion.com', 'vimeo.com'] + +HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', + }, +} +HAYSTACK_SIGNAL_PROCESSOR = 'ldt.indexation.signals.LdtSignalProcessor' + +#Cors headers for API +CORS_ORIGIN_ALLOW_ALL = True + +from config_docker import * + +if not "SRC_BASE_URL" in locals(): + SRC_BASE_URL = BASE_URL + __name__.split('.')[0] + '/' + +if not "LOGIN_URL" in locals(): + LOGIN_URL = SRC_BASE_URL + 'accounts/login/' +if not "LOGOUT_URL" in locals(): + LOGOUT_URL = SRC_BASE_URL + 'accounts/disconnect/' +if not "LOGIN_REDIRECT_URL" in locals(): + LOGIN_REDIRECT_URL = SRC_BASE_URL + 'ldt/' +if not "LOGOUT_REDIRECT_URL" in locals(): + LOGOUT_REDIRECT_URL = SRC_BASE_URL + 'accounts/login' +if not "PROFILE_REDIRECT_URL" in locals(): + PROFILE_REDIRECT_URL = SRC_BASE_URL + 'auth_accounts/create/profile' + +if not "LOGIN_ERROR_URL" in locals(): + LOGIN_ERROR_URL = SRC_BASE_URL + 'accounts/login' + +# URL that handles the media served from MEDIA_ROOT. +if not "MEDIA_URL" in locals(): + MEDIA_URL = BASE_URL + 'static/media/' + +if not "CORS_URLS_REGEX" in locals(): + CORS_URLS_REGEX = r"^" + BASE_URL + 'ldtplatform/api/.*$' + +#forced settings +MAX_TAG_LENGTH = 255 +FORCE_LOWERCASE_TAGS = True + +TAGGIT_TAGCLOUD_MIN = 1.0 +TAGGIT_TAGCLOUD_MAX = 12.0 diff -r cedbb7804a7b -r 3a80a07f1300 virtualenv/res/lib/lib_create_env.py --- a/virtualenv/res/lib/lib_create_env.py Wed Jan 25 22:21:48 2017 +0100 +++ b/virtualenv/res/lib/lib_create_env.py Tue Feb 21 00:29:53 2017 +0100 @@ -39,7 +39,7 @@ 'SETUPTOOLS_HG' : {'setup':'setuptools_hg', 'url':'https://bitbucket.org/jezdez/setuptools_hg/get/v0.4.tar.gz', 'local': 'setuptools_hg-0.4.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, # dependencies for Tastypie : mimeparse>=0.1.3, python-dateutil>=2.1, lxml, PyYAML (not necessary but we never know), python-digest, defusedxml 'MIMEPARSE' : {'setup':'mimeparse', 'url':'http://pypi.python.org/packages/source/m/mimeparse/mimeparse-0.1.3.tar.gz', 'local': 'mimeparse-0.1.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, - 'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz', 'local': 'six-1.9.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz', 'local': 'six-1.10.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'DATEUTIL' : {'setup':'python-dateutil', 'url':'https://github.com/dateutil/dateutil/archive/2.4.2.tar.gz', 'local': 'dateutil-2.4.2.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'PYYAML' : {'setup':'pyyaml', 'url':'http://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz', 'local': 'PyYAML-3.11.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'PYTHON-DIGEST' : {'setup':'python-digest', 'url':'http://pypi.python.org/packages/source/p/python-digest/python-digest-1.7.tar.gz', 'local': 'python-digest-1.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, diff -r cedbb7804a7b -r 3a80a07f1300 virtualenv/res/src/six-1.10.0.tar.gz Binary file virtualenv/res/src/six-1.10.0.tar.gz has changed diff -r cedbb7804a7b -r 3a80a07f1300 virtualenv/res/src/six-1.9.0.tar.gz Binary file virtualenv/res/src/six-1.9.0.tar.gz has changed diff -r cedbb7804a7b -r 3a80a07f1300 virtualenv/web/res/requirements.txt --- a/virtualenv/web/res/requirements.txt Wed Jan 25 22:21:48 2017 +0100 +++ b/virtualenv/web/res/requirements.txt Tue Feb 21 00:29:53 2017 +0100 @@ -31,7 +31,7 @@ requests-oauthlib==0.5.0 setuptools-hg==0.4 simplejson==3.6.5 -six==1.9.0 +six==1.10.0 sorl-thumbnail==12.3 urllib3==1.14 Whoosh==2.7.0