Skip to content

Commit

Permalink
update README and run script to be verbose and show errors
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jun 4, 2024
1 parent 6c68764 commit 381f00d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 80 deletions.
80 changes: 11 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,16 @@
# OntoPortal docker development environment

This repo contains docker compose and [DIP](https://github.com/bibendi/dip) configuration for running and
developing OntoPortal stack in 3 different ways:

1. docker-compose.backend_only.yml contains just the backend services required for developing and running API on your local system. To take advantage of that you would need to run `docker compose -f docker-compose.backend_only.yml up -d`
2. Run API/ncbo_cron and depenencies in docker using DIP
3. Run API/ncbo_cron in docker with mounted source code volumes from your local system. This will allow editing files on your local machine while running code inside docker container.


```sh
# clone this repo
git clone https://github.com/bioportal/ontoportal_docker.git

# clone ontologies_linked_data repo which is needed for creating solr configsets
git clone https://github.com/bioportal/ontologies_linked_data.git

# generate configsets:
cd ontologies_linked_data
./test/solr/generate_ncbo_configsets.sh

cd ../ontoportal_docker

# install DIP
bundle install

# export bioportal APIKEY which is needed for importing ontologies from bioportal when provisioning
cp .env.sample .env

# run provisioning via dip
dip provision
# OntoPortal docker environment
See help
```

`dip provision` will:
- clear existing volumes, i.e removing all data
- create 4store kb
- run ncbo_cron rake tasks for creating admin user acccount
- run bin/ncbo_ontology_import script on ncbo_cron container to import STY
ontology from bioportal
- run ontology pull script
- process STY ontology

# DIP commands:

list available dip commands

`dip ls`

starts api which you would be able to access on http://localhost:9393

`dip api rackup`

run ncbo_cron scripts:

`dip cron bundle exe bin/<script>`

For example, to import new ontology from BioPortal, pull and process it you would run:
```sh
dip cron bundle exec bin/ncbo_ontology_import --from-apikey ${BP_APIKEY} -o PO --from https://data.bioontology.org --admin-user admin
dip cron bundle exec bin/ncbo_ontology_pull -o PO
dip cron bundle exec bin/ncbo_ontology_process -o PO
./run -h
```

# API Development

When developing API it is possible to mount the source code from your local directory inside the container so that it runs your latest changes. To do that you need to make changes to dip.yml file and uncomment the line containing `# - docker-compose.dev.yml`. docker-compose.dev.yml contains overwrights to the docker-compose.yml which mounts your local directory.

to install gems inside the API container you would need to run `dip api bundle install` or `dip api bundle update` to get newer gems
to know how to run an ontoportal API docker instance

to test your changes you would need to run `dip api test`

# AllegroGraph
```
Usage: ./run [-k API_KEY] [-u API_URL] [-r IMAGE_REPOSITORY] [-t IMAGE_TAG] [-s STARTER_ONTOLOGY] [--no-provision]
```

Ontoportal has support for running AllegroGraph as triple store backend. To change default 4store triple store to AllgegroGraph you would need to rename dip.override.yml.sample to dip.override.yml
Example
```bash
./run -k <apikey>-r agroportal -t master -s STY -u "https://data.bioontology.org"
```
18 changes: 7 additions & 11 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ fi
echo "Running the Ontoportal API and CRON Setup..."


# Step 1: Clone ontologies_linked_data repo
echo "Cloning ontologies_linked_data repo..."
git clone --depth=1 https://github.com/ontoportal-lirmm/ontologies_linked_data.git

# Step 4: Install
echo "Installing (Docker in Production) dependencies..."
if ! bundle install; then
Expand Down Expand Up @@ -96,15 +92,15 @@ if [ "$PROVISION" = true ]; then
echo "Running provisioning ..."
commands=(
'docker compose down --volumes > /dev/null 2>&1'
'docker compose run --rm 4store bash -c "4s-backend-setup ontoportal_kb" > /dev/null 2>&1 '
'docker compose run --rm ncbo_cron bundle exec rake user:create[admin,[email protected]] > /dev/null 2>&1'
"docker compose run --rm ncbo_cron bundle exec 'bin/ncbo_ontology_import --admin-user admin --ontologies $STARTER_ONTOLOGY --from-apikey $API_KEY --from $API_URL' > /dev/null 2>&1 "
"docker compose run --rm ncbo_cron bundle exec 'bin/ncbo_ontology_pull -o $STARTER_ONTOLOGY' > /dev/null 2>&1 "
"docker compose run --rm ncbo_cron bundle exec 'bin/ncbo_ontology_process -o ${STARTER_ONTOLOGY}' > /dev/null 2>&1"
'docker compose run --rm 4store bash -c "4s-backend-setup ontoportal_kb" '
'docker compose run --rm ncbo_cron bundle exec rake user:create[admin,[email protected]]'
"docker compose run --rm ncbo_cron bundle exec 'bin/ncbo_ontology_import --admin-user admin --ontologies $STARTER_ONTOLOGY --from-apikey $API_KEY --from $API_URL'"
"docker compose run --rm ncbo_cron bundle exec 'bin/ncbo_ontology_pull -o $STARTER_ONTOLOGY'"
"docker compose run --rm ncbo_cron bundle exec 'bin/ncbo_ontology_process -o ${STARTER_ONTOLOGY}'"
)

for cmd in "${commands[@]}"; do
echo "Run: $cmd"
echo "> Run: $cmd"
if ! eval "$cmd"; then
echo "Error: Failed to run provisioning . $cmd"
exit 1
Expand All @@ -117,7 +113,7 @@ fi


echo "Running api ..."
docker compose run --service-ports -d api
docker compose run --service-ports -d --rm api

# Wait for API to be ready (adjust the sleep time accordingly)
timeout=300
Expand Down

0 comments on commit 381f00d

Please sign in to comment.