forked from ontoportal/ontoportal_docker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ontoportal-lirmm/feature/create-a-script-t…
…o-ontoportal-docker-api-ui Feature: create a script to ontoportal docker api UI
- Loading branch information
Showing
21 changed files
with
944 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
BUNDLE_PATH="/srv/ontoportal/bundle" | ||
# default bundle config resolves to /usr/local/bundle/config inside of the container | ||
# we are setting it to local app directory if we need to use 'bundle config local' | ||
BUNDLE_APP_CONFIG="/srv/ontoportal/.bundle" | ||
# API/NCBO configs | ||
REDIS_GOO_CACHE_HOST="redis" | ||
REDIS_HTTP_CACHE_HOST="redis" | ||
REDIS_PERSISTENT_HOST="redis" | ||
REPOSITORY_FOLDER="/srv/ontoportal/data/repository" | ||
REPORT_PATH="/srv/ontoportal/data/reports/ontologies_report.json" | ||
SOLR_TERM_SEARCH_URL="http://solr:8983/solr" | ||
SOLR_PROP_SEARCH_URL="http://solr:8983/solr" | ||
MGREP_HOST="mgrep" | ||
MGREP_PORT="55556" | ||
GOO_PORT=9000 | ||
GOO_HOST="4store" | ||
##################### General configuration #################### | ||
ORGANIZATION_NAME=ontoportal-lirmm | ||
COMPOSE_API_FILE_PATH=/ontologies_api/master/docker-compose.yml | ||
COMPOSE_UI_FILE_PATH=/bioportal_web_ui/master/docker-compose.yml | ||
SERVICE=ontoportal | ||
|
||
# AllegroGraph related settings | ||
AGRAPH_SUPER_USER="test" | ||
AGRAPH_SUPER_PASSWORD="xyzzy" | ||
##################### API configuration #################### | ||
API_URL=http://localhost:9393 | ||
REDIS_GOO_CACHE_HOST=redis-ut | ||
REDIS_HTTP_CACHE_HOST=redis-ut | ||
REDIS_PERSISTENT_HOST=redis-ut | ||
|
||
##################### UI configuration #################### | ||
RAILS_ENV=development | ||
SITE=Ontoportal | ||
ORG_URL=http://www.lirmm.fr | ||
UI_URL=http://localhost:3000 | ||
API_KEY=72c72cba-ad45-4785-b94e-483fa55cdddb | ||
UI_THEME=ontoportal | ||
FAIRNESS_DISABLED=false | ||
NCBO_ANNOTATORPLUS_ENABLED=false | ||
SUPPORT_EMAIL=sifrportal-support@lirmm.fr | ||
RELEASE_VERSION="OntoPortal Appliance 3.0.1" | ||
USE_RECAPTCHA=false | ||
ANNOTATOR_URL="" | ||
|
||
##################### CRON configuration ##################### | ||
OP_API_URL=https://data.bioontology.org | ||
OP_APIKEY=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb | ||
STARTER_ONTOLOGY=STY | ||
IMAGE_REPOSITORY=bioportal | ||
IMAGE_TAG=latest | ||
OP_APIKEY=<YOUR ONTOPORTAL API KEY> | ||
OP_API_URL="https://data.bioontology.org" | ||
STARTER_ONTOLOGY="STY" | ||
|
||
##################### KAMAL configuration #################### | ||
IMAGE_NAME= | ||
SERVER_IP= | ||
DOCKER_REGISTRY_NAME= | ||
KAMAL_REGISTRY_PASSWORD= | ||
SSH_USER= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: "Run docker scripts tests CI" | ||
|
||
on: | ||
push: | ||
pull_request: | ||
types: [opened, reopened] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: "recursive" # Make sure submodules are fetched recursively | ||
|
||
- name: Run OntoPortal Docker tests | ||
run: test/run_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[submodule "test/bats"] | ||
path = test/bats | ||
url = https://github.com/bats-core/bats-core.git | ||
[submodule "test/test_helper/bats-support"] | ||
path = test/test_helper/bats-support | ||
url = https://github.com/bats-core/bats-support.git | ||
[submodule "test/test_helper/bats-assert"] | ||
path = test/test_helper/bats-assert | ||
url = https://github.com/bats-core/bats-assert.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM alpine:latest | ||
|
||
ENV TERM xterm-256color | ||
RUN apk --update --no-cache add \ | ||
bash \ | ||
curl \ | ||
docker \ | ||
docker-compose \ | ||
git \ | ||
iproute2 \ | ||
busybox \ | ||
ncurses \ | ||
bind-tools | ||
|
||
COPY . /app | ||
RUN chmod +x /app/ontoportal | ||
RUN chmod +x /app/bin/* | ||
RUN chmod +x /app/utils/* | ||
WORKDIR /app | ||
|
||
CMD ["/bin/sh", "-c", "/app/ontoportal start --no-provision"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,93 @@ | ||
# OntoPortal docker environment | ||
See help | ||
# OntoPortal docker | ||
OntoPortal Docker is a comprehensive collection of scripts designed to facilitate the running, testing, and deployment of ontoPortal using Docker. | ||
|
||
With this project, you can quickly spin up a fully functional ontoPortal instance with minimal setup by leveraging docker's containerization technology. This allows you to test its features and deploy the instance using Kamal. | ||
|
||
## Features | ||
- Start ontoportal instance (with or without parsing ontology) | ||
- Start specific services (API/UI) | ||
- Build docker image for this project and push it to your repository | ||
- Deploy the instance to server | ||
|
||
## Project architecture | ||
- **bin**: directory contains essential scripts for deploying and running various components of the ontoPortal system | ||
- **config**: contains deploy.yml file which contains settings and parameters required for deployment using kamal deployment tool | ||
- **test**: testing-related files and scripts using bats testing framework | ||
- **utils**: utility and additional scripts for various purposes | ||
- **.env.sample**: sample file contains configuration of the ontoportal instance (will be copied to .env when running) | ||
- **Dockerfile**: defines configurations to build the docker image for the project | ||
- **ontoportal**: the main script to run the ontoportal, it includes the entry point and main execution logic for the ontoPortal services | ||
- **run**: This file is used to set up environment for tests (it will be deleted). | ||
## Prerequisites | ||
- [git](https://git-scm.com/downloads) | ||
- [Docker](https://docs.docker.com/engine/install/) | ||
- [Docker Compose](https://docs.docker.com/compose/install/) | ||
- [Kamal deploy tool](https://kamal-deploy.org/docs/installation/) (if you plan to use the deploy feature) | ||
|
||
## Installation | ||
``` | ||
./run -h | ||
~> git clone https://github.com/ontoportal-lirmm/ontoportal_docker.git | ||
~> cd ontoportal-docker | ||
``` | ||
## Usage | ||
### General Command Structure | ||
``` | ||
./ontoportal <command> [arguments] | ||
``` | ||
### Commands | ||
- **Start** | ||
- start ontoportal instance | ||
``` | ||
./ontoportal start [--no-provision] | ||
``` | ||
- start specific services (API or UI) | ||
``` | ||
./ontoportal start [api|ui] [--no-provision] | ||
``` | ||
- `--no-provision`: Start the appliance without any data (an empty appliance). | ||
|
||
to know how to run an ontoportal API docker instance | ||
- **Deploy** | ||
- build and push image to repository (by default docker hub) | ||
``` | ||
./ontoportal deploy push | ||
``` | ||
- Deploy ontoportal instance to server (or just specific services mentioned in the arguments) | ||
``` | ||
./ontoportal deploy [api|ui] | ||
``` | ||
- **Stop**: stop the OntoPortal API and UI services. | ||
``` | ||
./ontoportal stop [api|ui] | ||
``` | ||
- **Clean**: clean up the server. This removes all data, Docker Compose files, and containers | ||
``` | ||
./ontoportal clean [-f] | ||
``` | ||
- `-f` : for force clean | ||
|
||
``` | ||
Usage: ./run [-k API_KEY] [-u API_URL] [-r IMAGE_REPOSITORY] [-t IMAGE_TAG] [-s STARTER_ONTOLOGY] [--no-provision] | ||
``` | ||
- **Help**: display the help message. | ||
``` | ||
./ontoportal help | ||
``` | ||
|
||
Example | ||
```bash | ||
./run -k <apikey>-r agroportal -t master -s STY -u "https://data.bioontology.org" | ||
``` | ||
### Additional Notes | ||
- You can provide your own `.env` file to customize parameters. Place the .env file in the project directory. | ||
- `.env` file contains 5 parts: | ||
- **General configuration**: where you can specify: | ||
```yml | ||
ORGANIZATION_NAME: github organization from where script will fetch docker compose files | ||
COMPOSE_API_FILE_PATH: docker compose file of the UI | ||
COMPOSE_UI_FILE_PATH: docker compose file of the UI | ||
SERVICE: specify the service you want to run (script will handle this) | ||
``` | ||
- **API Configurations:** contains settings for api service | ||
- **UI Configurations:** contains settings for ui service | ||
- **Cron Configurations:** contains settings for cron service | ||
- **Kamal configurations**: for build and deployment of the ontoportal instance: | ||
```yml | ||
IMAGE_NAME: the name of the image to build and push to docker hub | ||
SERVER_IP: the ip server where you want to deploy the instance | ||
DOCKER_REGISTRY_NAME: the name of account in docker hub of another repository | ||
KAMAL_REGISTRY_PASSWORD: password of token to access the repository | ||
SSH_USER: the user that will be used when deploying into the server | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
deploy() { | ||
local env_path='.env' | ||
|
||
if [ -f "$env_path" ]; then | ||
echo "[+] Env file exist" | ||
else | ||
echo "[+] Env file does not exist" | ||
cp .env.sample .env | ||
fi | ||
|
||
if [ -z "$1" ]; then | ||
SERVICE="ontoportal" | ||
else | ||
SERVICE="$1" | ||
fi | ||
|
||
# Update SERVICE variable in .env file without using sed | ||
awk -v SERVICE="$SERVICE" '/^SERVICE=/{sub(/=.*/, "=" SERVICE)} 1' .env >temp && mv temp .env | ||
|
||
echo "[+] Checking for env variables" | ||
source .env | ||
|
||
variables=("IMAGE_NAME" "SERVER_IP" "DOCKER_REGISTRY_NAME" "KAMAL_REGISTRY_PASSWORD" "SSH_USER") | ||
|
||
for variable in "${variables[@]}"; do | ||
if [ -z "${!variable}" ]; then | ||
echo "[-] Error: $variable is not set." | ||
exit | ||
fi | ||
done | ||
|
||
echo "[+] Changing kamal deploy.yml file" | ||
echo "" > config/deploy.yml | ||
echo "service: ontoportal_docker" > config/deploy.yml | ||
echo "image: ${IMAGE_NAME}" >> config/deploy.yml | ||
echo -e "servers:\n - ${SERVER_IP}" >> config/deploy.yml | ||
echo "run_directory: /root/app" >> config/deploy.yml | ||
echo -e "registry:\n username:\n - ${DOCKER_REGISTRY_NAME}\n password:\n - ${KAMAL_REGISTRY_PASSWORD}" >>config/deploy.yml | ||
echo -e "ssh:\n user: ${SSH_USER}" >> config/deploy.yml | ||
echo -e "volumes:\n - /var/run/docker.sock:/var/run/docker.sock" >> config/deploy.yml | ||
echo -e "traefik:\n host_port: 4000" >> config/deploy.yml | ||
echo -e "healthcheck:\n cmd: /bin/true" >> config/deploy.yml | ||
if [ -z "$1" ]; then | ||
echo "[+] Starting the deployment" | ||
kamal setup -vv | ||
elif [ "$1" == "push" ]; then | ||
echo "[+] Pushing image to Docker Hub without deploying to server" | ||
kamal build push -vv | ||
fi | ||
|
||
} | ||
|
||
deploy "$1" |
Oops, something went wrong.