ontoportal / ontoportal-project

OntoPortal Alliance centralized repository for the management of the OntoPortal project
https://ontoportal.org/
3 stars 1 forks source link

Deploying custom code on the appliance (3.1.1) #32

Closed galviset closed 1 year ago

galviset commented 1 year ago

Hi,

Since there is no documentation concerning the deployment of a custom code which is necessary for instances that are not based on the appliance repository, I will share the steps I did for the EarthPortal to change the upstream repository and install all necessary dependencies for the most recent AgroPortal code (10/10/2023).

API deployment

# Edit the deploy.rb file
nano /srv/ontoportal/ontologies_api/current/config/deploy.rb
# Replace the NCBO repo with your repository

# Copy configuration files
cp -r /srv/ontoportal/virtual_appliance/appliance_config/ontologies_api/config /srv/ontoportal/ontologies_api/shared/config

# Install required gems and deploy the API using Capistrano
cd /srv/ontoportal/ontologies_api/current
bundle install --with development
bundle exec cap appliance deploy

UI deployment

# Install Ruby 2.7
rbenv local 2.7.6
sudo su - ontoportal
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
bash

# Install Node.js 14
# (as centos user)
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum clean all && sudo yum makecache fast
sudo yum install -y gcc-c++ make
sudo yum install -y nodejs

# Install required gem
sudo /usr/local/rbenv/shims/gem install --default uri --version 0.12.0

# Copy UI configuration files
cp -r /srv/ontoportal/virtual_appliance/appliance_config/bioportal_web_ui/config /srv/ontoportal/bioportal_web_ui/shared/config
cp -r /srv/ontoportal/bioportal_web_ui /srv/ontoportal/ontoportal_web_ui

# Edit Rails credentials
cd /srv/ontoportal/ontoportal_web_ui/current
RAILS_ENV=appliance EDITOR="nano" bin/rails credentials:edit --environment appliance

# Create a directory for credentials and copy them
mkdir /srv/ontoportal/ontoportal_web_ui/shared/config/credentials
cp config/credentials/* /srv/ontoportal/ontoportal_web_ui/shared/config/credentials/

# Modify deploy.rb
# (Append the listed linked files and directories)
# Example:
# append :linked_files, 'config/database.yml', 'config/bioportal_config_appliance.rb'
# append :linked_dirs, 'log', 'tmp', '.bundle', 'config/locales'
# append :linked_files, 'config/secrets.yml', 'config/site_config.rb', 'config/newrelic.yml','config/credentials/appliance.key', 'config/credentials/appliance.yml.enc

# Upload newrelic.yml (if needed)
# Copy database.yml
cp config/database.yml /srv/ontoportal/ontoportal_web_ui/shared/config

# Copy UI configuration
cp -r /srv/ontoportal/virtual_appliance/appliance_config/bioportal_web_ui/ /srv/ontoportal/virtual_appliance/appliance_config/ontoportal_web_ui

# Modify bioportal_config_appliance.rb with updated config

# Install Capistrano and deploy
bundle install --with development
bundle config unset with
bundle exec cap appliance deploy

# Update Apache configuration if necessary
sudo nano /etc/httpd/conf.d/10-appliance...
# Change "bioportal" to "ontoportal" if the repo name is different from the original

# Restart the server
sudo oprestart
jonquet commented 1 year ago

Hi @galviset We do have a place holder for this: https://ontoportal.github.io/documentation/developer Could you create a page there rather than an issue for this?

galviset commented 1 year ago

I can create a documentation page for this indeed. However it was mentioned at the workshop that these instructions might get outdated pretty fast since both the appliance and the code evolves in time. I decided then to go for an issue first. Would it make sense to add this in the documentation with an appliance version/code date disclaimer then ?

jonquet commented 1 year ago

Yes totally. An issue would disapear to fast and not be indexed... at least a doc page mlight turn outdated but will stay there.

syphax-bouazzouni commented 1 year ago

Raimi from BioDivPortal did also this document, to document the process that he followed.

Hi @galviset We do have a placeholder for this: https://ontoportal.github.io/documentation/developer Could you create a page there rather than an issue for this?

Hard to tell, if this documentation is not already outdated. For example one of the steps indicates how to update/use the ruby version 2.7.6, but the new appliance already comes with ruby version 3.0.

But I agree that having something (even if outdated or not working), is better than nothing at all.

If you open a PR in the documentation repository with your new page, we will continue our discussion there.

Also related https://github.com/ontoportal/documentation/issues/24 and https://github.com/ontoportal/documentation/issues/23

jonquet commented 1 year ago

Raimi from BioDivPortal did also this document, to document the process that he followed.

I would also put that somewhere in the Developer documentaiton... even if not sorted out... we need to avoid now documents and notes travelling everywhere.

galviset commented 1 year ago

I made the pull request : https://github.com/ontoportal/documentation/pull/37#issue-1947019626 We can continue the discussions there.

syphax-bouazzouni commented 1 year ago

And deployed, it can be visited here https://ontoportal.github.io/documentation/docs/developers-docs/deploying_local_code/