From 4a0850ed12c0af9eb43924d6a8f069c18735757f Mon Sep 17 00:00:00 2001 From: dasawanaka Date: Wed, 17 May 2023 07:57:00 +0200 Subject: [PATCH 01/12] New docker compose Signed-off-by: dasawanaka --- README.md | 93 +++++++++---------------------- docker-compose.yaml | 33 +++++------ docker/init-onto-viewer.sh | 3 +- docker/web/Dockerfile | 43 ++++---------- docker/web/init-web-and-strapi.sh | 27 +++++++++ docker/web/nuxt.config.js | 8 +-- 6 files changed, 83 insertions(+), 124 deletions(-) create mode 100644 docker/web/init-web-and-strapi.sh diff --git a/README.md b/README.md index 6dee6ad3..80571d42 100644 --- a/README.md +++ b/README.md @@ -36,91 +36,48 @@ java -jar app-v-0.1.0.war 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: - -``` -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/ -``` - + 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. Then, from the `onto-viewer/` folder run the following command to start the applications: ``` docker-compose up --build -d ``` -To list applications that have started, use ```docker-compose ps```. Please note that it takes a while to for all services to start depending on how many ontologies you provided. After all ontologies are loaded, the Onto viewer will be accessible from http://localhost:3000/dev/ontology. + +You can see all running containers and their status: + +``` +$ docker compose ps + +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +html-pages-general-1 html-pages-general "docker-entrypoint.s…" general 20 seconds ago Up 17 seconds 0.0.0.0:8081->3000/tcp +html-pages-home-1 html-pages-home "docker-entrypoint.s…" home 7 hours ago Up 4 minutes 0.0.0.0:8080->8080/tcp +html-pages-strapi-1 html-pages-strapi "docker-entrypoint.s…" strapi 4 hours ago Up 17 seconds 0.0.0.0:1337->1337/tcp +``` + +If you want to see logs from one container use: + +``` +# to view continuous log output +$ docker logs --follow + +# to view specific amount of logs +$ docker logs --tail +``` + To stop the applications run: ``` docker-compose down ``` +You could also run docker-compose without detached mode(without -d). If so, you'll just use '^C' to kill all containers. + # 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. diff --git a/docker-compose.yaml b/docker-compose.yaml index 541a9969..bed45d6a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,11 +12,14 @@ version: "3.8" services: onto-viewer-server: container_name: onto-viewer-server + environment: + - ONTPUB_FAMILY="${ONTPUB_FAMILY:-dev}" build: context: . dockerfile: ./docker/server/Dockerfile ports: - "6101:8080" + volumes: - ./docker/init-onto-viewer.sh:/opt/develop/init-onto-viewer.sh - .:/opt/develop/src @@ -24,26 +27,16 @@ services: - ./docker/runtime/server:/opt/develop/app_home networks: - default - - onto-viewer-web: - container_name: onto-viewer-web - build: - context: ../onto-viewer-web - dockerfile: Dockerfile - ports: - - "3000:3000" - depends_on: - - onto-viewer-server - - strapi - networks: - - default - - strapi: - container_name: onto-viewer-strapi + web-with-strapi: + container_name: onto-viewer-web-with-strapi + environment: + - PUBLIC_URL=0.0.0.0 + - NUXT_PORT=3000 + - ONTPUB_FAMILY=${ONTPUB_FAMILY:-dev} build: - context: ../strapi-dashboard - dockerfile: Dockerfile - ports: - - "1337:1337" + context: ./docker/web + ports: + - 3000:3000 + - 1337:1337 networks: - default \ No newline at end of file diff --git a/docker/init-onto-viewer.sh b/docker/init-onto-viewer.sh index b9e8c0f8..8ff19fec 100644 --- a/docker/init-onto-viewer.sh +++ b/docker/init-onto-viewer.sh @@ -19,4 +19,5 @@ cd "$INIT_DIR" cp "$INSTALL_DIR"/onto-viewer-web-app/target/onto-viewer-web-app-*.war app.war echo "[INFO] Starting app.war..." -java -jar app.war --server.servlet.context-path=/dev/ontology --app.defaultHomePath="$INIT_DIR/app_home" +exec java ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar app.war --server.servlet.context-path=/dev/ontology --app.defaultHomePath="$INIT_DIR/app_home" +#java -jar app.war --server.servlet.context-path=/$ONTPUB_FAMILY/ontology --app.defaultHomePath="$INIT_DIR/app_home" diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile index ff88d1e2..80535979 100644 --- a/docker/web/Dockerfile +++ b/docker/web/Dockerfile @@ -1,31 +1,12 @@ -FROM node:16-alpine - -# create destination directory -RUN mkdir -p /usr/src/nuxt-app -WORKDIR /usr/src/nuxt-app - -# update and install dependency -RUN apk update && apk upgrade -RUN apk add git - -# copy the app, note .dockerignore -COPY . /usr/src/nuxt-app/ -RUN npm install - -# build necessary, even if no static files are needed, -# since it builds the server as well - RUN npm run build - -# expose 3000 on container -EXPOSE 3000 - -# set app serving to permissive / assigned -ENV PUBLIC_URL=0.0.0.0 - -# set app port -ENV NUXT_PORT=3000 - -ENV ONTPUB_FAMILY=dev - -# start the app -CMD [ "npm", "run" ,"dev" ] +FROM node:16-alpine +# Installing libvips-dev for sharp Compatibility +RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev git +ARG NODE_ENV=development +ENV NODE_ENV=${NODE_ENV} +WORKDIR /opt/ +COPY ./ . +EXPOSE 1337 +EXPOSE 3000 +CMD ["sh", "init-web-and-strapi.sh"] +# ENV HOST=0.0.0.0 + diff --git a/docker/web/init-web-and-strapi.sh b/docker/web/init-web-and-strapi.sh new file mode 100644 index 00000000..dfef113b --- /dev/null +++ b/docker/web/init-web-and-strapi.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "[INFO] Clone html pages" +git clone https://github.com/edmcouncil/html-pages.git + +cd /opt/html-pages/general/strapi + +echo "[INFO] Install strapi without run." +npx create-strapi-app@latest strapi-dashboard --quickstart --no-run + +echo "[INFO] Copy database." +mkdir ./strapi-dashboard/.tmp +cp ./.tmp/data.db ./strapi-dashboard/.tmp/data.db + +echo "[INFO] Copy structures." +cp -R ./src/ ./strapi-dashboard + +echo "[INFO] Run Strapi." +cd strapi-dashboard +npm run develop & + +echo "[INFO] Install and run general web pages" +cd /opt/html-pages/general +rm nuxt.config.js +cp ../../nuxt.config.js . +npm install +npm run build +npm run dev diff --git a/docker/web/nuxt.config.js b/docker/web/nuxt.config.js index 17870b01..e8932fe0 100644 --- a/docker/web/nuxt.config.js +++ b/docker/web/nuxt.config.js @@ -18,7 +18,7 @@ process.env.VUE_APP_TAG = process.env.TAG || process.env.TAG_NAME || "latest"; process.env.VUE_DIST_DIR = `/${process.env.VUE_APP_PRODUCT}/${process.env.VUE_APP_BRANCH}/${process.env.VUE_APP_TAG}`; process.env.VUE_ASSETS_DIR = `${process.env.VUE_DIST_DIR}/_nuxt/`; -process.env.VUE_ONTOLOGY_NAME = process.env.ONTPUB_FAMILY || "iof"; +process.env.VUE_ONTOLOGY_NAME = process.env.ONTPUB_FAMILY || "dev"; process.env.VUE_BASE_URL = process.env.BASE_URL || "https://spec." + @@ -81,7 +81,7 @@ export default { base: `/${process.env.VUE_ONTOLOGY_NAME}`, }, -//to removed + //to removed generate: { dir: `dist/${process.env.VUE_ONTOLOGY_NAME}${process.env.VUE_DIST_DIR}`, routes() { @@ -182,8 +182,8 @@ export default { }, proxy: [ - "http://onto-viewer-server:8080/dev/ontology/api", - "http://onto-viewer-server:8080/dev/ontology/*/api", + `http://onto-viewer-server:8080/${process.env.VUE_ONTOLOGY_NAME}/ontology/api`, + `http://onto-viewer-server:8080/${process.env.VUE_ONTOLOGY_NAME}/ontology/*/api`, ], styleResources: { From 96630a3c5cc29166766f978bf9cb453cb3ff4b77 Mon Sep 17 00:00:00 2001 From: dasawanaka Date: Wed, 17 May 2023 08:04:53 +0200 Subject: [PATCH 02/12] Fix Readme description Signed-off-by: dasawanaka --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 80571d42..46756a96 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,8 @@ You can see all running containers and their status: $ docker compose ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS -html-pages-general-1 html-pages-general "docker-entrypoint.s…" general 20 seconds ago Up 17 seconds 0.0.0.0:8081->3000/tcp -html-pages-home-1 html-pages-home "docker-entrypoint.s…" home 7 hours ago Up 4 minutes 0.0.0.0:8080->8080/tcp -html-pages-strapi-1 html-pages-strapi "docker-entrypoint.s…" strapi 4 hours ago Up 17 seconds 0.0.0.0:1337->1337/tcp +onto-viewer-server-1 onto-viewer-server "docker-entrypoint.s…" onto-viewer-server 20 seconds ago Up 17 seconds 0.0.0.0:8080->6101/tcp +web-with-strapi-1 web-with-strapi "docker-entrypoint.s…" web-with-strapi 4 hours ago Up 17 seconds 0.0.0.0:1337->1337/tcp ``` If you want to see logs from one container use: From b3b809acc1cfff9c23383ab22779ae47506e3c37 Mon Sep 17 00:00:00 2001 From: dasawanaka Date: Fri, 19 May 2023 16:15:17 +0200 Subject: [PATCH 03/12] fix not working connection between ov and html-pages Signed-off-by: dasawanaka --- README.md | 8 +++++--- docker-compose.yaml | 12 ++---------- docker/init-onto-viewer.sh | 4 ++-- docker/web/init-web-and-strapi.sh | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 46756a96..efa3946d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ After all ontologies are loaded, the Onto viewer will be accessible from http:// You can see all running containers and their status: ``` -$ docker compose ps +$ docker-compose ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS onto-viewer-server-1 onto-viewer-server "docker-entrypoint.s…" onto-viewer-server 20 seconds ago Up 17 seconds 0.0.0.0:8080->6101/tcp @@ -63,10 +63,12 @@ If you want to see logs from one container use: ``` # to view continuous log output -$ docker logs --follow +# where "" is "onto-viewer-server" or "web-with-strapi" +$ docker-compose logs --follow # to view specific amount of logs -$ docker logs --tail +# where "" is amount of logs and "" is "onto-viewer-server" or "web-with-strapi" +$ docker-compose logs --tail ``` To stop the applications run: diff --git a/docker-compose.yaml b/docker-compose.yaml index bed45d6a..eab87f0e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,19 +1,11 @@ -# 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 environment: - - ONTPUB_FAMILY="${ONTPUB_FAMILY:-dev}" + - ONTPUB_FAMILY=${ONTPUB_FAMILY:-dev} + - UPDATE_URL build: context: . dockerfile: ./docker/server/Dockerfile diff --git a/docker/init-onto-viewer.sh b/docker/init-onto-viewer.sh index 8ff19fec..7b4b8365 100644 --- a/docker/init-onto-viewer.sh +++ b/docker/init-onto-viewer.sh @@ -19,5 +19,5 @@ cd "$INIT_DIR" cp "$INSTALL_DIR"/onto-viewer-web-app/target/onto-viewer-web-app-*.war app.war echo "[INFO] Starting app.war..." -exec java ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar app.war --server.servlet.context-path=/dev/ontology --app.defaultHomePath="$INIT_DIR/app_home" -#java -jar app.war --server.servlet.context-path=/$ONTPUB_FAMILY/ontology --app.defaultHomePath="$INIT_DIR/app_home" +exec java ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar app.war --server.servlet.context-path=/${ONTPUB_FAMILY:-dev}/ontology --app.defaultHomePath="$INIT_DIR/app_home" + diff --git a/docker/web/init-web-and-strapi.sh b/docker/web/init-web-and-strapi.sh index dfef113b..cc90dbcb 100644 --- a/docker/web/init-web-and-strapi.sh +++ b/docker/web/init-web-and-strapi.sh @@ -9,7 +9,7 @@ npx create-strapi-app@latest strapi-dashboard --quickstart --no-run echo "[INFO] Copy database." mkdir ./strapi-dashboard/.tmp -cp ./.tmp/data.db ./strapi-dashboard/.tmp/data.db +cp ./.tmp/${ONTPUB_FAMILY:-data}.db ./strapi-dashboard/.tmp/data.db echo "[INFO] Copy structures." cp -R ./src/ ./strapi-dashboard From 06a3ad1afcdfb2c702da3b9f9421e02e91419196 Mon Sep 17 00:00:00 2001 From: dasawanaka Date: Fri, 19 May 2023 18:00:19 +0200 Subject: [PATCH 04/12] docker-compose -> docker compose Signed-off-by: dasawanaka --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index efa3946d..671477dc 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,14 @@ java -jar app-v-0.1.0.war ## Running in Docker -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/). +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/). 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. Then, from the `onto-viewer/` folder run the following command to start the applications: ``` -docker-compose up --build -d +docker compose up --build -d ``` Please note that it takes a while to for all services to start depending on how many ontologies you provided. @@ -52,7 +52,7 @@ After all ontologies are loaded, the Onto viewer will be accessible from http:// You can see all running containers and their status: ``` -$ docker-compose ps +$ docker compose ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS onto-viewer-server-1 onto-viewer-server "docker-entrypoint.s…" onto-viewer-server 20 seconds ago Up 17 seconds 0.0.0.0:8080->6101/tcp @@ -64,20 +64,20 @@ If you want to see logs from one container use: ``` # to view continuous log output # where "" is "onto-viewer-server" or "web-with-strapi" -$ docker-compose logs --follow +$ docker compose logs --follow # to view specific amount of logs # where "" is amount of logs and "" is "onto-viewer-server" or "web-with-strapi" -$ docker-compose logs --tail +$ docker compose logs --tail ``` To stop the applications run: ``` -docker-compose down +docker compose down ``` -You could also run docker-compose without detached mode(without -d). If so, you'll just use '^C' to kill all containers. +You could also run docker compose without detached mode(without -d). If so, you'll just use '^C' to kill all containers. # Contributing From 63a78b1f8cb2733f562f0d22be3122e0bbe8772d Mon Sep 17 00:00:00 2001 From: dasawanaka Date: Wed, 31 May 2023 05:42:32 +0200 Subject: [PATCH 05/12] Fix README Signed-off-by: dasawanaka --- README.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 671477dc..3ba85c99 100644 --- a/README.md +++ b/README.md @@ -30,15 +30,15 @@ java -jar app-v-0.1.0.war ``` - ## Running in Docker - 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/). - 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 `onto-viewer/` folder is root/main project folder. All folders below are relative to this folder. + + In the `docker/runtime/server/` folder, you must put configuration(in the `config` folder) and ontologies(in the `ontologies` folder) files if used. You can find samples of these files in the `onto-viewer-config-loader/src/main/resources`, you should rename the files - remove the default_ prefix. Note that the `docker/runtime/ `folder is excluded from Git, so you can freely put there any file you want. -Then, from the `onto-viewer/` folder run the following command to start the applications: +Then, from the root folder run the following command to start the applications: ``` docker compose up --build -d @@ -46,7 +46,7 @@ docker compose up --build -d Please note that it takes a while to for all services to start depending on how many ontologies you provided. -After all ontologies are loaded, the Onto viewer will be accessible from http://localhost:3000/dev/ontology. +After all ontologies are loaded, the Onto Viewer will be accessible from http://localhost:3000/dev/ontology. You can see all running containers and their status: @@ -96,10 +96,3 @@ mvn -P integration-tests verify # License [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) - - - From 38d3657090847d717b0d940e3ffb2bb295606d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Tue, 6 Jun 2023 09:38:03 +0200 Subject: [PATCH 06/12] New docker compose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Przemysław Grądzki --- Dockerfile.onto-viewer | 23 ++++++++++++ docker-compose.yaml | 60 ++++++++++++++++--------------- onto-viewer-web-app/entrypoint.sh | 14 ++++++++ 3 files changed, 68 insertions(+), 29 deletions(-) create mode 100644 Dockerfile.onto-viewer create mode 100644 onto-viewer-web-app/entrypoint.sh diff --git a/Dockerfile.onto-viewer b/Dockerfile.onto-viewer new file mode 100644 index 00000000..1eaf741e --- /dev/null +++ b/Dockerfile.onto-viewer @@ -0,0 +1,23 @@ +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 +RUN 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 /app.war + +FROM adoptopenjdk/openjdk11-openj9:alpine-slim +ARG ONTPUB_FAMILY dev +ARG UPDATE_URL +ENV ONTPUB_FAMILY ${ONTPUB_FAMILY} +ENV UPDATE_URL ${UPDATE_URL} +RUN apk --no-cache add --upgrade bash curl jq && \ + install -d /opt/viewer/{config,ontologies} +WORKDIR /opt/viewer +COPY ./onto-viewer-web-app/entrypoint.sh /opt/viewer/entrypoint.sh +COPY ./onto-viewer-web-app/integration_tests /opt/viewer/integration_tests +COPY ./onto-viewer-web-app/staticOntologies /opt/viewer/staticOntologies +COPY --from=build-onto-viewer /app.war /app.war +CMD ["sh", "entrypoint.sh"] +HEALTHCHECK --start-period=60s --interval=15s --timeout=1s --retries=60 CMD curl -q http://localhost/${ONTPUB_FAMILY}/ontology/actuator/health | jq -e ".components.custom.details.INITIALIZATION_DONE" \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index eab87f0e..940035d3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,34 +1,36 @@ -version: "3.8" - services: - onto-viewer-server: - container_name: onto-viewer-server - environment: - - ONTPUB_FAMILY=${ONTPUB_FAMILY:-dev} - - UPDATE_URL + fibo-strapi: + image: edmcouncil/fibo-strapi:latest + volumes: + - opt:/opt + fibo-pages: + image: edmcouncil/fibo-pages:latest + environment: + - STRAPI_URL=http://fibo-strapi:1337 + volumes: + - opt:/opt + depends_on: + - fibo-strapi + fibo-viewer: + image: edmcouncil/onto-viewer:latest build: context: . - dockerfile: ./docker/server/Dockerfile + dockerfile: ./Dockerfile.onto-viewer + 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:latest + environment: + - FAMILY_REGEX=fibo + volumes: + - opt:/opt + depends_on: + - fibo-strapi + - fibo-pages + - fibo-viewer ports: - - "6101:8080" + - 8080:80 - 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 - web-with-strapi: - container_name: onto-viewer-web-with-strapi - environment: - - PUBLIC_URL=0.0.0.0 - - NUXT_PORT=3000 - - ONTPUB_FAMILY=${ONTPUB_FAMILY:-dev} - build: - context: ./docker/web - ports: - - 3000:3000 - - 1337:1337 - networks: - - default \ No newline at end of file +volumes: + opt: diff --git a/onto-viewer-web-app/entrypoint.sh b/onto-viewer-web-app/entrypoint.sh new file mode 100644 index 00000000..5c34b8ae --- /dev/null +++ b/onto-viewer-web-app/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +for i in config/default_* ; do + test -e config/${i#config/default_} || cp -av ${i} config/${i#config/default_} +done + +# if no UPDATE_URL and no ontology files in "ontologies" directory then copy ontology files from "integration_tests/ontologies/" +if [ -z "${UPDATE_URL}" ] && [ $(find ontologies/ -type f | wc -l) -eq 0 ] ; then + find integration_tests/ontologies/ -type f -exec cp -av "{}" ontologies/ \; +fi + +echo "[INFO] Starting app.war..." +exec java -server -Xmx4G -XX:-UseGCOverheadLimit -Dserver.address=0.0.0.0 -Dserver.port=80 -Dserver.forward-headers-strategy=native -Dserver.tomcat.redirect-context-root=false \ + ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar /app.war --server.servlet.context-path=/${ONTPUB_FAMILY:-dev}/ontology From b6e70ce2a86777905004588e814cc7268fde14c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Mon, 12 Jun 2023 09:28:12 +0200 Subject: [PATCH 07/12] New docker compose - fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Przemysław Grądzki --- .gitignore | 2 + Dockerfile.onto-viewer | 22 ++-- README.md | 99 +++++++++----- docker-compose.dev.yaml | 52 ++++++++ docker-compose.yaml | 30 +++-- docker/init-onto-viewer.sh | 23 ---- docker/server/Dockerfile | 13 -- docker/web/.dockerignore | 1 - docker/web/Dockerfile | 12 -- docker/web/init-web-and-strapi.sh | 27 ---- docker/web/nuxt.config.js | 206 ------------------------------ onto-viewer-web-app/entrypoint.sh | 5 - 12 files changed, 153 insertions(+), 339 deletions(-) create mode 100644 docker-compose.dev.yaml delete mode 100644 docker/init-onto-viewer.sh delete mode 100644 docker/server/Dockerfile delete mode 100644 docker/web/.dockerignore delete mode 100644 docker/web/Dockerfile delete mode 100644 docker/web/init-web-and-strapi.sh delete mode 100644 docker/web/nuxt.config.js diff --git a/.gitignore b/.gitignore index 0a8df84f..1e0b5ae6 100644 --- a/.gitignore +++ b/.gitignore @@ -205,6 +205,7 @@ nbactions.xml **/api.key **/updateHistory.json /web-app/fiboMapper/fibo/** +.env # Protege @@ -216,6 +217,7 @@ docker/runtime/ lucene_index/ download/ onto-viewer-web-app/config/ +onto-viewer-web-app/ontologies/* # Mac .DS_Store \ No newline at end of file diff --git a/Dockerfile.onto-viewer b/Dockerfile.onto-viewer index 1eaf741e..86723b1b 100644 --- a/Dockerfile.onto-viewer +++ b/Dockerfile.onto-viewer @@ -1,23 +1,21 @@ FROM maven:3.8.1-jdk-11-openj9 AS build-onto-viewer -SHELL ["/bin/bash", "-c"] +SHELL ["/bin/bash", "-c"] RUN apt-get update && \ - apt-get -y install curl unzip zip -RUN mkdir -p /opt/develop + 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 /app.war FROM adoptopenjdk/openjdk11-openj9:alpine-slim -ARG ONTPUB_FAMILY dev -ARG UPDATE_URL -ENV ONTPUB_FAMILY ${ONTPUB_FAMILY} -ENV UPDATE_URL ${UPDATE_URL} +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,ontologies} + 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 /opt/viewer/integration_tests -COPY ./onto-viewer-web-app/staticOntologies /opt/viewer/staticOntologies +COPY ./onto-viewer-web-app/entrypoint.sh /opt/viewer/entrypoint.sh +COPY ./onto-viewer-web-app/integration_tests/ontologies /opt/viewer/ +COPY ./onto-viewer-web-app/staticOntologies /opt/viewer/staticOntologies COPY --from=build-onto-viewer /app.war /app.war CMD ["sh", "entrypoint.sh"] -HEALTHCHECK --start-period=60s --interval=15s --timeout=1s --retries=60 CMD curl -q http://localhost/${ONTPUB_FAMILY}/ontology/actuator/health | jq -e ".components.custom.details.INITIALIZATION_DONE" \ No newline at end of file +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" \ No newline at end of file diff --git a/README.md b/README.md index 3ba85c99..aefc6365 100644 --- a/README.md +++ b/README.md @@ -30,55 +30,90 @@ java -jar app-v-0.1.0.war ``` - ## Running in Docker - -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/). - -The `onto-viewer/` folder is root/main project folder. All folders below are relative to this folder. - - In the `docker/runtime/server/` folder, you must put configuration(in the `config` folder) and ontologies(in the `ontologies` folder) files if used. You can find samples of these files in the `onto-viewer-config-loader/src/main/resources`, you should rename the files - remove the default_ prefix. Note that the `docker/runtime/ `folder is excluded from Git, so you can freely put there any file you want. - -Then, from the root folder run the following command to start the applications: +## 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/install/linux/) +- free port **8080/tcp** + +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 +``` +After some time, check the status of running containers: ``` -docker compose up --build -d +docker compose ps ``` -Please note that it takes a while to for all services to start depending on how many ontologies you provided. +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 -After all ontologies are loaded, the Onto Viewer will be accessible from http://localhost:3000/dev/ontology. +``` +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: *edmc-strapi@dev.com*, Password: *devDBonly1*) -You can see all running containers and their status: +It is possible to run containers with the `dev` ontology (instead of `FIBO`): +- use the `docker-compose.dev.yaml` file (instead of the default `docker-compose.yaml`): + ``` + echo COMPOSE_FILE=docker-compose.dev.yaml >> .env + ``` -``` -$ docker compose ps +- optionally place the ontology files in the `onto-viewer-web-app/ontologies` subdirectory + and uncomment the following entry + (see [comment](./docker-compose.dev.yaml#L31) in the `docker-compose.dev.yaml` file): + ``` + - ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies + ``` -NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS -onto-viewer-server-1 onto-viewer-server "docker-entrypoint.s…" onto-viewer-server 20 seconds ago Up 17 seconds 0.0.0.0:8080->6101/tcp -web-with-strapi-1 web-with-strapi "docker-entrypoint.s…" web-with-strapi 4 hours ago Up 17 seconds 0.0.0.0:1337->1337/tcp -``` +- build the images and run the containers. After all ontologies are loaded, + the Onto Viewer will be accessible from `http://localhost:8080/dev/ontology` -If you want to see logs from one container use: -``` -# to view continuous log output -# where "" is "onto-viewer-server" or "web-with-strapi" -$ docker compose logs --follow +If you want to see the logs use: +```bash +# to view continuous log output for =fibo-viewer +docker compose logs --follow fibo-viewer -# to view specific amount of logs -# where "" is amount of logs and "" is "onto-viewer-server" or "web-with-strapi" -$ docker compose logs --tail +# to view *100* latest log lines for =fibo-viewer +docker compose logs --tail 100 fibo-strapi ``` -To stop the applications run: - -``` +Stop the services with the command: +```bash docker compose down ``` -You could also run docker compose without detached mode(without -d). If so, you'll just use '^C' to kill all containers. - +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. diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml new file mode 100644 index 00000000..e153970e --- /dev/null +++ b/docker-compose.dev.yaml @@ -0,0 +1,52 @@ +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: . + dockerfile: ./Dockerfile.onto-viewer + environment: + - ONTPUB_FAMILY=dev + # uncomment to use custom ontology files located in the "./onto-viewer-web-app/ontologies" directory + #volumes: + # - ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies + 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: diff --git a/docker-compose.yaml b/docker-compose.yaml index 940035d3..4b6ae2a4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,18 +1,28 @@ services: fibo-strapi: - image: edmcouncil/fibo-strapi:latest + image: edmcouncil/fibo-strapi:${HTML_BRANCH:-latest} + build: + context: https://github.com/edmcouncil/html-pages.git#${HTML_BRANCH:-develop}:general/strapi + args: + - ONTPUB_FAMILY=fibo + - BRANCH_NAME=${HTML_BRANCH:-develop} volumes: - - opt:/opt + - spec_root:/opt/html-pages fibo-pages: - image: edmcouncil/fibo-pages:latest + image: edmcouncil/fibo-pages:${HTML_BRANCH:-latest} + build: + 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: - - opt:/opt + - spec_root:/opt/html-pages depends_on: - fibo-strapi fibo-viewer: - image: edmcouncil/onto-viewer:latest + image: edmcouncil/onto-viewer:${TAG:-latest} build: context: . dockerfile: ./Dockerfile.onto-viewer @@ -20,11 +30,15 @@ services: - ONTPUB_FAMILY=fibo - UPDATE_URL=${FIBO_UPDATE_URL:-https://spec.edmcouncil.org/fibo/ontology/etc/onto-viewer-web-app/config/} spec: - image: edmcouncil/spec:latest + 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=fibo volumes: - - opt:/opt + - spec_root:/opt/html-pages depends_on: - fibo-strapi - fibo-pages @@ -33,4 +47,4 @@ services: - 8080:80 volumes: - opt: + spec_root: diff --git a/docker/init-onto-viewer.sh b/docker/init-onto-viewer.sh deleted file mode 100644 index 7b4b8365..00000000 --- a/docker/init-onto-viewer.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -echo "[INFO] Starting 'init-onto-viewer' installer..." - -INIT_DIR=$(pwd) -INSTALL_DIR="$INIT_DIR/install_dir" - -cp -r src/ "$INSTALL_DIR" -if [ -d "$INSTALL_DIR" ]; then - cd "$INSTALL_DIR" - mvn clean package -else - echo "$INSTALL_DIR hasn't been created. Exiting..." - exit 1 -fi - -echo "[INFO] Moving to $INIT_DIR..." -cd "$INIT_DIR" -cp "$INSTALL_DIR"/onto-viewer-web-app/target/onto-viewer-web-app-*.war app.war - -echo "[INFO] Starting app.war..." -exec java ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar app.war --server.servlet.context-path=/${ONTPUB_FAMILY:-dev}/ontology --app.defaultHomePath="$INIT_DIR/app_home" - diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile deleted file mode 100644 index a3c3d296..00000000 --- a/docker/server/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM maven:3.8.1-jdk-11-openj9 - -SHELL ["/bin/bash", "-c"] - -RUN apt-get update -RUN apt-get -y install curl \ - unzip \ - zip - -RUN mkdir -p /opt/develop -WORKDIR /opt/develop - -CMD ["sh", "init-onto-viewer.sh"] \ No newline at end of file diff --git a/docker/web/.dockerignore b/docker/web/.dockerignore deleted file mode 100644 index b512c09d..00000000 --- a/docker/web/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile deleted file mode 100644 index 80535979..00000000 --- a/docker/web/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM node:16-alpine -# Installing libvips-dev for sharp Compatibility -RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev git -ARG NODE_ENV=development -ENV NODE_ENV=${NODE_ENV} -WORKDIR /opt/ -COPY ./ . -EXPOSE 1337 -EXPOSE 3000 -CMD ["sh", "init-web-and-strapi.sh"] -# ENV HOST=0.0.0.0 - diff --git a/docker/web/init-web-and-strapi.sh b/docker/web/init-web-and-strapi.sh deleted file mode 100644 index cc90dbcb..00000000 --- a/docker/web/init-web-and-strapi.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -echo "[INFO] Clone html pages" -git clone https://github.com/edmcouncil/html-pages.git - -cd /opt/html-pages/general/strapi - -echo "[INFO] Install strapi without run." -npx create-strapi-app@latest strapi-dashboard --quickstart --no-run - -echo "[INFO] Copy database." -mkdir ./strapi-dashboard/.tmp -cp ./.tmp/${ONTPUB_FAMILY:-data}.db ./strapi-dashboard/.tmp/data.db - -echo "[INFO] Copy structures." -cp -R ./src/ ./strapi-dashboard - -echo "[INFO] Run Strapi." -cd strapi-dashboard -npm run develop & - -echo "[INFO] Install and run general web pages" -cd /opt/html-pages/general -rm nuxt.config.js -cp ../../nuxt.config.js . -npm install -npm run build -npm run dev diff --git a/docker/web/nuxt.config.js b/docker/web/nuxt.config.js deleted file mode 100644 index e8932fe0..00000000 --- a/docker/web/nuxt.config.js +++ /dev/null @@ -1,206 +0,0 @@ -import axios from "axios"; - -process.env.VUE_APP_TIMESTAMP = - process.env.TIMESTAMP || process.env.VUE_ONTOLOGY_NAME==='idmp'?"latest":"2022Q3"; - -process.env.VUE_APP_PRODUCT = - process.env.PRODUCT || - process.env.ontology_publisher_current_product || - "pages"; -process.env.VUE_APP_BRANCH = ( - process.env.BRANCH || - (process.env.BRANCH_NAME === process.env.TAG_NAME - ? "develop" - : process.env.BRANCH_NAME || "develop") -).toLowerCase(); -process.env.VUE_APP_TAG = process.env.TAG || process.env.TAG_NAME || "latest"; - -process.env.VUE_DIST_DIR = `/${process.env.VUE_APP_PRODUCT}/${process.env.VUE_APP_BRANCH}/${process.env.VUE_APP_TAG}`; -process.env.VUE_ASSETS_DIR = `${process.env.VUE_DIST_DIR}/_nuxt/`; - -process.env.VUE_ONTOLOGY_NAME = process.env.ONTPUB_FAMILY || "dev"; -process.env.VUE_BASE_URL = - process.env.BASE_URL || - "https://spec." + - (process.env.VUE_ONTOLOGY_NAME === "idmp" - ? "pistoiaalliance" - : "edmcouncil") + - ".org/"; - -process.env.VUE_RESOURCES_BASE_URL = process.env.VUE_BASE_URL + process.env.VUE_ONTOLOGY_NAME + "/ontology/"; - -process.env.STRAPI_URL = process.env.STRAPI_URL || "http://localhost:1337"; - -export default { - // target: 'static' description https://nuxtjs.org/announcements/going-full-static/ - target: "static", - // Global page headers: https://go.nuxtjs.dev/config-head - head: { - title: process.env.VUE_ONTOLOGY_NAME.toUpperCase(), - htmlAttrs: { - lang: "en", - }, - meta: [ - { charset: "utf-8" }, - { name: "viewport", content: "width=device-width, initial-scale=1" }, - { hid: "description", name: "description", content: "" }, - { - hid: "keywords", - name: "keywords", - content: - "ontology, Open Knowledge Graph, OKG, EDM Council, Enterprise Data Management Council", - }, - { name: "format-detection", content: "telephone=no" }, - ], - link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }], - script: [ - { - src: "https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js", - integrity: - "sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj", - crossorigin: "anonymous", - }, - { - src: "https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js", - integrity: - "sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN", - crossorigin: "anonymous", - }, - { - src: "https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js", - integrity: - "sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2", - crossorigin: "anonymous", - }, - ], - }, - server: { - host: process.env.PUBLIC_URL || "localhost", - }, - router: { - base: `/${process.env.VUE_ONTOLOGY_NAME}`, - }, - - //to removed - generate: { - dir: `dist/${process.env.VUE_ONTOLOGY_NAME}${process.env.VUE_DIST_DIR}`, - routes() { - return axios - .get(`${process.env.STRAPI_URL || "http://localhost:1337"}/api/pages`) - .then((res) => { - return res.data.data.map((page) => { - const slug = page.attributes.slug; - return `/page/${slug}`; - }); - }); - }, - }, - - // loading bar - loading: { - color: "black", - height: "5px", - }, - - // Global CSS: https://go.nuxtjs.dev/config-css - css: ["./assets/scss/Ontology.scss"], - - // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins - plugins: [ - { src: "~/plugins/vue-multiselect" }, - { src: "~/plugins/v-clipboard" }, - ], - - // Auto import components: https://go.nuxtjs.dev/config-components - components: { - dirs: [ - "~/components", - "~/components/Articles", - "~/components/chunks", - "~/components/Ontology", - ], - }, - - // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules - buildModules: [ - [ - "@nuxtjs/google-fonts", - { - families: { - Inter: { - wght: [300, 400, 500], - }, - }, - display: "swap", - prefetch: false, - preconnect: false, - preload: false, - download: true, - base64: false, - }, - ], - ], - - // Modules: https://go.nuxtjs.dev/config-modules - modules: [ - "@nuxtjs/style-resources", - "bootstrap-vue/nuxt", - "@nuxtjs/markdownit", - "@nuxtjs/proxy", - ], - - // Build Configuration: https://go.nuxtjs.dev/config-build - build: { - standalone: true, - publicPath: process.env.VUE_ASSETS_DIR, - loaders: { - sass: { - implementation: require("sass"), - }, - scss: { - implementation: require("sass"), - }, - }, - extend(config) { - config.resolve.alias.vue = "vue/dist/vue.common"; - }, - }, - - env: { - generateDir: `dist/${process.env.VUE_ONTOLOGY_NAME}`, - ontologyName: process.env.VUE_ONTOLOGY_NAME, - assetsDir: process.env.VUE_ASSETS_DIR, - distDir: process.env.VUE_DIST_DIR, - staticGenerationMode: process.env.NODE_ENV === "production", - ontologyResourcesBaseUri: process.env.VUE_RESOURCES_BASE_URL, - strapiBaseUrl: process.env.STRAPI_URL, - showTermsLinkOnFooter: process.env.SHOW_TERMS_LINK_ON_FOOTER || true, - }, - - http: { - proxy: process.env.NODE_ENV !== "production", - }, - - proxy: [ - `http://onto-viewer-server:8080/${process.env.VUE_ONTOLOGY_NAME}/ontology/api`, - `http://onto-viewer-server:8080/${process.env.VUE_ONTOLOGY_NAME}/ontology/*/api`, - ], - - styleResources: { - scss: [ - "~assets/scss/_variables.scss", - "~assets/scss/_bootstrap-override.scss", - "~assets/scss/global.scss", - "~assets/scss/typography.scss", - "~assets/scss/highlight.scss", - ], - }, - - markdownit: { - preset: "default", - linkify: true, - breaks: true, - use: ["markdown-it-div", "markdown-it-attrs", "markdown-it-highlightjs"], - runtime: true, - }, -}; diff --git a/onto-viewer-web-app/entrypoint.sh b/onto-viewer-web-app/entrypoint.sh index 5c34b8ae..61038a0f 100644 --- a/onto-viewer-web-app/entrypoint.sh +++ b/onto-viewer-web-app/entrypoint.sh @@ -4,11 +4,6 @@ for i in config/default_* ; do test -e config/${i#config/default_} || cp -av ${i} config/${i#config/default_} done -# if no UPDATE_URL and no ontology files in "ontologies" directory then copy ontology files from "integration_tests/ontologies/" -if [ -z "${UPDATE_URL}" ] && [ $(find ontologies/ -type f | wc -l) -eq 0 ] ; then - find integration_tests/ontologies/ -type f -exec cp -av "{}" ontologies/ \; -fi - echo "[INFO] Starting app.war..." exec java -server -Xmx4G -XX:-UseGCOverheadLimit -Dserver.address=0.0.0.0 -Dserver.port=80 -Dserver.forward-headers-strategy=native -Dserver.tomcat.redirect-context-root=false \ ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar /app.war --server.servlet.context-path=/${ONTPUB_FAMILY:-dev}/ontology From 080115f1428becad71df3114feadeb70c4dcbca4 Mon Sep 17 00:00:00 2001 From: mereolog Date: Mon, 19 Jun 2023 11:12:31 +0200 Subject: [PATCH 08/12] dev config management Signed-off-by: mereolog --- .gitignore | 1 + README.md | 9 ++++++++- docker-compose.dev.yaml | 5 +++-- onto-viewer-web-app/ontologies | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) create mode 160000 onto-viewer-web-app/ontologies diff --git a/.gitignore b/.gitignore index 1e0b5ae6..857e9fa0 100644 --- a/.gitignore +++ b/.gitignore @@ -218,6 +218,7 @@ lucene_index/ download/ onto-viewer-web-app/config/ onto-viewer-web-app/ontologies/* +docker-compose.dev.yaml # Mac .DS_Store \ No newline at end of file diff --git a/README.md b/README.md index aefc6365..e0d55e10 100644 --- a/README.md +++ b/README.md @@ -85,13 +85,20 @@ It is possible to run containers with the `dev` ontology (instead of `FIBO`): echo COMPOSE_FILE=docker-compose.dev.yaml >> .env ``` -- optionally place the ontology files in the `onto-viewer-web-app/ontologies` subdirectory +- place the ontology files in the `onto-viewer-web-app/ontologies` subdirectory and uncomment the following entry (see [comment](./docker-compose.dev.yaml#L31) in the `docker-compose.dev.yaml` file): ``` - ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies ``` +- place the config files in the `onto-viewer-web-app/config` subdirectory + and uncomment the following entry + (see [comment](./docker-compose.dev.yaml#L31) in the `docker-compose.dev.yaml` file): + ``` + - ./onto-viewer-web-app/ontologies:/opt/viewer/config + ``` + - build the images and run the containers. After all ontologies are loaded, the Onto Viewer will be accessible from `http://localhost:8080/dev/ontology` diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index e153970e..878fdc73 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -28,9 +28,10 @@ services: dockerfile: ./Dockerfile.onto-viewer environment: - ONTPUB_FAMILY=dev - # uncomment to use custom ontology files located in the "./onto-viewer-web-app/ontologies" directory + # uncomment to use custom ontology and config files located in, respectively, "./onto-viewer-web-app/ontologies" and "./onto-viewer-web-app/config" folders #volumes: - # - ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies + # - ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies + # - ./onto-viewer-web-app/config:/opt/viewer/config spec: image: edmcouncil/spec:${HTML_BRANCH:-latest} build: diff --git a/onto-viewer-web-app/ontologies b/onto-viewer-web-app/ontologies new file mode 160000 index 00000000..487882fc --- /dev/null +++ b/onto-viewer-web-app/ontologies @@ -0,0 +1 @@ +Subproject commit 487882fcdbacf78b74aa1c3c415da9af8e189c0a From 09c2c84735a8eea33b5add482ca197df91f64308 Mon Sep 17 00:00:00 2001 From: mereolog Date: Mon, 19 Jun 2023 11:14:35 +0200 Subject: [PATCH 09/12] dev config management Signed-off-by: mereolog --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0d55e10..6869bb69 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ It is possible to run containers with the `dev` ontology (instead of `FIBO`): and uncomment the following entry (see [comment](./docker-compose.dev.yaml#L31) in the `docker-compose.dev.yaml` file): ``` - - ./onto-viewer-web-app/ontologies:/opt/viewer/config + - ./onto-viewer-web-app/config:/opt/viewer/config ``` - build the images and run the containers. After all ontologies are loaded, From c2fe105c0f95bd6d99e8ba3c75b7233101918e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Thu, 22 Jun 2023 20:09:37 +0200 Subject: [PATCH 10/12] New docker compose - last fixes and cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Przemysław Grądzki --- .gitignore | 3 +-- Dockerfile.onto-viewer => Dockerfile | 6 +++--- README.md | 29 +++++++++------------------- docker-compose.dev.yaml | 8 +++----- docker-compose.yaml | 1 - onto-viewer-web-app/config/.gitkeep | 0 onto-viewer-web-app/entrypoint.sh | 6 +----- 7 files changed, 17 insertions(+), 36 deletions(-) rename Dockerfile.onto-viewer => Dockerfile (87%) create mode 100644 onto-viewer-web-app/config/.gitkeep diff --git a/.gitignore b/.gitignore index 857e9fa0..f36087e6 100644 --- a/.gitignore +++ b/.gitignore @@ -216,9 +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/* -docker-compose.dev.yaml # Mac .DS_Store \ No newline at end of file diff --git a/Dockerfile.onto-viewer b/Dockerfile similarity index 87% rename from Dockerfile.onto-viewer rename to Dockerfile index 86723b1b..619a3eab 100644 --- a/Dockerfile.onto-viewer +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update && \ 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 /app.war +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 @@ -14,8 +14,8 @@ 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/ +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 /app.war /app.war +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" \ No newline at end of file diff --git a/README.md b/README.md index 6869bb69..20afe0e5 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,7 @@ 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/install/linux/) -- free port **8080/tcp** + * [Docker Engine](https://docs.docker.com/engine/) with [Docker Compose plugin](https://docs.docker.com/compose/) How to start: Clone the [edmcouncil/onto-viewer](https://github.com/edmcouncil/onto-viewer) repository to the *onto-viewer* directory, @@ -80,28 +79,18 @@ The services provide endpoints at the following URLs: - [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: *edmc-strapi@dev.com*, Password: *devDBonly1*) It is possible to run containers with the `dev` ontology (instead of `FIBO`): -- use the `docker-compose.dev.yaml` file (instead of the default `docker-compose.yaml`): - ``` - echo COMPOSE_FILE=docker-compose.dev.yaml >> .env - ``` - - place the ontology files in the `onto-viewer-web-app/ontologies` subdirectory - and uncomment the following entry - (see [comment](./docker-compose.dev.yaml#L31) in the `docker-compose.dev.yaml` file): - ``` - - ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies - ``` + and the config files in the `onto-viewer-web-app/config` subdirectory -- place the config files in the `onto-viewer-web-app/config` subdirectory - and uncomment the following entry - (see [comment](./docker-compose.dev.yaml#L31) in the `docker-compose.dev.yaml` file): - ``` - - ./onto-viewer-web-app/config:/opt/viewer/config +- 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 ``` -- build the images and run the containers. After all ontologies are loaded, - the Onto Viewer will be accessible from `http://localhost:8080/dev/ontology` - + once all services are up and running, Onto Viewer will be available at `http://localhost:8080/dev/ontology` If you want to see the logs use: ```bash diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 878fdc73..725fe368 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -25,13 +25,11 @@ services: image: edmcouncil/onto-viewer:${TAG:-latest} build: context: . - dockerfile: ./Dockerfile.onto-viewer environment: - ONTPUB_FAMILY=dev - # uncomment to use custom ontology and config files located in, respectively, "./onto-viewer-web-app/ontologies" and "./onto-viewer-web-app/config" folders - #volumes: - # - ./onto-viewer-web-app/ontologies:/opt/viewer/ontologies - # - ./onto-viewer-web-app/config:/opt/viewer/config + 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: diff --git a/docker-compose.yaml b/docker-compose.yaml index 4b6ae2a4..b7beca36 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -25,7 +25,6 @@ services: image: edmcouncil/onto-viewer:${TAG:-latest} build: context: . - dockerfile: ./Dockerfile.onto-viewer environment: - ONTPUB_FAMILY=fibo - UPDATE_URL=${FIBO_UPDATE_URL:-https://spec.edmcouncil.org/fibo/ontology/etc/onto-viewer-web-app/config/} diff --git a/onto-viewer-web-app/config/.gitkeep b/onto-viewer-web-app/config/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/onto-viewer-web-app/entrypoint.sh b/onto-viewer-web-app/entrypoint.sh index 61038a0f..5bc8b6ec 100644 --- a/onto-viewer-web-app/entrypoint.sh +++ b/onto-viewer-web-app/entrypoint.sh @@ -1,9 +1,5 @@ #!/bin/bash -for i in config/default_* ; do - test -e config/${i#config/default_} || cp -av ${i} config/${i#config/default_} -done - echo "[INFO] Starting app.war..." exec java -server -Xmx4G -XX:-UseGCOverheadLimit -Dserver.address=0.0.0.0 -Dserver.port=80 -Dserver.forward-headers-strategy=native -Dserver.tomcat.redirect-context-root=false \ - ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar /app.war --server.servlet.context-path=/${ONTPUB_FAMILY:-dev}/ontology + ${UPDATE_URL:+ -Dapp.config.ontologies.download_directory=download -Dapp.config.updateUrl=${UPDATE_URL}} -jar onto-viewer.war --server.servlet.context-path=/${ONTPUB_FAMILY:-dev}/ontology From 181a8fb7f1515234b26a09301ff898102dec74de Mon Sep 17 00:00:00 2001 From: Pawel Garbacz Date: Fri, 23 Jun 2023 16:43:13 +0200 Subject: [PATCH 11/12] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 20afe0e5..2a6ed59a 100644 --- a/README.md +++ b/README.md @@ -78,8 +78,8 @@ The services provide endpoints at the following URLs: - [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: *edmc-strapi@dev.com*, Password: *devDBonly1*) -It is possible to run containers with the `dev` ontology (instead of `FIBO`): -- place the ontology files in the `onto-viewer-web-app/ontologies` subdirectory +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 - using the `docker-compose.dev.yaml` compose file (instead of the default `docker-compose.yaml`), @@ -90,7 +90,7 @@ It is possible to run containers with the `dev` ontology (instead of `FIBO`): docker compose up -d ``` - once all services are up and running, Onto Viewer will be available at `http://localhost:8080/dev/ontology` + once all services are up and running, onto-viewer with your ontology will be available at `http://localhost:8080/dev/ontology` If you want to see the logs use: ```bash From 17ef8363bc784460abf153fdc9c9241ee8642cb3 Mon Sep 17 00:00:00 2001 From: Pawel Garbacz Date: Fri, 23 Jun 2023 16:45:17 +0200 Subject: [PATCH 12/12] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 2a6ed59a..784428fd 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Requirements: * [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), @@ -78,6 +80,9 @@ The services provide endpoints at the following URLs: - [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: *edmc-strapi@dev.com*, Password: *devDBonly1*) + +### ... with an ontology of your choice + 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