wiki:REDCap HowTo Install Using Docker

Please read Docker HowTo Install before installing REDcap

Prerequisites if required

Step 1 - Install Docker

Docker HowTo Install

Step 2 - Install Git

$ sudo apt-get update

$ sudo apt-get install git

Step 3 - Install NGINX

NGINX HowTo Install Using Docker

Step 4 - Backup Redcap Database

Log on to the mysql database machine.

/usr/local/mysql/bin/mysqldump --routines --skip-extended-insert --force -h localhost -u root -p redcap > $(date +\%d-\%m-\%Y-)_redcap.sql

This will create a database dump file.

Connect to my sql.

mysql -u root -p

Create a database, make sure you postfix with Redcap version number. Please stick to this naming convention.

mysql > create database redcap6168

Import the lastest database.

mysql -u root -p -h localhost redcap6168 < 19-09-2016-_redcap.sql

Step 5 - Create / Grant Mysql permissions

If a new user is needed run the following, replace necessary details

CREATE USER 'briccsext02_user'@'uhlbriccsext02.xuhl-tr.nhs.uk' IDENTIFIED BY 'password'

Grant necessary privileges to user.

GRANT USAGE ON *.* TO 'briccsext02_user'@'uhlbriccsext01.xuhl-tr.nhs.uk' IDENTIFIED BY 'password'

GRANT ALL PRIVILEGES ON redcap6168_briccsext.* TO 'briccsext02_user'@'%';

GRANT ALL PRIVILEGES ON redcap6168_briccsext.* TO 'briccsext02_user'@'%';

If user already exists

GRANT ALL PRIVILEGES ON redcap6168.* TO 'redcap'@'%';

GRANT ALL PRIVILEGES ON redcap6168.* TO 'briccsext02_user'@'%';

or

GRANT ALL PRIVILEGES ON redcap6168_briccsext.* TO 'briccsext_user'@'uhlbriccsext01.xuhl-tr.nhs.uk';

You have the choice of either upgrading Redcap or installing a fresh version of Redcap

Installs

  1. On the host machine go to directory

/local/docker/<USER>/

  1. Go to this directory and checkout from git docker_redcap_upgrade

sudo git clone https://github.com/LCBRU/docker_redcap_upgrade.git

sudo chmod -R 777 docker_redcap_upgrade/

This will create a directory /local/docker/<USER>/docker_redcap_upgrade

This docker script upgrades an existing redcap installation.

The first step is to zip the existing redcap installation, this could be either

  1. The directory /var/www/redcap on a virtual machine.

cd /var/www

sudo zip -r redcap_v5.7.0.zip redcap

Move this file into /home/<USER>/docker_redcap_upgrade

  1. The directory /var/www/redcap within a running Docker container.

Connect to existing docker container using

sudo docker exec -i -t <CONTAINERID> /bin/bash

cd /var/www/site/redcap

sudo zip -r redcap_v5.7.0.zip *

sudo mv redcap_v5.7.0.zip /share/

exit

redcap_v5.7.0.zip should now be available on the host machine. In the directory /share/

Move this file into /home/<USER>/docker_redcap_upgrade

  1. Now edit Dockerfile

Amend the line # Old Redcap

Amend all instance of latest Redcap, i.e redcapX.XX.X_upgrade.zip, redcap_vX.XX.X. Please use a copy and replace.

  1. Edit database.php

Add entries for the database.

Ensure salt entry is exactly same as old version of redcap

  1. Build Docker container

sudo docker build -t lcbruit/redcap_upgrade:v6.16.8 .

  1. Run container

sudo docker run -v /share:/share -itd -p 82:80 lcbruit/redcap_upgrade:v6.16.8

  1. Open URL

http://<HOST>.xuhl-tr.nhs.uk:82/redcap/redcap_v6.16.8/upgrade.php

  1. This url will give you a sql script that you run against the database. Download the sql file and place it on the mysql host. Run as follows :

mysql -u root -p redcap6168 < redcap_upgrade_61608.sql

Upgrade

  1. Download the Redcap upgrade from https://community.projectredcap.org/page/download.html and place it in the /share directory
  1. Backup your database or copy the most recent database from /var/MySqlBackerUpper/data/latest.
  1. Amend the backup file to change the database name using the following command:
    sed -i.bak 's/redcap{old_version}_briccs/redcap{new_version}_briccs/g' {copy of backup file}
    
  1. Create the database:
    mysql < {copy of backup file}
    
  1. Grant redcap user permission to the new database:
    GRANT SELECT ON redcap{version}.* TO  'redcap'@'%';
    
  1. Connect to your docker redcap container

sudo docker exec -i -t <CONTAINERID> /bin/bash

  1. Unzip the contents of redcap7.X.X_upgrade.zip into /var/www/site/redcap
  1. Change database.php with details of new database.
  1. Open URL

http://<HOST>.xuhl-tr.nhs.uk/redcap/redcap_v7.X.X/upgrade.php

  1. This url will give you a sql script that you run against the database. Download the sql file and place it on the mysql host. Run as follows :

mysql -u root -p redcap6168 < redcap_upgrade_XXXXX.sql

  1. Now modify lcbruit/redcap_fresh docker image. This is very important as it will replace you current docker image.

Download the fresh install package from redcap and modify the Dockerfile in redcap_fresh to use it.

  1. Build and run the redcap_fresh container :

sudo docker build -t lcbruit/redcap_fresh:v6.16.6 .

sudo docker run -itd -p 80:80 lcbruit/redcap_fresh:v6.16.6

  1. Ensure you have set the container to start on reboot with the correct version number

Docker HowTo Auto Start Containers On Reboot

Last modified 5 years ago Last modified on 08/05/17 10:21:40
Note: See TracWiki for help on using the wiki.