| 1 | Please read [[Docker HowTo Install]] before installing CiviCRM |
| 2 | |
| 3 | == Prerequisites if required |
| 4 | |
| 5 | '''Step 1 - Install Docker''' |
| 6 | |
| 7 | [[Docker HowTo Install]] |
| 8 | |
| 9 | '''Step 2 - Install Git''' |
| 10 | |
| 11 | {{{$ sudo apt-get update }}} |
| 12 | |
| 13 | {{{$ sudo apt-get install git }}} |
| 14 | |
| 15 | '''Step 3 - Backup CiviCRM and Drupal Databases''' |
| 16 | |
| 17 | Log on to the mysql database machine. Backup Druplal and CiviCRM as follows : |
| 18 | |
| 19 | {{{/usr/local/mysql/bin/mysqldump --single-transaction -u root -p --ignore-table=civicrm_db_name.civicrm_domain \ }}} |
| 20 | |
| 21 | {{{--ignore-table=civicrm_db_name.civicrm_acl_cache \ }}} |
| 22 | |
| 23 | {{{--ignore-table=civicrm_db_name.civicrm_acl_contact_cache \ }}} |
| 24 | |
| 25 | {{{--ignore-table=civicrm_db_name.civicrm_cache \ }}} |
| 26 | |
| 27 | {{{--ignore-table=civicrm_db_name.civicrm_group_contact_cache \ }}} |
| 28 | |
| 29 | {{{civicrmtest > civicrmtest.sql }}} |
| 30 | |
| 31 | {{{ }}} |
| 32 | |
| 33 | {{{/usr/local/mysql/bin/mysqldump --single-transaction -u root -p drupaltest > drupaltest.sql }}} |
| 34 | |
| 35 | This creates 2 sql dump files. |
| 36 | |
| 37 | Connect to your destination mysql server where you wish to install the new databases. |
| 38 | |
| 39 | {{{mysql -u root -p}}} |
| 40 | |
| 41 | Create a database, make sure you postfix with CiviCRM version number. Please stick to this naming convention. |
| 42 | |
| 43 | {{{mysql > create database civicrmtest_docker4715}}} |
| 44 | |
| 45 | {{{mysql > create database drupaltest_docker4715}}} |
| 46 | |
| 47 | Import the lastest database. |
| 48 | |
| 49 | {{{mysql -u root -p drupaltest_docker4715 < drupaltest.sql}}} |
| 50 | |
| 51 | {{{mysql -u root -p civicrmtest_docker4715 < civicrmtest.sql}}} |
| 52 | |
| 53 | '''Step 4 - Create / Grant Mysql permissions''' |
| 54 | |
| 55 | If a new user is needed run the following, replace necessary details |
| 56 | |
| 57 | {{{CREATE USER 'docker'@'localhost' IDENTIFIED BY 'docker'; }}} |
| 58 | |
| 59 | {{{CREATE USER 'docker'@'%' IDENTIFIED BY 'docker'; }}} |
| 60 | |
| 61 | Grant necessary privileges to user. |
| 62 | |
| 63 | {{{GRANT ALL PRIVILEGES ON drupaltest_docker4715.* TO 'docker'@'localhost' WITH GRANT OPTION;}}} |
| 64 | |
| 65 | {{{GRANT ALL PRIVILEGES ON civicrmtest_docker4715.* TO 'docker'@'localhost' WITH GRANT OPTION;}}} |
| 66 | |
| 67 | {{{GRANT ALL PRIVILEGES ON drupaltest_docker4715.* TO 'docker'@'%' WITH GRANT OPTION;}}} |
| 68 | |
| 69 | {{{GRANT ALL PRIVILEGES ON civicrmtest_docker4715.* TO 'docker'@'%' WITH GRANT OPTION;}}} |
| 70 | |
| 71 | '''Step 5 - Perform necessary sql if required''' |
| 72 | |
| 73 | Run the following commands and take note of the sql for the views : |
| 74 | |
| 75 | {{{SHOW CREATE VIEW civicrm_view_case_activity_upcoming;}}} |
| 76 | |
| 77 | {{{SHOW CREATE VIEW civicrm_view_case_activity_recent;}}} |
| 78 | |
| 79 | Make the modification 'CREATE SQL SECURITY invoker' and recreate the view : |
| 80 | |
| 81 | {{{DROP VIEW civicrm_view_case_activity_upcoming;}}} |
| 82 | |
| 83 | {{{CREATE SQL SECURITY invoker VIEW `civicrm_view_case_activity_upcoming` AS select `ca`.`case_id` AS `case_id`,`a`.`id` AS `id`,`a`.`activity_date_time` AS `activity_date_time`,`a`.`status_id` AS `status_id`,`a`.`activity_type_id` AS `activity_type_id` from (`civicrm_case_activity` `ca` join `civicrm_activity` `a` on((`ca`.`activity_id` = `a`.`id`))) where ((`a`.`activity_date_time` <= (now() + interval 14 day)) and (`a`.`is_current_revision` = 1) and (`a`.`is_deleted` = 0) and (`a`.`status_id` = 1));}}} |
| 84 | |
| 85 | {{{DROP VIEW civicrm_view_case_activity_recent;}}} |
| 86 | |
| 87 | {{{CREATE SQL SECURITY invoker VIEW `civicrm_view_case_activity_recent` AS select `ca`.`case_id` AS `case_id`,`a`.`id` AS `id`,`a`.`activity_date_time` AS `activity_date_time`,`a`.`status_id` AS `status_id`,`a`.`activity_type_id` AS `activity_type_id` from (`civicrm_case_activity` `ca` join `civicrm_activity` `a` on((`ca`.`activity_id` = `a`.`id`))) where ((`a`.`activity_date_time` <= now()) and (`a`.`activity_date_time` >= (now() - interval 14 day)) and (`a`.`is_current_revision` = 1) and (`a`.`is_deleted` = 0) and (`a`.`status_id` <> 1));}}} |
| 88 | |
| 89 | == Upgrade CiviCRM using Docker |
| 90 | |
| 91 | Step 1. On the host machine go to directory |
| 92 | |
| 93 | {{{/local/docker/<USER>/}}} |
| 94 | |
| 95 | Step 2. Go to this directory and checkout from git docker_civicrm_upgrade |
| 96 | |
| 97 | {{{sudo git clone https://github.com/LCBRU/docker_civicrm_upgrade.git}}} |
| 98 | |
| 99 | {{{sudo chmod -R 777 docker_civicrm_upgrade/}}} |
| 100 | |
| 101 | This will create a directory /local/docker/<USER>/docker_civicrm_upgrade |
| 102 | |
| 103 | This docker script upgrades an existing CiviCRM installation. |
| 104 | |
| 105 | Step 3. The main configuration file is Dockerfile |
| 106 | |
| 107 | Modify the following lines in Dockerfile : |
| 108 | |
| 109 | {{{ENV DRUPALVERSION 7.53}}} |
| 110 | |
| 111 | {{{ENV CIVICRMVERSION 4.7.15}}} |
| 112 | |
| 113 | {{{#####################}}} |
| 114 | |
| 115 | {{{# select only one}}} |
| 116 | |
| 117 | {{{ENV ENVIRONMENT test }}} |
| 118 | |
| 119 | {{{#ENV ENVIRONMENT live}}} |
| 120 | |
| 121 | {{{#####################}}} |
| 122 | |
| 123 | Note the database config are in the live and test folders. |
| 124 | |
| 125 | Modify as necessary the files : |
| 126 | |
| 127 | {{{civicrm.settings.php}}} |
| 128 | |
| 129 | {{{settings.php}}} |
| 130 | |
| 131 | Step 4. Build Docker container |
| 132 | |
| 133 | {{{sudo docker build -t lcbruit/civicrm:v4.7.15 .}}} |
| 134 | |
| 135 | {{{sudo docker build --no-cache=true -t lcbruit/civicrm:v4.7.15 .}}} |
| 136 | |
| 137 | Ensure that the **version number** matches the actual CiviCRM version you are upgrading to. |
| 138 | |
| 139 | Run container |
| 140 | |
| 141 | {{{sudo docker run -v /share:/share -itd -p 80:80 lcbruit/civicrm:v4.7.15}}} |
| 142 | |
| 143 | To connect to container : |
| 144 | |
| 145 | {{{sudo docker ps -a}}} |
| 146 | {{{sudo docker exec -i -t [CONTAINER ID] /bin/bash}}} |
| 147 | |
| 148 | Step 5. Upgrade Drupal and CiviCRM |
| 149 | |
| 150 | To upgrade Drupal point your browser to : |
| 151 | |
| 152 | {{{http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/update.php?op=info}}} |
| 153 | |
| 154 | To upgrade CiviCRM point your browser to : |
| 155 | |
| 156 | {{{http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/civicrm/upgrade?reset=1}}} |
| 157 | |
| 158 | Go to Drupal -> Modules and enable the module 'Module Missing Message Fixer' |
| 159 | |
| 160 | Go to Drupal -> Configuration -> Missing Module Message Fixer to remove any missing modules. |
| 161 | |
| 162 | Go to the url : |
| 163 | |
| 164 | {{{http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/civicrm/admin/setting/path?reset=1}}} |
| 165 | |
| 166 | ensure that the following are set to : |
| 167 | |
| 168 | {{{Temporary Files Directory = /var/local/civicrm/drupal/sites/default/files/civicrm/upload/}}} |
| 169 | |
| 170 | {{{Image Directory = /var/local/civicrm/drupal/sites/default/files/civicrm/persist/contribute/}}} |
| 171 | |
| 172 | {{{Custom Files Directory = /var/local/civicrm/drupal/sites/default/files/civicrm/custom/}}} |
| 173 | |
| 174 | {{{Custom Template Directory = /var/local/civicrm/drupal/sites/all/lcbru_custom/civicrm_templates/}}} |
| 175 | |
| 176 | {{{Custom PHP Directory = /var/local/civicrm/drupal/sites/all/lcbru_custom/civicrm_php/}}} |
| 177 | |
| 178 | {{{Extensions Directory = /var/local/civicrm/drupal/sites/all/lcbru_custom/civicrm_extensions/}}} |
| 179 | |
| 180 | Go to the url : |
| 181 | |
| 182 | {{{http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/civicrm/admin/setting/url?reset=1}}} |
| 183 | |
| 184 | ensure that the following are set to : |
| 185 | |
| 186 | {{{CiviCRM Resource URL = http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/sites/all/modules/civicrm}}} |
| 187 | |
| 188 | {{{Image Upload URL = http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/sites/default/files/civicrm/persist/contribute/}}} |
| 189 | |
| 190 | {{{Extension Resource URL = http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/sites/all/civicrm_extensions}}} |
| 191 | |
| 192 | Go to the url : |
| 193 | |
| 194 | {{{http://XXXXXXXXXXXXXX.xuhl-tr.nhs.uk/civicrm/admin/setting/misc?reset=1}}} |
| 195 | |
| 196 | ensure that the following are set to : |
| 197 | |
| 198 | {{{Path to wkhtmltopdf executable = /usr/local/bin/wkhtmltopdf}}} |
| 199 | |
| 200 | Go to the url : |
| 201 | |
| 202 | {{{http://uhlbriccsapp07.xuhl-tr.nhs.uk/civicrm/admin/extensions?reset=1}}} |
| 203 | |
| 204 | Remove any extensions not required. |
| 205 | |
| 206 | Stop the container : |
| 207 | |
| 208 | {{{sudo docker ps -a}}} |
| 209 | {{{sudo docker stop [CONTAINER ID] }}} |
| 210 | |
| 211 | Step 6. Set location of theme directory. |
| 212 | |
| 213 | Connect to your drupal database and run the following |
| 214 | |
| 215 | {{{select * from variable where name = 'color_antonelli_files'; }}} |
| 216 | |
| 217 | This give the following output |
| 218 | |
| 219 | {{{a:2:{i:0;s:42:"public://color/antonelli-d1bee6f5/logo.png";i:1;s:44:"public://color/antonelli-d1bee6f5/colors.css";} }}} |
| 220 | |
| 221 | Modify the Dockerfile as follows |
| 222 | |
| 223 | {{{################### }}} |
| 224 | |
| 225 | {{{#css location. first line is test, 2nd line is live }}} |
| 226 | |
| 227 | {{{ENV CSS antonelli-d1bee6f5/ }}} |
| 228 | |
| 229 | {{{#ENV CSS antonelli-75b84edd }}} |
| 230 | |
| 231 | {{{#################### }}} |
| 232 | |
| 233 | Rebuild you image : |
| 234 | |
| 235 | {{{sudo docker build -t lcbruit/civicrm:v4.7.15 .}}} |
| 236 | |
| 237 | {{{sudo docker build --no-cache=true -t lcbruit/civicrm:v4.7.15 .}}} |
| 238 | |
| 239 | Run container |
| 240 | |
| 241 | {{{sudo docker run -v /share:/share -itd -p 80:80 lcbruit/civicrm:v4.7.15}}} |
| 242 | |
| 243 | Step 7. Ensure you have set the container to start on reboot. |
| 244 | |
| 245 | [[Docker HowTo Auto Start Containers On Reboot]] |
| 246 | |