From afa2fb8956942338791a606b9ce67a35789dc3e7 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 20 Oct 2016 13:08:52 +0200 Subject: [PATCH] Use eve and presta in autonous compositions, add submodule init on pull --- app/local_settings.py | 21 +++++----- .../organization-sync-prestashop-events.py | 3 +- docker-compose.yml | 29 +------------- env/eve.yml | 19 +++++++--- env/prestashop.yml | 38 +++++++++++++++++++ lib/mezzanine-agenda | 2 +- scripts/pull.sh | 3 +- 7 files changed, 68 insertions(+), 47 deletions(-) create mode 100644 env/prestashop.yml diff --git a/app/local_settings.py b/app/local_settings.py index 1377d2ef..0fd91cbf 100644 --- a/app/local_settings.py +++ b/app/local_settings.py @@ -19,26 +19,27 @@ DATABASES = { 'HOST': 'db', 'PORT': '5432', }, - 'eve': { +} + +if os.environ.get('EVEDB_ENV_POSTGRES_PASSWORD'): + DATABASES['eve'] = { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'eve', 'USER': 'eve', - 'PASSWORD': "q2nqzt0WGnwWé,256", + 'PASSWORD': os.environ.get('EVEDB_ENV_POSTGRES_PASSWORD'), 'HOST': 'evedb', 'PORT': '5432', - }, - 'prestashop': { + } + +if os.environ.get('PRESTADB_ENV_MYSQL_PASSWORD'): + DATABASES['prestashop'] = { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'USER': 'ircam_shops', # Not used with sqlite3. - 'PASSWORD': 'pUmt97e4MgR9EP4knyWea0n', # Not used with sqlite3. + 'PASSWORD': os.environ.get('PRESTADB_ENV_MYSQL_PASSWORD'), # Not used with sqlite3. 'NAME': 'ircam_shops', 'HOST': 'prestadb', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '3306', # Set to empty string for default. Not used with sqlite3. - } - -} - -# DATABASE_ROUTERS = ['eve.routers.EveRouter',] + } # EXTENSIONS AND FORMATS diff --git a/app/organization/agenda/management/commands/organization-sync-prestashop-events.py b/app/organization/agenda/management/commands/organization-sync-prestashop-events.py index bc781bca..c2984f81 100644 --- a/app/organization/agenda/management/commands/organization-sync-prestashop-events.py +++ b/app/organization/agenda/management/commands/organization-sync-prestashop-events.py @@ -34,7 +34,8 @@ class Command(BaseCommand): event.delete() def handle(self, *args, **kwargs): - self.cleanup() + # !! NOT FOR PROD !! + # self.cleanup() products = [] category_lang_name = kwargs.get('category_lang_name') diff --git a/docker-compose.yml b/docker-compose.yml index 0d6ac496..66e895aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,31 +38,6 @@ db: environment: - POSTGRES_PASSWORD=hyRob0otlaz4 -prestadb: - image: mariadb - volumes_from: - - data - volumes: - - ./scripts/:/srv/scripts - - ./data/external/prestashop/mysql/:/var/lib/mysql - environment: - - MYSQL_ROOT_PASSWORD=mysecretpassword - - MYSQL_DATABASE=ircam_shops - - MYSQL_USER=ircam_shops - - MYSQL_PASSWORD=pUmt97e4MgR9EP4knyWea0n - -evedb: - image: postgres:9.5 - volumes_from: - - data - volumes: - - ./scripts/:/srv/scripts - - ./data/external/eve/postgresql/data/:/var/lib/postgresql/data - environment: - - POSTGRES_USER=eve - - POSTGRES_DB=eve - - POSTGRES_PASSWORD=q2nqzt0WGnwWé,256 - app: build: . command: /bin/bash scripts/app.sh @@ -70,7 +45,7 @@ app: - ./app/:/srv/app - ./lib/grappelli-safe/:/srv/lib/grappelli-safe - ./lib/mezzanine-agenda/:/srv/lib/mezzanine-agenda - - ./lib/mezzanine/:/srv/lib/mezzanine + # - ./lib/mezzanine/:/srv/lib/mezzanine - ./lib/django-eve/:/srv/lib/django-eve - ./lib/django-prestashop/:/srv/lib/django-prestashop volumes_from: @@ -79,8 +54,6 @@ app: - "8000" links: - db - - prestadb - - evedb environment: - DEBUG=False diff --git a/env/eve.yml b/env/eve.yml index 8190bff5..3bce54cc 100644 --- a/env/eve.yml +++ b/env/eve.yml @@ -1,4 +1,4 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- # # Copyright (c) 2015 Guillaume Pellerin @@ -18,13 +18,20 @@ # Authors: # Guillaume Pellerin + evedb: - image: postgres - volumes: - - ./data/var/lib/postgresql/eve/data/:/var/lib/postgresql/data + image: postgres:9.5 volumes_from: - data + volumes: + - ./scripts/:/srv/scripts + - ./data/external/eve/postgresql/data/:/var/lib/postgresql/data environment: - - POSTGRES_PASSWORD=mysecretpassword - - POSTGRES_USER=postgres + - POSTGRES_USER=eve - POSTGRES_DB=eve + - POSTGRES_PASSWORD=q2nqzt0WGnwWé,256 + +app: + links: + - db + - evedb diff --git a/env/prestashop.yml b/env/prestashop.yml new file mode 100644 index 00000000..d371047d --- /dev/null +++ b/env/prestashop.yml @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2015 Guillaume Pellerin + +# Manifeste is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. + +# Manifeste is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Manifeste. If not, see . + +# Authors: +# Guillaume Pellerin + + +prestadb: + image: mariadb + volumes_from: + - data + volumes: + - ./scripts/:/srv/scripts + - ./data/external/prestashop/mysql/:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=mysecretpassword + - MYSQL_DATABASE=ircam_shops + - MYSQL_USER=ircam_shops + - MYSQL_PASSWORD=pUmt97e4MgR9EP4knyWea0n + +app: + links: + - db + - prestadb diff --git a/lib/mezzanine-agenda b/lib/mezzanine-agenda index 2c6e15e6..d975b0c2 160000 --- a/lib/mezzanine-agenda +++ b/lib/mezzanine-agenda @@ -1 +1 @@ -Subproject commit 2c6e15e6a66c507e05ab803016acd4d250f4d2dd +Subproject commit d975b0c2dde27b3cedc93016f5aaafd345d35d60 diff --git a/scripts/pull.sh b/scripts/pull.sh index bd4b4f44..a6e290fe 100755 --- a/scripts/pull.sh +++ b/scripts/pull.sh @@ -3,5 +3,6 @@ sudo chown -R $USER data/media sudo chown -R $USER data/backup git pull -git submodule foreach git pull origin master +git submodule update --init --recursive +git submodule foreach git pull docker-compose run db /srv/scripts/restore_db.sh -- 2.39.5