First check out the primero source code from the repository. For example:
mkdir ~/Dev/tmp
cd ~/Dev/tmp
git clone https://github.com/primeroIMS/primero.git
cd primero
We then need to get the specific branch for v2 work. To fetch a specific branch, you need to do this:
git fetch origin
This will fetch all of the remote branches for you. With the remote branches in hand, you now need to check out the branch you are interested in, giving you a local working copy:
git checkout -b development_v2 origin/development_v2
You can check your working branch now by doing
git branch
which should show you development_v2. Then move into the docker folder
cd docker
and then pull the docker images
cp local.env.sample.development local.env
sudo ./build.sh postgres
sudo ./build.sh solr
sudo ./compose.local.sh up -d postgres
sudo ./compose.local.sh run solr make-primero-core.sh primero-test
sudo ./compose.local.sh up -d solr
Now that the services have started we need to install the ruby version manager
sudo apt install software-properties-common
sudo apt-add-repository -y ppa:rael-gc/rvm
sudo apt update && sudo apt-get install rvm
It is a good idea to restart your system now unless you know how to start rvm with your .bashrc file. If you do restart make sure that you start the services again that v2 needs. So that is move into the docker folder again and start the services e.g
sudo ./compose.local.sh up -d postgres
sudo ./compose.local.sh run solr make-primero-core.sh primero-test
sudo ./compose.local.sh up -d solr
Now install the latest version of ruby
rvm install 2.6.5
and also node
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
and some binary dependencies
sudo apt-get install -y libpq-dev imagemagick libsodium-dev p7zip
Next move back into the root of the folder and install
cd ../
bundle install
npm install
and then copy the config files (review them and change anything you need)
cp config/database.yml.development config/database.yml
cp config/locales.yml.development config/locales.yml
cp config/mailers.yml.development config/mailers.yml
cp config/sunspot.yml.development config/sunspot.yml
The final step is to set some environment variables for your shell (these are 3 separate commands)
$ echo "export PRIMERO_SECRET_KEY_BASE=PRIMERO_SECRET_KEY_BASE" >> ~/.bashrc
$ echo "export DEVISE_SECRET_KEY=DEVISE_SECRET_KEY" >> ~/.bashrc
$ echo "export DEVISE_JWT_SECRET_KEY=DEVISE_JWT_SECRET_KEY" >> ~/.bashrc
and then either close and reopen the bash shell or run this command in the same shell to load the environment you just set
source ~/.bashrc
Next is to create a logging directory and file so that we can log errors
mkdir log
touch log/development.log
and then prepare the database
rails db:create
rails db:migrate
rails db:seed
This last command should create all of the tables and populate them. It should output something like
Seeding Lookups
Seeding Lookup.
Updating lookup lookup-location-type
Updating lookup lookup-country
Updating lookup lookup-nationality
Updating lookup lookup-ethnicity
Updating lookup lookup-language
Updating lookup lookup-religion
Updating lookup lookup-case-status
Updating lookup lookup-conference-case-status
Updating lookup lookup-incident-status
Updating lookup lookup-displacement-status
Updating lookup lookup-unaccompanied-separated-status
Updating lookup lookup-protection-status
Updating lookup lookup-verification-status
Updating lookup lookup-risk-level
Updating lookup lookup-gbv-sexual-violence-type
Updating lookup lookup-cp-violence-type
Updating lookup lookup-armed-force-group-type
Updating lookup lookup-armed-force-group-name
Updating lookup lookup-separation-cause
Updating lookup lookup-service-type
Updating lookup lookup-followup-type
Updating lookup lookup-protection-concerns
Updating lookup lookup-unhcr-needs-codes
Updating lookup lookup-yes-no
Updating lookup lookup-yes-no-unknown
Updating lookup lookup-yes-no-undecided
Updating lookup lookup-yes-no-not-applicable
Updating lookup lookup-gbv-reported-elsewhere
Updating lookup lookup-approval-type
Updating lookup lookup-gbv-approval-types
Updating lookup lookup-approval-status
Updating lookup lookup-gender
Updating lookup lookup-inquiry-status
Updating lookup lookup-service-referred
Updating lookup lookup-workflow
Updating lookup lookup-service-implemented
Updating lookup lookup-service-response-type
Updating lookup lookup-marital-status
Updating lookup lookup-marital-status-with-spouse
Updating lookup lookup-marital-status-unknown
Updating lookup lookup-perpetrator-relationship
Updating lookup lookup-time-of-day
Updating lookup lookup-incident-location
Updating lookup lookup-incident-identification
Updating lookup lookup-disability-type
Updating lookup lookup-disability-type-with-no
Updating lookup lookup-transition-type
Updating lookup lookup-assessment-duration
Updating lookup lookup-child-minor-age-group
Updating lookup lookup-age-group-type
Updating lookup lookup-discovery-method
Updating lookup lookup-assessment-progress
Updating lookup lookup-further-action_needed
Updating lookup lookup-family-relationship
Updating lookup lookup-tracing-status
Updating lookup lookup-form-group-cp-case
Updating lookup lookup-form-group-cp-tracing-request
Updating lookup lookup-form-group-cp-incident
Updating lookup lookup-form-group-gbv-case
Updating lookup lookup-form-group-gbv-incident
Updating lookup lookup-agency-office
Seeding Export Configuration
Seeding ExportConfiguration.
Updating export configuration export-unhcr-csv
Updating export configuration export-unhcr-csv-jo
Updating export configuration export-duplicate-id-csv
Seeding the system settings
Seeding SystemSettings.
Updating System Settings
[Re-]Seeding the forms
Seeding FormSection.
Seeding Programs
Seeding PrimeroProgram.
Updating program primeroprogram-primero
Seeding Modules
Seeding PrimeroModule.
Updating module CP
Updating module GBV
Seeding Roles
Seeding Role.
Updating role role-cp-administrator
Updating role role-cp-case-worker
Updating role role-cp-manager
Updating role role-cp-user-manager
Updating role role-gbv-social-worker
Updating role role-gbv-manager
Updating role role-gbv-user-manager
Updating role role-gbv-caseworker
Updating role role-gbv-mobile-caseworker
Updating role role-gbv-case-management-supervisor
Updating role role-gbv-program-manager
Updating role role-gbv-organization-focal-point
Updating role role-agency-user-administrator
Updating role role-gbv-agency-user-administrator
Updating role role-gbv-system-administrator
Updating role role-referral
Updating role role-transfer
Updating role role-ftr-manager
Updating role role-superuser
Seeding User Groups
Seeding UserGroup.
Updating user group usergroup-primero-cp
Updating user group usergroup-primero-ftr
Updating user group usergroup-primero-gbv
Seeding Agencies
Seeding Agency.
Updating agency UNICEF
Seeding Users
Seeding User.
Updating user primero
Updating user primero_admin_cp
Updating user primero_cp
Updating user primero_mgr_cp
Updating user primero_gbv
Updating user primero_mgr_gbv
Updating user primero_ftr_manager
Updating user primero_user_mgr_cp
Updating user primero_user_mgr_gbv
Updating user agency_user_admin
Updating user primero_system_admin_gbv
Updating user agency_user_admin_gbv
Updating user primero_cp_ar
Updating user primero_mgr_cp_ar
Updating user primero_gbv_ar
Updating user primero_mgr_gbv_ar
Creating user primero_sup_gbv
Seeding Default Reports
Seeding Report.
Seeding ContactInformation.
The last thing to do is to generate the translation files
bin/rails primero:i18n_js
and then start the server.
foreman start -f Procfile.dev
And it gave an error!
Lets dig into that and see what the issue is. Lets check our node version
ian@wintermute:~/Dev/tmp/primero$ node -v
v6.11.1
That does not look good. Lets try with the most recent node LTS
nvm install 12.16.1
then go to http://localhost:3000/ and login with primero primer0!
You will see this