From 1fca66d326ee452cf71b800b0d1887d1678dbef4 Mon Sep 17 00:00:00 2001 From: Xavier Rousset Date: Tue, 11 Jun 2019 16:44:39 +0200 Subject: [PATCH 1/5] PHRAS-2565 Add prompt to configure the build (triggered with --provision flag) --- Vagrantfile | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 74f8710e8e..e1ada1eca9 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,6 +11,7 @@ class MyCustomError < StandardError "[#{code} #{super}]" end end + # Check to determine whether we're on a windows or linux/os-x host, # later on we use this to launch ansible in the supported way # source: https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby @@ -34,15 +35,43 @@ else if which('ifconfig') end end -$php = [ "5.6", "7.0", "7.1", "7.2" ] -$phpVersion = ENV['phpversion'] ? ENV['phpversion'] : "7.0"; - unless Vagrant.has_plugin?('vagrant-hostmanager') raise "vagrant-hostmanager is not installed! Please run\n vagrant plugin install vagrant-hostmanager\n\n" end -unless $php.include?($phpVersion) - raise "You should specify php version before running vagrant\n\n (Available : 5.6, 7.0, 7.1, 7.2 | default => 5.6)\n\n Exemple: phpversion='7.0' vagrant up \n\n" +if ARGV[1] == '--provision' + print "Choose a PHP version for your build (Available : 5.6, 7.0, 7.1, 7.2)\n" + phpversion = STDIN.gets.chomp + print "\n" + # Php version selection + case (phpversion) + when "5.6", "7.0", "7.1", "7.2" + print "Selected PHP version : "+phpversion+"\n" + print "Continue ? (Y/n) \n" + continue = STDIN.gets.chomp + case continue + when 'n', 'no', 'N', 'NO' + raise "Build aborted" + else + print "Build with PHP"+phpversion+"\n" + end + + else + raise "You should specify php version before running vagrant\n\n (Available : 5.6, 7.0, 7.1, 7.2)\n\n" + end + + print "Choose a Build type (1 local, 2 box)\n" + type = STDIN.gets.chomp + print "\n" + # Switch between Phraseanet box and native trusty64 + case (type) + when '1' + $box = "ubuntu/xenial64" + when '2' + $box = "alchemy/Phraseanet-vagrant-dev_php" + $box.concat(phpversion) + end + print "Build with "+$box+" box\n" end $root = File.dirname(File.expand_path(__FILE__)) @@ -119,14 +148,12 @@ Vagrant.configure("2") do |config| ] end - # Switch between Phraseanet box and native trusty64 - config.vm.box = "alchemy/Phraseanet-vagrant-dev" - #config.vm.box = "ubuntu/trusty64" + config.vm.box = ($box) ? $box : "ubuntu/xenial64" # In case, Phraseanet box, choose the php version # For php 7.0 use box 0.0.1 # For php 7.1 use box 0.0.2 - config.vm.box_version = "0.0.1" + #config.vm.box_version = "0.0.1" config.ssh.forward_agent = true config_net(config) @@ -141,7 +168,7 @@ Vagrant.configure("2") do |config| ansible.extra_vars = { hostname: $hostname, host_addresses: $hostIps, - phpversion: $phpVersion, + phpversion: phpversion, postfix: { postfix_domain: $hostname + ".vb" } From b8efa93e397a0c78a6149b6da017cf29ecf04810 Mon Sep 17 00:00:00 2001 From: Xavier Rousset Date: Tue, 11 Jun 2019 16:49:26 +0200 Subject: [PATCH 2/5] PHRAS-2565 Update vars for PHP7-2 build, check of another builds in progress --- resources/ansible/roles/elasticsearch/tasks/main.yml | 2 +- resources/ansible/roles/repositories/tasks/main.yml | 2 +- resources/ansible/vars/all.yml | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/ansible/roles/elasticsearch/tasks/main.yml b/resources/ansible/roles/elasticsearch/tasks/main.yml index d246953df7..655567c119 100644 --- a/resources/ansible/roles/elasticsearch/tasks/main.yml +++ b/resources/ansible/roles/elasticsearch/tasks/main.yml @@ -13,7 +13,7 @@ changed_when: false - name: Install Dependencies - apt: pkg=openjdk-7-jre state=latest + apt: pkg=openjdk-8-jre state=latest - name: Remove temporary debian package shell: rm -f /tmp/elasticsearch-{{ elasticsearch.version }}.deb diff --git a/resources/ansible/roles/repositories/tasks/main.yml b/resources/ansible/roles/repositories/tasks/main.yml index 2c00cef1e7..ee459d8949 100644 --- a/resources/ansible/roles/repositories/tasks/main.yml +++ b/resources/ansible/roles/repositories/tasks/main.yml @@ -16,7 +16,7 @@ - name: Add Key for MariaDB Repository sudo: yes - apt_key: url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xcbcb082a1bb943db + apt_key: url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF1656F24C74CD1D8 # RabbitMQ - name: Add rabbitmq package repository diff --git a/resources/ansible/vars/all.yml b/resources/ansible/vars/all.yml index 5cdf9f6a51..acef9788e3 100644 --- a/resources/ansible/vars/all.yml +++ b/resources/ansible/vars/all.yml @@ -34,12 +34,14 @@ server: - fr_FR.UTF-8 - de_DE.UTF-8 - nl_NL.UTF-8 + repositories: php: 'ppa:ondrej/php' - mariadb: 'deb http://mirror6.layerjet.com/mariadb/repo/10.1/ubuntu' + mariadb: 'deb [arch=amd64,arm64,i386,ppc64el] http://mirror.nodesdirect.com/mariadb/repo/10.3/ubuntu' elasticsearch: 'ppa:webupd8team/java' rabbitmq: 'deb http://www.rabbitmq.com/debian/ testing main' yarn: 'https://dl.yarnpkg.com/debian/' + vagrant_local: install: '1' vm: From 2441731b94bc3091bf0808ba493b692efe5df1cd Mon Sep 17 00:00:00 2001 From: Xavier Rousset Date: Tue, 11 Jun 2019 17:25:39 +0200 Subject: [PATCH 3/5] Update README --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 90bb6dd4c9..18948ebd57 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ Phraseanet 4.1 - Digital Asset Management application - Elasticsearch search engine - Multiple resolution assets generation +# License : + +Phraseanet is licensed under GPL-v3 license. + # Documentation : https://docs.phraseanet.com/ @@ -31,17 +35,22 @@ https://www.phraseanet.com/download/ # Development : For development purpose Phraseanet is shipped with ready to use development environments using vagrant. +You can easily choose betweeen a complete build or a prebuild box, with a specific PHP version. -- git clone -- vagrant up + git clone + vagrant up --provision + +then, a prompt allow you to choose PHP version, and another one to choose a complete build or an Alchemy prebuilt boxes. + +Ex: +- vagrant up --provision //// 5.6 ///// 1 >> Build an ubuntu/xenial box with php5.6 +- vagrant up --provision //// 7.0 ///// 1 >> Build an ubuntu/xenial with php7.0 +- vagrant up --provision //// 7.2 ///// 2 >> Build the alchemy/phraseanet-php-7.2 box +- vagrant up --provision //// 5.6 ///// 1 >> Build the alchemy/phraseanet-php-5.6 box For development with Phraseanet API see https://docs.phraseanet.com/4.0/en/Devel/index.html -# License : - -Phraseanet is licensed under GPL-v3 license. - # Docker build From b58f09de8d59286462bb0cf6d62db62b8ece8046 Mon Sep 17 00:00:00 2001 From: Xavier Rousset Date: Wed, 12 Jun 2019 15:10:27 +0200 Subject: [PATCH 4/5] Update wording and switch questions --- Vagrantfile | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index e1ada1eca9..de38e6b5ea 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -40,6 +40,20 @@ unless Vagrant.has_plugin?('vagrant-hostmanager') end if ARGV[1] == '--provision' + + + print "\nChoose a Build type :\n\n(1) Build local\n(2) Pre-built Phraseanet box\n" + type = STDIN.gets.chomp + print "\n" + # Switch between Phraseanet box and native trusty64 + case (type) + when '1' + $box = "ubuntu/xenial64" + when '2' + $box = "alchemy/Phraseanet-vagrant-dev_php" + end + print "Build with "+$box+" box\n" + print "Choose a PHP version for your build (Available : 5.6, 7.0, 7.1, 7.2)\n" phpversion = STDIN.gets.chomp print "\n" @@ -53,25 +67,15 @@ if ARGV[1] == '--provision' when 'n', 'no', 'N', 'NO' raise "Build aborted" else + if (type == '2') + $box.concat(phpversion) + end print "Build with PHP"+phpversion+"\n" end else raise "You should specify php version before running vagrant\n\n (Available : 5.6, 7.0, 7.1, 7.2)\n\n" end - - print "Choose a Build type (1 local, 2 box)\n" - type = STDIN.gets.chomp - print "\n" - # Switch between Phraseanet box and native trusty64 - case (type) - when '1' - $box = "ubuntu/xenial64" - when '2' - $box = "alchemy/Phraseanet-vagrant-dev_php" - $box.concat(phpversion) - end - print "Build with "+$box+" box\n" end $root = File.dirname(File.expand_path(__FILE__)) From dc44ddb59b9fdca5d1588b4e3278fbbfb6514ede Mon Sep 17 00:00:00 2001 From: Xavier Rousset Date: Wed, 12 Jun 2019 15:47:37 +0200 Subject: [PATCH 5/5] Add colors on prompt --- Vagrantfile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index de38e6b5ea..a899a77ca5 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -40,41 +40,46 @@ unless Vagrant.has_plugin?('vagrant-hostmanager') end if ARGV[1] == '--provision' - - - print "\nChoose a Build type :\n\n(1) Build local\n(2) Pre-built Phraseanet box\n" + print "\033[34m \nChoose a Build type :\n\n(1) Use prebuilt Phraseanet Box\n(2) Build Phraseanet from scratch (xenial)\n\033[00m" type = STDIN.gets.chomp print "\n" # Switch between Phraseanet box and native trusty64 case (type) when '1' - $box = "ubuntu/xenial64" + $box = "alchemy/Phraseanet-vagrant-dev_php" when '2' - $box = "alchemy/Phraseanet-vagrant-dev_php" + $box = "ubuntu/xenial64" + print("\033[91mComplete build selected, don't forget to uncomment all roles on playbook.yml\n\n\033[00m") + else + raise "\033[31mYou should specify Build type before running vagrant\n\n (Available : 1, 2)\n\n\033[00m" end + print "\033[32m-----------------------------------------------\n" print "Build with "+$box+" box\n" + print "-----------------------------------------------\n\n\033[00m" - print "Choose a PHP version for your build (Available : 5.6, 7.0, 7.1, 7.2)\n" + print "\033[34mChoose a PHP version for your build (Available : 5.6, 7.0, 7.1, 7.2)\n\033[00m" phpversion = STDIN.gets.chomp print "\n" # Php version selection case (phpversion) when "5.6", "7.0", "7.1", "7.2" - print "Selected PHP version : "+phpversion+"\n" + print "\033[32mSelected PHP version : "+phpversion+"\n\033[00m" print "Continue ? (Y/n) \n" continue = STDIN.gets.chomp case continue when 'n', 'no', 'N', 'NO' - raise "Build aborted" + raise "\033[31mBuild aborted\033[00m" else - if (type == '2') + if (type == '1') $box.concat(phpversion) end + print "\033[32m-----------------------------------------------\n" print "Build with PHP"+phpversion+"\n" - end + print "-----------------------------------------------\n\n\033[00m" + end else - raise "You should specify php version before running vagrant\n\n (Available : 5.6, 7.0, 7.1, 7.2)\n\n" + raise "\033[31mYou should specify php version before running vagrant\n\n (Available : 5.6, 7.0, 7.1, 7.2)\n\n\033[00m" end end