diff --git a/.env b/.env index 64f1337343..934bf6b74c 100644 --- a/.env +++ b/.env @@ -1,22 +1,11 @@ -# Variable substitution for docker-compose.yml +LOCAL_SOLR_PORT=8983 +LOCAL_SOLR_DATA=./vivo-solr +RESET_CORE=false -# solr service variable substitution -SOLR_RESET_CORE=false -SOLR_VERBOSE=no +LOCAL_VIVO_PORT=8080 +LOCAL_VIVO_HOME=./vivo-home +RESET_HOME=false -SOLR_HOST_PORT=8983 -SOLR_CONTAINER_PORT=8983 +VIVO_HOME=/usr/local/vivo/home -SOLR_CORES=./vivo-cores - -# tomcat service variable substitution -VIVO_RESET_HOME=false -VIVO_VERBOSE=no - -VIVO_TDB_FILE_MODE=direct - -VIVO_HOST_VIVO_HOME=./vivo-home -VIVO_CONTAINER_VIVO_HOME=/usr/local/vivo/home - -VIVO_HOST_PORT=8080 -VIVO_CONTAINER_PORT=8080 +VERBOSE=no 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/.gitignore b/.gitignore index fbecea9ce0..f8c758298e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,8 @@ utilities/rdbmigration/.work **/.project **/bin/ -vivo-cores/ +vivo-solr/* +!vivo-solr/solr.xml vivo-home/ .fake diff --git a/Dockerfile b/Dockerfile index a61be8c0af..b27fb6a404 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,44 @@ FROM tomcat:9-jdk11-openjdk +ARG USER_ID=3001 +ARG USER_NAME=vivo +ARG USER_HOME_DIR=/home/$USER_NAME -ARG TDB_FILE_MODE=direct -ARG VIVO_HOME=/usr/local/vivo/home -ARG SOLR_URL=http://localhost:8983/solr/vivocore +ENV TOMCAT_CONTEXT_PATH=ROOT +ENV VIVO_HOME=/usr/local/vivo/home +ENV TDB_FILE_MODE=direct +ENV ROOT_USER_ADDRESS=vivo_root@mydomain.edu +ENV DEFAULT_NAMESPACE=http://vivo.mydomain.edu/individual/ -ENV JAVA_OPTS="${JAVA_OPTS} -Dtdb:fileMode=$TDB_FILE_MODE" -ENV VIVO_HOME=${VIVO_HOME} -ENV SOLR_URL=${SOLR_URL} +ENV SOLR_URL=http://localhost:8983/solr/vivocore +ENV SELF_ID_MATCHING_PROPERTY=http://vivo.mydomain.edu/ns#networkId -RUN mkdir -p ${VIVO_HOME} +ENV LOAD_SAMPLE_DATA=false +ENV SAMPLE_DATA_REPO_URL=https://github.com/vivo-project/sample-data.git +ENV SAMPLE_DATA_BRANCH=main +ENV SAMPLE_DATA_DIRECTORY=i18n -# Copy VIVO home onto image for backup, initialization, and reset -COPY ./installer/home/target/vivo /vivo-home -COPY ./installer/webapp/target/vivo.war /usr/local/tomcat/webapps/ROOT.war +ENV RECONFIGURE=false -COPY start.sh /start.sh +COPY ./installer/webapp/target/vivo.war /tmp/vivo.war + +COPY ./home/src/main/resources/config/default.applicationSetup.n3 /tmp/applicationSetup.n3 +COPY ./home/src/main/resources/config/default.runtime.properties /tmp/runtime.properties + +COPY start.sh /usr/local/vivo/start.sh + +RUN \ +apt-get update -y && \ +apt-get upgrade -y && \ +apt-get install -y git && \ +apt-get clean && \ +rm -rf /var/lib/apt/lists/* && \ +addgroup --disabled-password --gid ${USER_ID} ${USER_NAME} && \ +adduser --disabled-password --home ${USER_HOME_DIR} --uid ${USER_ID} --gid ${USER_ID} ${USER_NAME} && \ +mkdir -p ${VIVO_HOME} && \ +chown -R ${USER_ID}:${USER_ID} ${VIVO_HOME} /usr/local/tomcat /usr/local/vivo /tmp + +USER ${USER_NAME} EXPOSE 8080 -CMD ["/bin/bash", "/start.sh"] +CMD ["/bin/bash", "/usr/local/vivo/start.sh"] diff --git a/README.md b/README.md index 1254e2493c..eb3519d2c8 100644 --- a/README.md +++ b/README.md @@ -21,59 +21,108 @@ https://wiki.lyrasis.org/display/VIVO/ Installation instructions for all releases can be found at this location on the wiki: https://wiki.lyrasis.org/display/VIVODOC/All+Documentation -When you select the wiki pages for technical documentation for the release you would like to install at https://wiki.lyrasis.org/display/VIVODOC/All+Documentation, please open the Installing VIVO section and follow the instructions. +When you select the wiki pages for technical documentation for the release you would like to install at https://wiki.lyrasis.org/display/VIVODOC/All+Documentation, please open the Installing VIVO section and follow the instructions. ### Docker -VIVO docker container is available at [vivoweb/vivo](https://hub.docker.com/repository/docker/vivoweb/vivo) with accompanying [vivoweb/vivo-solr](https://hub.docker.com/repository/docker/vivoweb/vivo-solr). These can be used independently or with docker-compose. +VIVO docker container is available at [vivoweb/vivo](https://hub.docker.com/r/vivoweb/vivo) with accompanying [vivoweb/vivo-solr](https://hub.docker.com/r/vivoweb/vivo-solr). These can be used independently or with docker-compose. + +#### Build Args + +Build args used at time of building the Docker image. + +| Variable | Description | Default | +| ----------------------------- | -----------------------------| ------------------------------------ | +| USER_ID | User id | 3001 | +| USER_NAME | User name | vivo | +| USER_HOME_DIR | User home directory | /home/vivo | + +#### Environment + +| Variable | Description | Default | +| ----------------------------- | ---------------------------------------------------------------- | ----------------------------------------------- | +| TOMCAT_CONTEXT_PATH | Tomcat webapp context path | ROOT | +| VIVO_HOME | VIVO home directory in container | /usr/local/vivo/home | +| TDB_FILE_MODE | TDB file mode | direct | +| ROOT_USER_ADDRESS | Root user email address | vivo_root@mydomain.edu | +| DEFAULT_NAMESPACE | Default namespace | http://vivo.mydomain.edu/individual/ | +| SOLR_URL | VIVO Solr URL | http://localhost:8983/solr/vivocore | +| SELF_ID_MATCHING_PROPERTY | Individual property associated with user account | http://vivo.mydomain.edu/ns#networkId | +| EMAIL_SMTP_HOST | Email SMTP host | not defined | +| EMAIL_PORT | Email server port | not defined | +| EMAIL_USERNAME | Email server username | not defined | +| EMAIL_PASSWORD | Email server password | not defined | +| EMAIL_REPLY_TO | Reply to email address | not defined | +| LANGUAGE_FILTER_ENABLED | Enable language filter to respect browser Accept-Language header | not defined | +| FORCE_LOCALE | Ignore browser Accept-Language header | not defined | +| SELECTABLE_LOCALES | Selectable locales | not defined | +| RESET_CORE | Reset VIVO Solr core | false | +| RESET_HOME | Reset VIVO home directory | false | +| LOAD_SAMPLE_DATA | Load sample data | false | +| SAMPLE_DATA_REPO_URL | Sample data GitHub repository | https://github.com/vivo-project/sample-data.git | +| SAMPLE_DATA_BRANCH | Sample data GitHub repository branch | main | +| SAMPLE_DATA_DIRECTORY | Sample data directory | openvivo | +| RECONFIGURE | Whether to update runtime properties and application setup | false | + +> Both RESET_HOME and LOAD_SAMPLE_DATA must be true in order to load sample data. + +#### Running VIVO from published Docker images. + +Create a docker [network](https://docs.docker.com/engine/reference/commandline/network_create/). +``` +docker network create vivo_net +``` + +Run vivo-solr [detached](https://docs.docker.com/engine/reference/run/#detached-vs-foreground) with [port forwarding](https://docs.docker.com/engine/reference/run/#expose-incoming-ports) and on a above [network](https://docs.docker.com/engine/reference/run/#network-settings). +``` +docker run -d -p 8983:8983 --hostname solr --network vivo_net vivoweb/vivo-solr +``` + +Run vivo with [port forwarding](https://docs.docker.com/engine/reference/run/#expose-incoming-ports), on a above [network](https://docs.docker.com/engine/reference/run/#network-settings), defining Solr URL [environment variable](https://docs.docker.com/engine/reference/run/#env-environment-variables), and local [volume](https://docs.docker.com/engine/reference/run/#volume-shared-filesystems) mounted to VIVO home directory. +``` +docker run -p 8080:8080 --network vivo_net -e "SOLR_URL=http://solr:8983/solr/vivocore" -v "./vivo-home:/opt/vivo/home" vivoweb/vivo +``` ### Docker Compose -Docker Compose variable substitution: +Docker Compose environment variables: .env defaults ``` -SOLR_RESET_CORE=false -SOLR_VERBOSE=no +LOCAL_SOLR_PORT=8983 +LOCAL_SOLR_DATA=./vivo-solr +RESET_CORE=false -SOLR_HOST_PORT=8983 -SOLR_CONTAINER_PORT=8983 +LOCAL_VIVO_PORT=8080 +LOCAL_VIVO_HOME=./vivo-home +RESET_HOME=false -SOLR_CORES=./vivo-cores +VIVO_HOME=/usr/local/vivo/home -VIVO_RESET_HOME=false -VIVO_VERBOSE=no +VERBOSE=no -VIVO_TDB_FILE_MODE=direct +``` -VIVO_HOST_VIVO_HOME=./vivo-home -VIVO_CONTAINER_VIVO_HOME=/usr/local/vivo/home +- `LOCAL_SOLR_PORT`: VIVO Solr port on your host machine. Port must not be in use. +- `LOCAL_SOLR_DATA`: VIVO Solr data directory on your host machine which will mount to volume in Solr docker container. Set this environment variable to persist your VIVO Solr data on your host machine. +- `RESET_CORE`: Convenience to reset VIVO Solr core when starting container. **Caution**, will require complete reindex. -VIVO_HOST_PORT=8080 -VIVO_CONTAINER_PORT=8080 -``` +- `LOCAL_VIVO_PORT`: VIVO Tomcat port on your host machine. Port must not be in use. +- `LOCAL_VIVO_HOME`: VIVO home directory on your host machine which will mount to volume in docker container. Set this environment variable to persist your VIVO data on your host machine. +- `RESET_HOME`: Convenience to reset VIVO home when starting container. **Caution**, will delete local configuration, content, and configuration model. + +- `VIVO_HOME`: VIVO home directory in the container. -- `SOLR_RESET_CORE`: Convenience to reset VIVO Solr core when starting container. **Caution**, will require complete reindex. -- `SOLR_VERBOSE`: Increase log verbosity. -- `SOLR_HOST_PORT`: Host port binding for solr service port mapping. -- `SOLR_CONTAINER_PORT`: Container port binding for solr service port mapping. -- `SOLR_CORES`: Solr cores data directories on your host machine which will mount to volume in docker container. Set this environment variable to persist your Solr data on your host machine. +- `VERBOSE`: Enable start.sh script debugging. -- `VIVO_RESET_HOME`: Convenience to reset VIVO home when starting container. **Caution**, will delete local configuration, content, and configuration model. -- `VIVO_VERBOSE`: Increase log verbosity. -- `VIVO_TDB_FILE_MODE`: TDB file mode. See https://jena.apache.org/documentation/tdb/configuration.html#file-access-mode. -- `VIVO_HOST_VIVO_HOME`: VIVO home directory on your host machine which will mount to volume in docker container. Set this environment variable to persist your VIVO data on your host machine. -- `VIVO_CONTAINER_VIVO_HOME`: VIVO home directory within the container. -- `VIVO_HOST_PORT`: Host port binding for VIVO Tomcat service port mapping. -- `VIVO_CONTAINER_PORT`: Container port binding for VIVO Tomcat service port mapping. +Build and start VIVO using Docker Compose. -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 ``` @@ -90,7 +139,7 @@ docker run -p 8080:8080 vivoweb/vivo:development There are several ways to contact and join the VIVO community. All of them are listed at https://vivo.lyrasis.org/contact/ ## Contributing Code -If you would like to contribute code to the VIVO project, please read instructions at [this page](https://github.com/vivo-project/VIVO/wiki/Development-Processes#process-for-suggesting-contribution). Contributors welcome! +If you would like to contribute code to the VIVO project, please read instructions at [this page](https://github.com/vivo-project/VIVO/wiki/Development-Processes#process-for-suggesting-contribution). Contributors welcome! ## Citing VIVO If you are using VIVO in your publications or projects, please cite the software paper in the Journal of Open Source Software: diff --git a/docker-compose.yml b/docker-compose.yml index 2efa496e2b..f5d83d3bcf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,48 +1,52 @@ -version: '3.2' +networks: + net: services: - vivo-solr: - container_name: vivo-solr + solr: image: vivoweb/vivo-solr:latest + container_name: vivo-solr + hostname: solr environment: - - RESET_CORE=${SOLR_RESET_CORE} - - VERBOSE=${SOLR_VERBOSE} + - VERBOSE=${VERBOSE} + - RESET_CORE=${RESET_CORE} ports: - - ${SOLR_HOST_PORT}:${SOLR_CONTAINER_PORT} + - ${LOCAL_SOLR_PORT}:8983 volumes: - - ${SOLR_CORES}:/opt/solr/server/solr/mycores + - ${LOCAL_SOLR_DATA}:/var/solr/data networks: - - vivoweb + - net healthcheck: - test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8983/solr/vivocore/admin/ping || exit 1"] - interval: 15s - timeout: 5s + test: ["CMD", "curl", "--silent", "--fail", "http://localhost:8983/solr/vivocore/admin/ping"] + start_period: 5s + interval: 5s + timeout: 10s retries: 3 - vivo: + tomcat: container_name: vivo - image: vivoweb/vivo:latest hostname: vivo build: context: ./ dockerfile: Dockerfile - args: - - TDB_FILE_MODE=${VIVO_TDB_FILE_MODE} - - VIVO_HOME=${VIVO_CONTAINER_VIVO_HOME} - - SOLR_URL=http://vivo-solr:${SOLR_CONTAINER_PORT}/solr/vivocore environment: - - RESET_HOME=${VIVO_RESET_HOME} - - VERBOSE=${VIVO_VERBOSE} + - VERBOSE=${VERBOSE} + - RESET_HOME=${RESET_HOME} + - VIVO_HOME=${VIVO_HOME} + - SOLR_URL=http://solr:8983/solr/vivocore + - LANGUAGE_FILTER_ENABLED=true + - SELECTABLE_LOCALES=en_US,de_DE,sr_Latn_RS,ru_RU,fr_CA,en_CA,es,pt_BR + - LOAD_SAMPLE_DATA=false + - SAMPLE_DATA_REPO_URL=https://github.com/chenejac/sample-data.git + - SAMPLE_DATA_BRANCH=reorganization + - SAMPLE_DATA_DIRECTORY=openvivo + - CATALINA_OPTS=-Xms2048M -Xmx8192M ports: - - ${VIVO_HOST_PORT}:${VIVO_CONTAINER_PORT} + - ${LOCAL_VIVO_PORT}:8080 volumes: - - ${VIVO_HOST_VIVO_HOME}:${VIVO_CONTAINER_VIVO_HOME} - networks: - - vivoweb + - ${LOCAL_VIVO_HOME}:${VIVO_HOME} depends_on: - vivo-solr: + solr: condition: service_healthy - -networks: - vivoweb: + networks: + - net diff --git a/home/pom.xml b/home/pom.xml index a5d27e1248..e4e0cfcb1b 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 8817ce777b..e258684b51 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 cc5a90d582..7a4d0b6de8 100644 --- a/installer/home/pom.xml +++ b/installer/home/pom.xml @@ -18,81 +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 5359e11c29..76968fc479 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 4f19644c66..22f621ceee 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.15.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..eb30238e2f 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="${default-namespace}" 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..ab15511546 100644 --- a/installer/webapp/src/main/webResources/WEB-INF/classes/log4j.properties +++ b/installer/webapp/src/main/webResources/WEB-INF/classes/log4j.properties @@ -30,8 +30,12 @@ log4j.appender.AllAppender.MaxBackupIndex=10 log4j.appender.AllAppender.layout=org.apache.log4j.PatternLayout log4j.appender.AllAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{1}] %m%n +# Console appender configuration +log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender +log4j.appender.ConsoleAppender.layout=org.apache.log4j.PatternLayout +log4j.appender.ConsoleAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{1}] %m%n -log4j.rootLogger=INFO, AllAppender +log4j.rootLogger=INFO, AllAppender, ConsoleAppender # These classes are too chatty to display INFO messages. log4j.logger.edu.cornell.mannlib.vitro.webapp.startup.StartupStatus=WARN diff --git a/pom.xml b/pom.xml index 6b567922bd..566b2fa7da 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,7 @@ + vivo ${project.version} ${basedir} yyyy-MM-dd HH:mm:ss @@ -428,6 +429,12 @@ 2.2.1 + org.apache.maven.plugins + maven-surefire-plugin + 2.12.4 + + + org.apache.maven.plugins maven-war-plugin 3.2.0 @@ -542,4 +549,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 a9688a8afd..55666ba9ea 100644 --- a/start.sh +++ b/start.sh @@ -9,52 +9,106 @@ fi # allow easier reset home with `docker run -e RESET_HOME=true` if [[ "$RESET_HOME" = "true" ]]; then - echo "Clearing VIVO HOME $VIVO_HOME" - rm -rf "$VIVO_HOME/*" + echo 'Clearing VIVO HOME $VIVO_HOME' + rm -rf $VIVO_HOME/* fi -# copy home bin if not exists -if [ ! -d "$VIVO_HOME/bin" ]; then - echo "Copying home bin directory to $VIVO_HOME/bin" - cp -r /vivo-home/bin "$VIVO_HOME/bin" -fi +# ensure home config directory exists +mkdir -p $VIVO_HOME/config -# copy home config if not exists -if [ ! -d $VIVO_HOME/config ]; then - echo "Copying home config directory to $VIVO_HOME/config" - cp -r /vivo-home/config "$VIVO_HOME/config" +# generate digest.md5 for existing VIVO home if not already exist +if [ ! -f $VIVO_HOME/digest.md5 ]; then + find $VIVO_HOME -type f | grep -E "^$VIVO_HOME/bin/|^$VIVO_HOME/config/|^$VIVO_HOME/rdf/" | xargs md5sum > $VIVO_HOME/digest.md5 + echo "Generated digest.md5 for VIVO home" + cat $VIVO_HOME/digest.md5 fi -# copy home rdf if not exists -if [ ! -d $VIVO_HOME/rdf ]; then - echo "Copying home rdf directory to $VIVO_HOME/rdf" - cp -r /vivo-home/rdf "$VIVO_HOME/rdf" +# load sample data +if [[ "$RESET_HOME" = "true" ]] && [[ "$LOAD_SAMPLE_DATA" = "true" ]]; then + echo "Cloning sample-data branch $SAMPLE_DATA_BRANCH from $SAMPLE_DATA_REPO_URL" + git clone --branch $SAMPLE_DATA_BRANCH $SAMPLE_DATA_REPO_URL sample-data > /dev/null + + # ensure home rdf directory exists + mkdir -p $VIVO_HOME/rdf + + echo "Loading $SAMPLE_DATA_DIRECTORY/*" + cp -r sample-data/$SAMPLE_DATA_DIRECTORY/* $VIVO_HOME/rdf/. fi -# copy runtime.properties if it does not already exist in target home directory -if [ -f "$VIVO_HOME/config/example.runtime.properties" ]; then - if [ ! -f "$VIVO_HOME/config/runtime.properties" ] - then - echo "Copying example.runtime.properties to $VIVO_HOME/config/runtime.properties" - cp "$VIVO_HOME/config/example.runtime.properties" "$VIVO_HOME/config/runtime.properties" +# only add/update runtime.properties if it does not already exist in target home directory or reconfigure env variable true +if [ ! -f $VIVO_HOME/config/runtime.properties ] || [[ "$RECONFIGURE" = "true" ]] +then + # template runtime.properties + + echo "Templating runtime.properties vitro.local.solr.url = $SOLR_URL" + sed -i "s,vitro.local.solr.url = http://localhost:8983/solr/vivocore,vitro.local.solr.url = $SOLR_URL,g" /tmp/runtime.properties + + echo "Templating runtime.properties selfEditing.idMatchingProperty = $SELF_ID_MATCHING_PROPERTY" + sed -i "s,selfEditing.idMatchingProperty = http://vivo.mydomain.edu/ns#networkId,selfEditing.idMatchingProperty = $SELF_ID_MATCHING_PROPERTY,g" /tmp/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" "$VIVO_HOME/config/runtime.properties" - else - echo "Using existing $VIVO_HOME/config/runtime.properties" + if [[ ! -z "${EMAIL_SMTP_HOST}" ]]; then + echo "Templating runtime.properties email.smtpHost = $EMAIL_SMTP_HOST" + sed -i "s, # email.smtpHost = smtp.mydomain.edu,email.smtpHost = $EMAIL_SMTP_HOST,g" /tmp/runtime.properties + fi + if [[ ! -z "${EMAIL_PORT}" ]]; then + echo "Templating runtime.properties email.port = $EMAIL_PORT" + sed -i "s, # email.port = 25 or 587,email.port = $EMAIL_PORT,g" /tmp/runtime.properties + fi + if [[ ! -z "${EMAIL_USERNAME}" ]]; then + echo "Templating runtime.properties email.username = $EMAIL_USERNAME" + sed -i "s, # email.username = vivtroAdmin@mydomain.edu,email.username = $EMAIL_USERNAME,g" /tmp/runtime.properties + fi + if [[ ! -z "${EMAIL_PASSWORD}" ]]; then + echo "Templating runtime.properties email.password = ***" + sed -i "s, # email.password = secret,email.password = $EMAIL_PASSWORD,g" /tmp/runtime.properties + fi + if [[ ! -z "${EMAIL_REPLY_TO}" ]]; then + echo "Templating runtime.properties email.replyTo = $EMAIL_REPLY_TO" + sed -i "s, # email.replyTo = vitroAdmin@mydomain.edu,email.replyTo = $EMAIL_REPLY_TO,g" /tmp/runtime.properties fi -fi -# copy applicationSetup.n3 if it does not already exist in target home directory -if [ -f "$VIVO_HOME/config/example.applicationSetup.n3" ]; then - if [ ! -f "$VIVO_HOME/config/applicationSetup.n3" ] - then - echo "Copying example.applicationSetup.n3 to $VIVO_HOME/config/applicationSetup.n3" - cp "$VIVO_HOME/config/example.applicationSetup.n3" "$VIVO_HOME/config/applicationSetup.n3" - else - echo "Using existing $VIVO_HOME/config/applicationSetup.n3" + if [[ ! -z "${LANGUAGE_FILTER_ENABLED}" ]]; then + echo "Templating runtime.properties RDFService.languageFilter = $LANGUAGE_FILTER_ENABLED" + sed -i "s,# RDFService.languageFilter = false,RDFService.languageFilter = $LANGUAGE_FILTER_ENABLED,g" /tmp/runtime.properties fi + if [[ ! -z "${FORCE_LOCALE}" ]]; then + echo "Templating runtime.properties languages.forceLocale = $FORCE_LOCALE" + sed -i "s,# languages.forceLocale = en_US,languages.forceLocale = $FORCE_LOCALE,g" /tmp/runtime.properties + fi + if [[ ! -z "${SELECTABLE_LOCALES}" ]]; then + echo "Templating runtime.properties languages.selectableLocales = $SELECTABLE_LOCALES" + sed -i "s/# languages.selectableLocales = en_US, es_GO/languages.selectableLocales = $SELECTABLE_LOCALES/g" /tmp/runtime.properties + fi + + echo "Copying /tmp/runtime.properties to /$VIVO_HOME/config/runtime.properties" + cp -r /tmp/runtime.properties $VIVO_HOME/config/runtime.properties +else + echo "Using existing $VIVO_HOME/config/runtime.properties" +fi + +# only add/update applicationSetup.n3 if it does not already exist in target home directory or reconfigure env variable true +if [ ! -f $VIVO_HOME/config/applicationSetup.n3 ] || [[ "$RECONFIGURE" = "true" ]] +then + echo "Copying /tmp/applicationSetup.n3 to $VIVO_HOME/config/applicationSetup.n3" + cp -r /tmp/applicationSetup.n3 $VIVO_HOME/config/applicationSetup.n3 +else + echo "Using existing $VIVO_HOME/config/applicationSetup.n3" fi +# Define the file path for setenv.sh +SETENV_PATH="$CATALINA_HOME/bin/setenv.sh" + +# Create or overwrite setenv.sh with the hashbang +echo "#!/bin/sh" > $SETENV_PATH + +# Append the JAVA_OPTS export line +echo 'export JAVA_OPTS="${JAVA_OPTS} -Dvivo-dir=$VIVO_HOME -Droot-user-address=$ROOT_USER_ADDRESS -Ddefault-namespace=$DEFAULT_NAMESPACE -Dtdb:fileMode=$TDB_FILE_MODE"' >> $SETENV_PATH + +# Make the setenv.sh file executable +chmod +x $SETENV_PATH + +# Copy VIVO artifact to Tomcat webapps +echo "Deploying VIVO $CATALINA_HOME/webapps/$TOMCAT_CONTEXT_PATH.war" +cp -r /tmp/vivo.war $CATALINA_HOME/webapps/$TOMCAT_CONTEXT_PATH.war + catalina.sh run diff --git a/vivo-solr/solr.xml b/vivo-solr/solr.xml new file mode 100644 index 0000000000..d9118e70b7 --- /dev/null +++ b/vivo-solr/solr.xml @@ -0,0 +1,2 @@ + +