From 1a7c098fd22a8d899eb607d4521414727837078d Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 5 Dec 2016 15:21:26 +0100 Subject: [PATCH] Add all front tools to build it from app container, update doc --- Dockerfile | 25 +++++++++++++++++----- bin/front_build.sh | 3 +++ bin/upgrade.sh | 5 +---- debian-requirements.txt | 5 +++-- doc/src/architecture.rst | 24 ++++++++++++--------- doc/src/index.rst | 3 +-- doc/src/install.rst | 45 ++++++---------------------------------- doc/src/maintenance.rst | 27 ++++++++++++++---------- doc/src/overview.rst | 2 +- doc/src/production.rst | 19 ----------------- doc/src/related.rst | 19 ----------------- etc/apt/sources.list | 6 ++++++ 12 files changed, 71 insertions(+), 112 deletions(-) create mode 100644 bin/front_build.sh delete mode 100644 doc/src/production.rst delete mode 100644 doc/src/related.rst diff --git a/Dockerfile b/Dockerfile index b3444611..559e1249 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,13 @@ ENV PYTHONUNBUFFERED 1 RUN mkdir /srv/app RUN mkdir /srv/lib -WORKDIR /srv/app +WORKDIR /srv RUN apt-get update && apt-get install apt-transport-https COPY etc/apt/sources.list /etc/apt/ -COPY debian-requirements.txt /srv/app/ +COPY debian-requirements.txt /srv RUN apt-get update && \ - DEBIAN_PACKAGES=$(egrep -v "^\s*(#|$)" debian-requirements.txt) && \ + DEBIAN_PACKAGES=$(egrep -v "^\s*(#|$)" /srv/debian-requirements.txt) && \ apt-get install -y --force-yes $DEBIAN_PACKAGES && \ echo fr_FR.UTF-8 UTF-8 >> /etc/locale.gen && \ locale-gen && \ @@ -20,10 +20,25 @@ ENV LANG fr_FR.UTF-8 ENV LANGUAGE fr_FR:fr ENV LC_ALL fr_FR.UTF-8 -ADD requirements.txt /srv/app/ +COPY requirements.txt /srv RUN pip install -r requirements.txt -ADD requirements-dev.txt /srv/app/ +COPY requirements-dev.txt /srv RUN pip install -r requirements-dev.txt --src /srv/lib +COPY package.json /srv +RUN npm install + +COPY Gemfile /srv +RUN gem install bundler +RUN bundle install + +COPY bower.json /srv RUN npm install -g bower +RUN bower --allow-root install + +COPY gulpfile.js /srv +RUN npm install -g gulp +RUN gulp build + +WORKDIR /srv/app diff --git a/bin/front_build.sh b/bin/front_build.sh new file mode 100644 index 00000000..26da3575 --- /dev/null +++ b/bin/front_build.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +docker-compose run app bash -c "cd /srv && bower install && gulp build" diff --git a/bin/upgrade.sh b/bin/upgrade.sh index f9870000..46fa0fb2 100755 --- a/bin/upgrade.sh +++ b/bin/upgrade.sh @@ -1,12 +1,9 @@ #!/bin/sh -# Use this script to update a dev/prod server - git pull git submodule foreach git pull docker-compose run app python /srv/app/manage.py migrate # docker-compose run app python /srv/app/manage.py update_translation_fields -bower install -gulp build +docker-compose run app bash -c "cd /srv && bower install && gulp build" docker-compose run app python /srv/app/manage.py collectstatic --noinput docker-compose run app bash /srv/doc/build.sh diff --git a/debian-requirements.txt b/debian-requirements.txt index 04c6b888..aff02e3e 100644 --- a/debian-requirements.txt +++ b/debian-requirements.txt @@ -3,9 +3,10 @@ wget bzip2 build-essential netcat -npm +nodejs locales pandoc -nodejs-legacy vim python-sphinx +ruby +ruby-dev diff --git a/doc/src/architecture.rst b/doc/src/architecture.rst index 3435e398..cd884fd8 100644 --- a/doc/src/architecture.rst +++ b/doc/src/architecture.rst @@ -46,25 +46,25 @@ Paths uwsgi logs (not versioned) - bower.json \ - javascript dependencies (cf `Front`_ section) + javascript dependencies - debian-requirements.txt \ - used by docker to install debian packages (cf `In case of broken app`_ section) + used by docker to install debian packages - docker-compose.yml \ - description of all docker containers. This file is used by command "docker-compose" (cf `In case of broken app`_ section) + configuration file for docker containers used by docker-compose - Dockerfile \ - instructions to build app image (cf `In case of broken app`_ section) + instructions to build the app image - Gemfile \ - gem dependecies for ruby. For our case, it will install _Sass and _Compass. (cf `Front`_ section) + gem dependecies for ruby. For our case, it will install _Sass and _Compass. - gulpfile.js \ - script to compile all css, js files (cf `Front`_ section) + script to compile all CSS and JS files - install.py \ - cf section 'Install as a daemon' (cf `Install as a daemon`_ section) + daemon and init boot script installer (Linux only) - package.json \ - gulp dependencies when running "gulp install" (cf `Front`_ section) + gulp dependencies when running "gulp install" - requirements-dev.txt \ - application package in dev version (cf `In case of broken app`_ section) + application package in dev version - requirements.txt \ - application package (cf `In case of broken app`_ section) + application package @@ -93,3 +93,7 @@ Main modules embed in app/organization represent projects related to a team or a person - shop \ manage product from prestashop (softwares and subscriptions), using _Cartridge + + +.. _Compass : http://compass-style.org/ +.. _Sass: http://sass-lang.com/ diff --git a/doc/src/index.rst b/doc/src/index.rst index efb8c4b4..027cfaf2 100644 --- a/doc/src/index.rst +++ b/doc/src/index.rst @@ -16,10 +16,9 @@ Contents: architecture install development - production maintenance copyright - licence + license Indices and tables ================== diff --git a/doc/src/install.rst b/doc/src/install.rst index a7088c2e..f35d8b2f 100644 --- a/doc/src/install.rst +++ b/doc/src/install.rst @@ -14,55 +14,24 @@ Then run these commands:: git clone --recursive https://github.com/Ircam-RnD/mezzanine-organization.git -Compile static files -+++++++++++++++++++++ - -Gulp_ allow to compile scss to css, concatenate js files and has a watcher, who do this tasks on file change. -Gulp_ require NodeJS_ installed on your computer to work. - -1. Install gulp globally:: - - sudo npm install --g gulp - -2. Install bower globally:: - - sudo npm install -g bower - -3. Install gulp dependencies:: - - npm install - -4. Install ruby dependencies:: - - sudo apt install ruby - sudo gem install bundler - bundle install - -5. Build:: - - bower install - gulp build - - -/!\ If you have an issue with ffi module, try to install dev package from ruby:: - - apt-get install ruby-dev - - Start +++++ +Our docker composition already bundles some powerful containers and bleeding edge frameworks like: Nginx, MySQL, Redis, Celery, Django and Python. It thus provides a safe and continuous way to deploy your project from an early development stage to a massive production environment. + For a production environment setup:: cd mezzanine-organization docker-compose up -which builds, (re)creates, starts, and attaches to containers. +which builds, (re)creates, starts, and attaches all containers. Then browse the app at http://localhost:8020/ On MacOS or Windows, we need to replace 'localhost' by the IP given by the docker terminal. +.. warning :: Before any serious production usecase, you *must* modify all the passwords and secret keys in the configuration files of the sandbox. + Daemonize +++++++++++ @@ -79,7 +48,7 @@ options:: --systemd : use systemd --composition_file : the path of the YAML composition file to use (optional) -This will install a init script in /etc/init.d. For example, if your app directory is named `mezzanine-organization`, `/etc/init.d/mezzanine-organization` becomes the init script for the OS booting procedure and for you if you need to start the daemon by hand:: +This will install a init script in /etc/init.d. For example, if your app directory is named `mezzanine-organization` then `/etc/init.d/mezzanine-organization` becomes the init script for the OS booting procedure and for you if you need to start the daemon by hand:: sudo /etc/init.d/mezzanine-organization start @@ -116,5 +85,3 @@ Prod .. _Gulp: http://gulpjs.com/ .. _Mezzanine-Agenda : https://github.com/jpells/mezzanine-agenda .. _Cartridge : https://github.com/stephenmcd/cartridge/ -.. _Sass: http://sass-lang.com/ -.. _Compass : http://compass-style.org/ diff --git a/doc/src/maintenance.rst b/doc/src/maintenance.rst index 9c7b038a..ce31678a 100644 --- a/doc/src/maintenance.rst +++ b/doc/src/maintenance.rst @@ -11,24 +11,29 @@ Log - var/log/uwsgi/app.log \ uwsgi log of the app -Upgrade -+++++++++ -Upgrade application, all dependencies, data from master branch and also recompile assets:: +Backup & restore ++++++++++++++++++ - bin/upgrade.sh +To backup the database and all the media, this will push all of them to the var submodule own repository:: + bin/push.sh -Backup & restore DB -++++++++++++++++++++ +.. warning :: use this ONLY from the **production** environment! -To backup the database and push it to the var (data) own repository (**only** prod!):: +To restore the backuped the database, all the media and rebuild front ():: - bin/push.sh + bin/pull.sh -To restore the backuped database and rebuild front:: +.. warning :: use this ONLY from the **development** environment! - bin/pull.sh + +Upgrade ++++++++++ + +Upgrade application, all dependencies, data from master branch and also recompile assets:: + + bin/upgrade.sh Repair @@ -50,7 +55,7 @@ If the containers are still broken, try to delete exisiting containers (this wil docker-compose rm docker-compose up -In case you have installed the init script to run the app as a daemon (cf. section "Install as a daemon"), you can use it to restart the app: +In case you have installed the init script to run the app as a daemon (cf. section "Daemonize"), you can use it to restart the app: /etc/init.d/mezzanine-organization restart diff --git a/doc/src/overview.rst b/doc/src/overview.rst index 0c90c52a..6fab3047 100644 --- a/doc/src/overview.rst +++ b/doc/src/overview.rst @@ -4,7 +4,7 @@ Mezzanine-organization This application is a CMS for organizations with workflows -It is based on Mezzanine and Django. +It is based on Mezzanine_ and Django_. Use cases ========== diff --git a/doc/src/production.rst b/doc/src/production.rst deleted file mode 100644 index a6b77a18..00000000 --- a/doc/src/production.rst +++ /dev/null @@ -1,19 +0,0 @@ - -Production -=========== - -Deploying ---------- - -Our docker composition already bundles some powerful containers and bleeding edge frameworks like: Nginx, MySQL, Redis, Celery, Django and Python. It thus provides a safe and continuous way to deploy your project from an early development stage to a massive production environment. - -.. warning :: Before any serious production usecase, you *must* modify all the passwords and secret keys in the configuration files of the sandbox. - -The best - -Scaling --------- - -Thanks to Celery, each TimeSide worker of the server will process each task asynchronously over independant threads so that you can load all the cores of your CPU. - -To scale it up through your cluster, Docker provides some nice tools for orchestrating it very easily: `Machine and Swarm `_. diff --git a/doc/src/related.rst b/doc/src/related.rst deleted file mode 100644 index cada6a11..00000000 --- a/doc/src/related.rst +++ /dev/null @@ -1,19 +0,0 @@ - -Sponsors and Partners -===================== - -* `Parisson `_ -* `CNRS `_ (National Center of Science Research, France) -* `Huma-Num `_ (big data equipment for digital humanities, ex TGE Adonis) -* `CREM `_ (french National Center of Ethomusicology Research, France) -* `Université Pierre et Marie Curie `_ (UPMC Paris, France) -* `ANR `_ (CONTINT 2012 project : DIADEMS) -* `MNHN `_ : Museum National d'Histoire Naturelle (Paris, France) - - -Related projects -================= - -* `Telemeta `__ : open web audio platform -* `Sound archives `_ of the CNRS, CREM and the "Musée de l'Homme" in Paris, France. -* The `DIADEMS project `_ sponsored by the ANR. diff --git a/etc/apt/sources.list b/etc/apt/sources.list index 0237e678..5d054102 100644 --- a/etc/apt/sources.list +++ b/etc/apt/sources.list @@ -6,3 +6,9 @@ deb-src http://security.debian.org/ jessie/updates main deb http://mirrors.ircam.fr/pub/debian/ jessie-updates main deb-src http://mirrors.ircam.fr/pub/debian/ jessie-updates main + +deb http://mirrors.ircam.fr/pub/debian/ jessie-backports main contrib non-free +deb-src http://mirrors.ircam.fr/pub/debian/ jessie-backports main contrib non-free + +deb https://deb.nodesource.com/node_6.x jessie main +deb-src https://deb.nodesource.com/node_6.x jessie main -- 2.39.5