Skip to content

Commit

Permalink
Merge pull request #354 from edmcouncil/new-docker-compose
Browse files Browse the repository at this point in the history
New docker compose
  • Loading branch information
mereolog authored Jun 26, 2023
2 parents bff669b + 17ef836 commit 48ee857
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 400 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ nbactions.xml
**/api.key
**/updateHistory.json
/web-app/fiboMapper/fibo/**
.env


# Protege
Expand All @@ -215,7 +216,8 @@ catalog-v001.xml
docker/runtime/
lucene_index/
download/
onto-viewer-web-app/config/
onto-viewer-web-app/config/*
onto-viewer-web-app/ontologies/*

# Mac
.DS_Store
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM maven:3.8.1-jdk-11-openj9 AS build-onto-viewer
SHELL ["/bin/bash", "-c"]
RUN apt-get update && \
apt-get -y install curl unzip zip && \
mkdir -p /opt/develop
WORKDIR /opt/develop
COPY . /opt/develop/
RUN mvn clean package && cp -av onto-viewer-web-app/target/onto-viewer-web-app-*.war /onto-viewer-web-app.war

FROM adoptopenjdk/openjdk11-openj9:alpine-slim
ARG ONTPUB_FAMILY=dev UPDATE_URL
ENV ONTPUB_FAMILY="${ONTPUB_FAMILY}" UPDATE_URL="${UPDATE_URL}"
RUN apk --no-cache add --upgrade bash curl jq && \
install -d /opt/viewer/config
WORKDIR /opt/viewer
COPY ./onto-viewer-web-app/entrypoint.sh /opt/viewer/entrypoint.sh
COPY ./onto-viewer-web-app/integration_tests/ontologies /opt/viewer/ontologies
COPY ./onto-viewer-web-app/staticOntologies /opt/viewer/staticOntologies
COPY --from=build-onto-viewer /onto-viewer-web-app.war /opt/viewer/onto-viewer.war
CMD ["sh", "entrypoint.sh"]
HEALTHCHECK --start-period=60s --interval=15s --timeout=1s --retries=60 CMD test "$(curl -q http://localhost/${ONTPUB_FAMILY}/ontology/actuator/health | jq -e ".components.custom.details.INITIALIZATION_DONE")" = "true"
155 changes: 71 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,97 +30,91 @@ java -jar app-v-0.1.0.war
```


## Run with docker
Requirements:
- [git](https://git-scm.com/) ([install](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git))
- [docker](https://www.docker.com/) - install:
* [Docker Desktop](https://docs.docker.com/desktop/) or ...
* [Docker Engine](https://docs.docker.com/engine/) with [Docker Compose plugin](https://docs.docker.com/compose/)

### ... with FIBO

How to start:
Clone the [edmcouncil/onto-viewer](https://github.com/edmcouncil/onto-viewer) repository to the *onto-viewer* directory,
go to the *onto-viewer* directory (run all subsequent commands inside this directory),
then build the images (or pull from the registry if available) and run the containers:
```bash
# clone the repository
git clone https://github.com/edmcouncil/onto-viewer onto-viewer

# got to the onto-viewer directory
cd onto-viewer

# build images
docker compose build
# alternatively pull images from registry if available
#docker compose pull --ignore-pull-failures

# run the containers
docker compose up -d
```

## Running in Docker
After some time, check the status of running containers:
```
docker compose ps
```

if they work correctly, the following message will appear:
```
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
onto-viewer-fibo-pages-1 edmcouncil/fibo-pages:latest "docker-entrypoint.s…" fibo-pages 7 minutes ago Up 6 minutes (healthy)
onto-viewer-fibo-strapi-1 edmcouncil/fibo-strapi:latest "docker-entrypoint.s…" fibo-strapi 7 minutes ago Up 6 minutes (healthy)
onto-viewer-fibo-viewer-1 edmcouncil/onto-viewer:latest "sh entrypoint.sh" fibo-viewer 7 minutes ago Up 6 minutes (healthy)
onto-viewer-spec-1 edmcouncil/spec:latest "/docker-entrypoint.…" spec 7 minutes ago Up 6 minutes (healthy) 0.0.0.0:8080->80/tcp, :::8080->80/tcp
To run the application using Docker you have to install Docker and docker-compose on your local computer. To install Docker see [here](https://docs.docker.com/get-docker/) and to install docker-compose see [here](https://docs.docker.com/compose/install/).
```

1. Create onto-viewer-web directory next to onto-viewer root folder.
2. Install Strapi with the development database in the root directory. To this end, run `npx create-strapi-app@latest strapi-dashboard --quickstart --no-run`command.
3. Copy files and folders from html-pages repository:
- `html-pages/general/strapi/.tmp/` > `strapi-dashboard/.tmp/`
- `html-pages/general/strapi/src/` > `strapi-dashboard/src/`
- `html-pages/general` > `onto-viewer-web/`
- `html-pages/general/strapi/Dockerfile` > `strapi-dashboard/Dockerfile`
- `onto-viewer/docker/web/.dockerignore` > `strapi-dashboard/.dockerignore`
- `onto-viewer/docker/web/nuxt.config.js` > `onto-viewer-web/nuxt.config.js`
- `onto-viewer/docker/web/Dockerfile` > `onto-viewer-web/Dockerfile`
4. In the `onto-viewer/docker/runtime/server/` folder, you must put configuration and ontologies files. You can find samples of these files in the `onto-viewer-config-loader/src/main/resources`. Note that the `onto-viewer/docker/runtime/ `folder is excluded from Git, so you can freely put there any file you want.
The final folder system should look like shown below:
The services provide endpoints at the following URLs:
- [http://localhost:8080](http://localhost:8080) :- [html-pages home page](https://github.com/edmcouncil/html-pages/blob/develop/home/README.md)
- [http://localhost:8080/fibo](http://localhost:8080/fibo) :- [html-pages general template](https://github.com/edmcouncil/html-pages/tree/develop/general) for [FIBO](https://github.com/edmcouncil/fibo) ontology
- [http://localhost:8080/fibo/ontology](http://localhost:8080/fibo/ontology) :- onto-viewer for [FIBO](https://github.com/edmcouncil/fibo) ontology
- [http://localhost:8080/fibo/strapi/admin](http://localhost:8080/fibo/strapi/admin) :- [Strapi admin panel](https://docs.strapi.io/user-docs/intro#accessing-the-admin-panel) for for [FIBO](https://github.com/edmcouncil/fibo) ontology (Email: *[email protected]*, Password: *devDBonly1*)

```
onto-viewer
| .gitignore
| CHANGELOG.md
| CODE_OF_CONDUCT.md
| CONTRIBUTING.md
| DCO
| docker-compose.yaml
| LICENSE
| pom.xml
| README.md
| api-doc/
| docker/
| | init-onto-viewer.sh
| runtime/
| | server/
| | config <- config files go here
| | ontologies <- ontologies go here
| server
| | Dockerfile
| web
| | nuxt.config.js
| onto-viewer-config-loader
| onto-viewer-core
| onto-viewer-toolkit
| onto-viewer-web-app
| style
onto-viewer-web <- installed and configured general tempaltes from general directory
| .dockerignore
| ...
| Dockerfile
| jsconfig.json
| nuxt.config.js
| ...
| api
| ...
| store
| strapi
strapi-dashboard <- installed and configured Strapi
| .dockerignore
| ...
| Dockerfile
| favicon.png
| package-lock.json
| package.json
| README.md
| yarn.lock
| .tmp/
| config/
| database/
| public/
| src/
```


Then, from the `onto-viewer/` folder run the following command to start the applications:
### ... with an ontology of your choice

```
docker-compose up --build -d
```
To list applications that have started, use ```docker-compose ps```.
It is possible to run containers with any ontology (instead of `FIBO`):
- place the ontology files of your choice in the `onto-viewer-web-app/ontologies` subdirectory
and the config files in the `onto-viewer-web-app/config` subdirectory

Please note that it takes a while to for all services to start depending on how many ontologies you provided.
- using the `docker-compose.dev.yaml` compose file (instead of the default `docker-compose.yaml`),
build the images,then run the containers:
```bash
echo COMPOSE_FILE=docker-compose.dev.yaml >> .env
docker compose build
docker compose up -d
```

After all ontologies are loaded, the Onto viewer will be accessible from http://localhost:3000/dev/ontology.
once all services are up and running, onto-viewer with your ontology will be available at `http://localhost:8080/dev/ontology`

To stop the applications run:
If you want to see the logs use:
```bash
# to view continuous log output for <SERVICE>=fibo-viewer
docker compose logs --follow fibo-viewer

# to view *100* latest log lines for <SERVICE>=fibo-viewer
docker compose logs --tail 100 fibo-strapi
```
docker-compose down

Stop the services with the command:
```bash
docker compose down
```

Remove all images and volumes with the command:
```bash
docker compose down --rmi all -v
```

# Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details on our code of conduct, and the process for submitting pull requests to us.
Expand All @@ -138,10 +132,3 @@ mvn -P integration-tests verify
# License
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)


<!--
# Release notes
Please read [CHANGELOG.md](CHANGELOG.md) for details.
-->

51 changes: 51 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
services:
dev-strapi:
image: edmcouncil/dev-strapi:${HTML_BRANCH:-latest}
build:
context: https://github.com/edmcouncil/html-pages.git#${HTML_BRANCH:-develop}:general/strapi
args:
- ONTPUB_FAMILY=dev
- BRANCH_NAME=${HTML_BRANCH:-develop}
volumes:
- spec_root:/opt/html-pages
dev-pages:
image: edmcouncil/dev-pages:${HTML_BRANCH:-latest}
build:
context: https://github.com/edmcouncil/html-pages.git#${HTML_BRANCH:-develop}:general
args:
- ONTPUB_FAMILY=dev
- BRANCH_NAME=${HTML_BRANCH:-develop}
environment:
- STRAPI_URL=http://dev-strapi:1337
volumes:
- spec_root:/opt/html-pages
depends_on:
- dev-strapi
dev-viewer:
image: edmcouncil/onto-viewer:${TAG:-latest}
build:
context: .
environment:
- ONTPUB_FAMILY=dev
volumes:
- ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies
- ./onto-viewer-web-app/config:/opt/viewer/config
spec:
image: edmcouncil/spec:${HTML_BRANCH:-latest}
build:
context: https://github.com/edmcouncil/html-pages.git#${HTML_BRANCH:-develop}:home
args:
- BRANCH_NAME=${HTML_BRANCH:-develop}
environment:
- FAMILY_REGEX=dev
volumes:
- spec_root:/opt/html-pages
depends_on:
- dev-strapi
- dev-pages
- dev-viewer
ports:
- 8080:80

volumes:
spec_root:
84 changes: 42 additions & 42 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
# For this docker-compose.yaml file to work, the following folder outline is required:
#
# aRootDir/
# onto-viewer/ (https://github.com/edmcouncil/onto-viewer)
# docker-compose.yaml <- this file
# ...
# html-pages/ (https://github.com/edmcouncil/html-pages)
# ...

version: "3.8"

services:
onto-viewer-server:
container_name: onto-viewer-server
fibo-strapi:
image: edmcouncil/fibo-strapi:${HTML_BRANCH:-latest}
build:
context: .
dockerfile: ./docker/server/Dockerfile
ports:
- "6101:8080"
context: https://github.com/edmcouncil/html-pages.git#${HTML_BRANCH:-develop}:general/strapi
args:
- ONTPUB_FAMILY=fibo
- BRANCH_NAME=${HTML_BRANCH:-develop}
volumes:
- ./docker/init-onto-viewer.sh:/opt/develop/init-onto-viewer.sh
- .:/opt/develop/src
- ./docker/runtime/.m2:/opt/develop/.m2
- ./docker/runtime/server:/opt/develop/app_home
networks:
- default

onto-viewer-web:
container_name: onto-viewer-web
- spec_root:/opt/html-pages
fibo-pages:
image: edmcouncil/fibo-pages:${HTML_BRANCH:-latest}
build:
context: ../onto-viewer-web
dockerfile: Dockerfile
ports:
- "3000:3000"
context: https://github.com/edmcouncil/html-pages.git#${HTML_BRANCH:-develop}:general
args:
- ONTPUB_FAMILY=fibo
- BRANCH_NAME=${HTML_BRANCH:-develop}
environment:
- STRAPI_URL=http://fibo-strapi:1337
volumes:
- spec_root:/opt/html-pages
depends_on:
- onto-viewer-server
- strapi
networks:
- default

strapi:
container_name: onto-viewer-strapi
- fibo-strapi
fibo-viewer:
image: edmcouncil/onto-viewer:${TAG:-latest}
build:
context: .
environment:
- ONTPUB_FAMILY=fibo
- UPDATE_URL=${FIBO_UPDATE_URL:-https://spec.edmcouncil.org/fibo/ontology/etc/onto-viewer-web-app/config/}
spec:
image: edmcouncil/spec:${HTML_BRANCH:-latest}
build:
context: ../strapi-dashboard
dockerfile: Dockerfile
context: https://github.com/edmcouncil/html-pages.git#${HTML_BRANCH:-develop}:home
args:
- BRANCH_NAME=${HTML_BRANCH:-develop}
environment:
- FAMILY_REGEX=fibo
volumes:
- spec_root:/opt/html-pages
depends_on:
- fibo-strapi
- fibo-pages
- fibo-viewer
ports:
- "1337:1337"
networks:
- default
- 8080:80

volumes:
spec_root:
22 changes: 0 additions & 22 deletions docker/init-onto-viewer.sh

This file was deleted.

Loading

0 comments on commit 48ee857

Please sign in to comment.