diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dcd3346372..8df140f5c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,4 +30,4 @@ jobs: - name: Maven Build run: | cd ../VIVO - mvn clean package -s installer/example-settings.xml + mvn clean install diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bde1e3a39f..a9aad97e1b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,7 +37,7 @@ jobs: - name: Maven Deploy run: | cd ../VIVO - mvn --batch-mode deploy -Pskip + mvn --batch-mode deploy env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 73466c2ed4..ccd12ea038 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,7 +34,7 @@ jobs: - name: Maven Build run: | cd ../VIVO - mvn clean package -s installer/example-settings.xml + mvn clean install - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -47,7 +47,7 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Build and push id: docker_build uses: docker/build-push-action@v2 diff --git a/Dockerfile b/Dockerfile index 6632d8b3b9..be98e557c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,15 +4,17 @@ ARG SOLR_URL=http://localhost:8983/solr/vivocore ARG VIVO_DIR=/usr/local/vivo/home ARG TDB_FILE_MODE=direct +ENV VIVO_DIR=${VIVO_DIR} ENV SOLR_URL=${SOLR_URL} -ENV JAVA_OPTS="${JAVA_OPTS} -Dtdb:fileMode=$TDB_FILE_MODE" +ENV JAVA_OPTS="${JAVA_OPTS} -Dvivo-dir=$VIVO_DIR -Dtdb:fileMode=$TDB_FILE_MODE" -RUN mkdir /usr/local/vivo -RUN mkdir /usr/local/vivo/home +RUN mkdir -p $VIVO_DIR -COPY ./installer/home/target/vivo /vivo-home COPY ./installer/webapp/target/vivo.war /usr/local/tomcat/webapps/ROOT.war +COPY ./home/src/main/resources/config/default.applicationSetup.n3 /applicationSetup.n3 +COPY ./home/src/main/resources/config/default.runtime.properties /runtime.properties + COPY start.sh /start.sh EXPOSE 8080 diff --git a/README.md b/README.md index b9a89d62b5..a8c28c74ce 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,12 @@ RESET_CORE=false - `RESET_HOME`: Convenience to reset VIVO home when starting container. **Caution**, will delete local configuration, content, and configuration model. - `RESET_CORE`: Convenience to reset VIVO Solr core when starting container. **Caution**, will require complete reindex. -Before building VIVO, you will also need to clone (and switch to the same branch, if other than main) of [Vitro](https://github.com/vivo-project/Vitro). The Vitro project must be cloned to a sibling directory next to VIVO so that it can be found during the build. +Before building VIVO, you will also need to clone (and switch to the same branch, if other than main) of [Vitro](https://github.com/vivo-project/Vitro). The Vitro project must be cloned to a sibling directory next to VIVO so that it can be found during the build. Build and start VIVO. -1. In VIVO (with Vitro cloned alongside it), run: ``` -mvn clean package -s installer/example-settings.xml +mvn clean package docker-compose up ``` diff --git a/docker-compose.yml b/docker-compose.yml index d47dcf7d0d..17022507e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: context: ./ dockerfile: Dockerfile args: - - VIVO_DIR=/usr/local/vivo/home + - VIVO_DIR=/opt/vivo/home - TDB_FILE_MODE=direct - SOLR_URL=http://solr:8983/solr/vivocore environment: @@ -28,9 +28,11 @@ services: ports: - 8080:8080 volumes: - - ${LOCAL_VIVO_HOME}:/usr/local/vivo/home + - ${LOCAL_VIVO_HOME}:/opt/vivo/home networks: - vivo + depends_on: + - solr networks: vivo: diff --git a/home/pom.xml b/home/pom.xml index 86c24e05d4..f08b6c7af1 100644 --- a/home/pom.xml +++ b/home/pom.xml @@ -69,4 +69,4 @@ tar.gz - \ No newline at end of file + diff --git a/home/src/main/resources/config/example.applicationSetup.n3 b/home/src/main/resources/config/default.applicationSetup.n3 similarity index 100% rename from home/src/main/resources/config/example.applicationSetup.n3 rename to home/src/main/resources/config/default.applicationSetup.n3 diff --git a/home/src/main/resources/config/example.runtime.properties b/home/src/main/resources/config/default.runtime.properties similarity index 96% rename from home/src/main/resources/config/example.runtime.properties rename to home/src/main/resources/config/default.runtime.properties index 0f22433b70..317b11e96f 100644 --- a/home/src/main/resources/config/example.runtime.properties +++ b/home/src/main/resources/config/default.runtime.properties @@ -19,26 +19,6 @@ # BASIC PROPERTIES # ----------------------------------------------------------------------------- - # - # This namespace will be used when generating URIs for objects created in the - # editor. In order to serve linked data, the default namespace must be composed - # as follows (optional elements in parentheses): - # - # scheme + server_name (+ port) (+ servlet_context) + "/individual/" - # - # For example, Cornell's default namespace is: - # - # http://vivo.cornell.edu/individual/ - # -Vitro.defaultNamespace = http://vivo.mydomain.edu/individual/ - - # - # The email address of the root user for the VIVO application. The password - # for this user is initially set to "rootPassword", but you will be asked to - # change the password the first time you log in. - # -rootUser.emailAddress = vivo_root@mydomain.edu - # # Argon2 password hashing parameters for time, memory and parallelism required to # compute a hash. diff --git a/installer/example-settings.xml b/installer/example-settings.xml deleted file mode 100644 index cae40e61b1..0000000000 --- a/installer/example-settings.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - defaults - - vivo - - /usr/local/vivo/home - /usr/local/tomcat - - wilma - - - - - - defaults - - diff --git a/installer/home/pom.xml b/installer/home/pom.xml index 932f43ea6a..6d89944de1 100644 --- a/installer/home/pom.xml +++ b/installer/home/pom.xml @@ -18,86 +18,24 @@ wilma - - - install - - vivo-dir - - - ${app-name} - - - maven-assembly-plugin - - - src/main/assembly/home.xml - - false - - - - package - - single - - - - - - maven-antrun-plugin - - - remove-webapp - verify - - run - - - - - - - - - - - - - - - - maven-resources-plugin - - - install - install - - copy-resources - - - ${vivo-dir} - - - ${project.build.directory}/${project.build.finalName} - - - - - - - - - - - - maven-install-plugin + maven-assembly-plugin - true + + src/main/assembly/home.xml + + false + + + package + + single + + + diff --git a/installer/home/src/main/assembly/home.xml b/installer/home/src/main/assembly/home.xml index 6de97e21d7..34f447c0ae 100644 --- a/installer/home/src/main/assembly/home.xml +++ b/installer/home/src/main/assembly/home.xml @@ -4,6 +4,7 @@ home dir + tar false diff --git a/installer/pom.xml b/installer/pom.xml index 5b3eaa5432..758760cf31 100644 --- a/installer/pom.xml +++ b/installer/pom.xml @@ -10,6 +10,7 @@ VIVO Installer + vivo ${project.version} true UTF-8 @@ -24,12 +25,6 @@ UTF-8 - - maven-install-plugin - - true - - org.apache.maven.plugins maven-gpg-plugin @@ -150,12 +145,6 @@ - - maven-dependency-plugin - - true - - maven-resources-plugin 2.6 @@ -179,45 +168,6 @@ - - maven-war-plugin - - - default-war - - - - - - - - - install - - vivo-dir - - - - - maven-enforcer-plugin - - - enforce-properties - validate - - enforce - - - - - app-name - You must provide an application name (app-name) - - - - - - @@ -262,4 +212,4 @@ - \ No newline at end of file + diff --git a/installer/webapp/pom.xml b/installer/webapp/pom.xml index 6f5f16513b..0d896cc23a 100644 --- a/installer/webapp/pom.xml +++ b/installer/webapp/pom.xml @@ -2,11 +2,14 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + org.vivoweb vivo-installer-vivo 1.13.1-SNAPSHOT war + org.vivoweb vivo-installer @@ -16,105 +19,9 @@ VIVO Install Web App - - - package - - app-name - - - ${app-name} - - - org.apache.maven.plugins - maven-war-plugin - - - - true - - - false - - - org.vivoweb - vivo-webapp - war - - - - - src/main/webResources - true - - - - - - - - - install - - tomcat-dir - - - - - maven-antrun-plugin - - - remove-webapp - verify - - run - - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - install - install - - unpack - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - war - true - ${tomcat-dir}/webapps/${project.build.finalName} - - - - - - - - - - - + ${app-name} - - maven-install-plugin - - true - - maven-clean-plugin @@ -125,6 +32,63 @@ + + org.apache.maven.plugins + maven-dependency-plugin + + false + + + + include-home + process-resources + + copy + + + + + org.vivoweb + vivo-installer-home + ${project.version} + tar + vivo-home.tar + ${project.build.directory}/home-files + + + + + + + + org.apache.maven.plugins + maven-war-plugin + + + + true + + + false + + + org.vivoweb + vivo-webapp + war + + + + + src/main/webResources + true + + + ${project.build.directory}/home-files/ + WEB-INF/resources/home-files/ + + + + diff --git a/installer/webapp/src/main/webResources/META-INF/context.xml b/installer/webapp/src/main/webResources/META-INF/context.xml index d60bd1ff63..ea94491337 100644 --- a/installer/webapp/src/main/webResources/META-INF/context.xml +++ b/installer/webapp/src/main/webResources/META-INF/context.xml @@ -1,9 +1,52 @@ + + + + + + + + + + + + name="vitro/defaultNamespace" + value="http://vivo.mydomain.edu/individual/" override="true"/> - \ No newline at end of file + diff --git a/installer/webapp/src/main/webResources/WEB-INF/classes/log4j.properties b/installer/webapp/src/main/webResources/WEB-INF/classes/log4j.properties index 5cdfd31cd8..dcf4b59502 100644 --- a/installer/webapp/src/main/webResources/WEB-INF/classes/log4j.properties +++ b/installer/webapp/src/main/webResources/WEB-INF/classes/log4j.properties @@ -24,7 +24,7 @@ # debug.log4j.properties exists will be used instead, if it exists, but is not stored in Subversion. log4j.appender.AllAppender=org.apache.log4j.RollingFileAppender -log4j.appender.AllAppender.File=${catalina.base}/logs/${app-name}.all.log +log4j.appender.AllAppender.File= ${catalina.base}/logs/${app-name}.all.log log4j.appender.AllAppender.MaxFileSize=10MB log4j.appender.AllAppender.MaxBackupIndex=10 log4j.appender.AllAppender.layout=org.apache.log4j.PatternLayout diff --git a/pom.xml b/pom.xml index d429a0db8a..c9b8c142da 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,7 @@ + vivo ${project.version} ${basedir} yyyy-MM-dd HH:mm:ss @@ -542,4 +543,4 @@ https://oss.sonatype.org/service/local/staging/deploy/maven2/ - \ No newline at end of file + diff --git a/start.sh b/start.sh index 0f9ef7d921..049fa447bb 100644 --- a/start.sh +++ b/start.sh @@ -9,52 +9,48 @@ fi # allow easier reset home with `docker run -e RESET_HOME=true` if [[ "$RESET_HOME" = "true" ]]; then - echo 'Clearing VIVO HOME /usr/local/vivo/home' - rm -rf /usr/local/vivo/home/* + echo 'Clearing VIVO HOME $VIVO_DIR' + rm -rf $VIVO_DIR/* fi -# copy home bin if not exists -if [ ! -d /usr/local/vivo/home/bin ]; then - echo "Copying home bin directory to /usr/local/vivo/home/bin" - cp -r /vivo-home/bin /usr/local/vivo/home/bin -fi +# ensure home config directory exists +mkdir -p $VIVO_DIR/config -# copy home config if not exists -if [ ! -d /usr/local/vivo/home/config ]; then - echo "Copying home config directory to /usr/local/vivo/home/config" - cp -r /vivo-home/config /usr/local/vivo/home/config +# generate digest.md5 for existing VIVO home if not already exist +if [ ! -f $VIVO_DIR/digest.md5 ]; then + find $VIVO_DIR -type f | grep -E "^$VIVO_DIR/bin/|^$VIVO_DIR/config/|^$VIVO_DIR/rdf/" | xargs md5sum > $VIVO_DIR/digest.md5 + echo "Generated digest.md5 for VIVO home" + cat $VIVO_DIR/digest.md5 fi -# copy home rdf if not exists -if [ ! -d /usr/local/vivo/home/rdf ]; then - echo "Copying home rdf directory to /usr/local/vivo/home/rdf" - cp -r /vivo-home/rdf /usr/local/vivo/home/rdf -fi +# only move runtime.properties first time and if it does not already exist in target home directory +if [ -f /runtime.properties ]; then + # template runtime.properties vitro.local.solr.url value to $SOLR_URL value + echo "Templating runtime.properties vitro.local.solr.url = $SOLR_URL" + sed -i "s,http://localhost:8983/solr/vivocore,$SOLR_URL,g" /runtime.properties -# copy runtime.properties if it does not already exist in target home directory -if [ -f /usr/local/vivo/home/config/example.runtime.properties ]; then - if [ ! -f /usr/local/vivo/home/config/runtime.properties ] + if [ ! -f $VIVO_DIR/config/runtime.properties ] then - echo "Copying example.runtime.properties to /usr/local/vivo/home/config/runtime.properties" - cp /usr/local/vivo/home/config/example.runtime.properties /usr/local/vivo/home/config/runtime.properties - - # template runtime.properties vitro.local.solr.url value to $SOLR_URL value - echo "Templating runtime.properties vitro.local.solr.url = $SOLR_URL" - sed -i "s,http://localhost:8983/solr/vivocore,$SOLR_URL,g" /usr/local/vivo/home/config/runtime.properties + echo "First time: moving /runtime.properties to $VIVO_DIR/config/runtime.properties" + mv -n /runtime.properties $VIVO_DIR/config/runtime.properties else - echo "Using existing /usr/local/vivo/home/config/runtime.properties" + echo "Using existing $VIVO_DIR/config/runtime.properties" fi fi -# copy applicationSetup.n3 if it does not already exist in target home directory -if [ -f /usr/local/vivo/home/config/example.applicationSetup.n3 ]; then - if [ ! -f /usr/local/vivo/home/config/applicationSetup.n3 ] +# only move applicationSetup.n3 first time and if it does not already exist in target home directory +if [ -f /applicationSetup.n3 ]; then + if [ ! -f $VIVO_DIR/config/applicationSetup.n3 ] then - echo "Copying example.applicationSetup.n3 to /usr/local/vivo/home/config/applicationSetup.n3" - cp /usr/local/vivo/home/config/example.applicationSetup.n3 /usr/local/vivo/home/config/applicationSetup.n3 + echo "First time: moving /applicationSetup.n3 to $VIVO_DIR/config/applicationSetup.n3" + mv -n /applicationSetup.n3 $VIVO_DIR/config/applicationSetup.n3 else - echo "Using existing /usr/local/vivo/home/config/applicationSetup.n3" + echo "Using existing $VIVO_DIR/config/applicationSetup.n3" fi fi +echo "Giving time for Solr to startup..." +sleep 15 +echo "Starting Tomcat" + catalina.sh run