From 7773db339421aa19e44653389a58c703fb2b7d92 Mon Sep 17 00:00:00 2001 From: William Welling Date: Mon, 22 Mar 2021 13:37:13 -0500 Subject: [PATCH] revert deployment changes (#228) * revert deployment changes * update docker and compose for previous deployment * minor readme update * use package instead of install this avoids exploding war file in tomcat but seems to be missing overlays for VIVO theme * test docker workflow * test deploy workflow * add package profile for home * skip deploy for installer * skip installer by profile * update workflows * minor readme update * use app-name for vivo log file name * Update log4j.properties --- .github/workflows/build.yml | 2 +- .github/workflows/deploy.yml | 2 +- .github/workflows/docker.yml | 2 +- Dockerfile | 12 +- README.md | 6 +- docker-compose.yml | 4 +- ...onSetup.n3 => example.applicationSetup.n3} | 0 ....properties => example.runtime.properties} | 20 ++ installer/example-settings.xml | 21 +++ installer/home/pom.xml | 110 +++++++++-- installer/home/src/main/assembly/home.xml | 1 - installer/pom.xml | 66 +++++++ installer/webapp/pom.xml | 177 +++++++++++------- .../main/webResources/META-INF/context.xml | 43 ----- .../WEB-INF/classes/log4j.properties | 2 +- pom.xml | 1 - start.sh | 56 +++--- 17 files changed, 358 insertions(+), 167 deletions(-) rename home/src/main/resources/config/{default.applicationSetup.n3 => example.applicationSetup.n3} (100%) rename home/src/main/resources/config/{default.runtime.properties => example.runtime.properties} (95%) create mode 100644 installer/example-settings.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09b5b3bd3..a2515869f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,4 +28,4 @@ jobs: java-version: 11 - name: Maven Build - run: mvn clean install + run: mvn clean package -s installer/example-settings.xml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 84431d854..82012b896 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,7 +35,7 @@ jobs: server-password: MAVEN_PASSWORD - name: Maven Deploy - run: mvn --batch-mode deploy + run: mvn --batch-mode deploy -Pskip env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 602ae6b1f..26a2cf4a3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -32,7 +32,7 @@ jobs: java-version: 11 - name: Maven Build - run: mvn clean install + run: mvn clean package -s installer/example-settings.xml - name: Set up QEMU uses: docker/setup-qemu-action@v1 diff --git a/Dockerfile b/Dockerfile index ccfe74a7e..6632d8b3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,18 @@ FROM tomcat:9-jdk11-openjdk ARG SOLR_URL=http://localhost:8983/solr/vivocore -ARG VIVO_DIR=/opt/vivo/home +ARG VIVO_DIR=/usr/local/vivo/home ARG TDB_FILE_MODE=direct ENV SOLR_URL=${SOLR_URL} -ENV JAVA_OPTS="${JAVA_OPTS} -Dvivo-dir=$VIVO_DIR -Dtdb:fileMode=$TDB_FILE_MODE" +ENV JAVA_OPTS="${JAVA_OPTS} -Dtdb:fileMode=$TDB_FILE_MODE" -RUN mkdir /opt/vivo -RUN mkdir /opt/vivo/home +RUN mkdir /usr/local/vivo +RUN mkdir /usr/local/vivo/home +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 0deb596ca..3b7f65983 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,13 @@ RESET_CORE=false ``` - `LOCAL_VIVO_HOME`: VIVO home directory on your host machine which will mount to volume in docker container. -- `RESET_HOME`: Convinience to reset VIVO home when starting container. **Caution** will delete local configuration, content, and configuration model. -- `RESET_CORE`: Convinience to reset VIVO Solr core when starting container. **Caution** will require complete reindex. +- `RESET_HOME`: Convinience to reset VIVO home when starting container. **Caution**, will delete local configuration, content, and configuration model. +- `RESET_CORE`: Convinience to reset VIVO Solr core when starting container. **Caution**, will require complete reindex. Build and start VIVO. ``` -mvn clean install +mvn clean package -s installer/example-settings.xml docker-compose up ``` diff --git a/docker-compose.yml b/docker-compose.yml index e6386a711..d47dcf7d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: context: ./ dockerfile: Dockerfile args: - - VIVO_DIR=/opt/vivo/home + - VIVO_DIR=/usr/local/vivo/home - TDB_FILE_MODE=direct - SOLR_URL=http://solr:8983/solr/vivocore environment: @@ -28,7 +28,7 @@ services: ports: - 8080:8080 volumes: - - ${LOCAL_VIVO_HOME}:/opt/vivo/home + - ${LOCAL_VIVO_HOME}:/usr/local/vivo/home networks: - vivo diff --git a/home/src/main/resources/config/default.applicationSetup.n3 b/home/src/main/resources/config/example.applicationSetup.n3 similarity index 100% rename from home/src/main/resources/config/default.applicationSetup.n3 rename to home/src/main/resources/config/example.applicationSetup.n3 diff --git a/home/src/main/resources/config/default.runtime.properties b/home/src/main/resources/config/example.runtime.properties similarity index 95% rename from home/src/main/resources/config/default.runtime.properties rename to home/src/main/resources/config/example.runtime.properties index 6b6f8bf8c..e5a9da9dc 100644 --- a/home/src/main/resources/config/default.runtime.properties +++ b/home/src/main/resources/config/example.runtime.properties @@ -19,6 +19,26 @@ # 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 new file mode 100644 index 000000000..0007c79c9 --- /dev/null +++ b/installer/example-settings.xml @@ -0,0 +1,21 @@ + + + + + defaults + + vivo + + /usr/local/vivo/home + /usr/local/tomcat + + wilma + + + + + + defaults + + diff --git a/installer/home/pom.xml b/installer/home/pom.xml index e57789a40..059daab37 100644 --- a/installer/home/pom.xml +++ b/installer/home/pom.xml @@ -23,24 +23,108 @@ wilma + + + package + + vivo-dir + + + ${app-name} + + + maven-assembly-plugin + + + src/main/assembly/home.xml + + false + + + + package + + single + + + + + + + + + install + + vivo-dir + + + + + 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-assembly-plugin + maven-install-plugin - - src/main/assembly/home.xml - - false + true - - - package - - single - - - diff --git a/installer/home/src/main/assembly/home.xml b/installer/home/src/main/assembly/home.xml index 34f447c0a..6de97e21d 100644 --- a/installer/home/src/main/assembly/home.xml +++ b/installer/home/src/main/assembly/home.xml @@ -4,7 +4,6 @@ home dir - tar false diff --git a/installer/pom.xml b/installer/pom.xml index 75ca4250b..2c966aa85 100644 --- a/installer/pom.xml +++ b/installer/pom.xml @@ -29,6 +29,12 @@ UTF-8 + + maven-install-plugin + + true + + org.apache.maven.plugins maven-gpg-plugin @@ -142,6 +148,12 @@ + + maven-dependency-plugin + + true + + maven-resources-plugin 2.6 @@ -165,6 +177,60 @@ + + 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) + + + + + + + + + + + skip + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + diff --git a/installer/webapp/pom.xml b/installer/webapp/pom.xml index 689936254..78973a347 100644 --- a/installer/webapp/pom.xml +++ b/installer/webapp/pom.xml @@ -19,9 +19,117 @@ 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 @@ -32,75 +140,6 @@ - - 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 - - - - org.vivoweb - vitro-languages-webapp-core - war - - - org.vivoweb - vivo-languages-webapp-core - 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 ea9449133..f4af100a8 100644 --- a/installer/webapp/src/main/webResources/META-INF/context.xml +++ b/installer/webapp/src/main/webResources/META-INF/context.xml @@ -1,52 +1,9 @@ - - - - - - - - - - - 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 17c0c8ff9..1d3c0c4a8 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/vivo.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 dfd2c4274..0665c5f28 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,6 @@ - vivo ${project.version} ${basedir} yyyy-MM-dd HH:mm:ss diff --git a/start.sh b/start.sh index 90e76f605..0f9ef7d92 100644 --- a/start.sh +++ b/start.sh @@ -9,43 +9,51 @@ fi # allow easier reset home with `docker run -e RESET_HOME=true` if [[ "$RESET_HOME" = "true" ]]; then - echo 'Clearing VIVO HOME /opt/vivo/home' - rm -rf /opt/vivo/home/* + echo 'Clearing VIVO HOME /usr/local/vivo/home' + rm -rf /usr/local/vivo/home/* fi -# ensure home config directory exists -mkdir -p /opt/vivo/home/config +# 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 -# generate digest.md5 for existing VIVO home if not already exist -if [ ! -f /opt/vivo/home/digest.md5 ]; then - find /opt/vivo/home -type f | grep -E '^/opt/vivo/home/bin/|^/opt/vivo/home/config/|^/opt/vivo/home/rdf/' | xargs md5sum > /opt/vivo/home/digest.md5 - echo "Generated digest.md5 for VIVO home" - cat /opt/vivo/home/digest.md5 +# 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 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 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 - if [ ! -f /opt/vivo/home/config/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 ] then - echo "First time: moving /runtime.properties to /opt/vivo/home/config/runtime.properties" - mv -n /runtime.properties /opt/vivo/home/config/runtime.properties + 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 else - echo "Using existing /opt/vivo/home/config/runtime.properties" + echo "Using existing /usr/local/vivo/home/config/runtime.properties" fi fi -# only move applicationSetup.n3 first time and if it does not already exist in target home directory -if [ -f /applicationSetup.n3 ]; then - if [ ! -f /opt/vivo/home/config/applicationSetup.n3 ] +# 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 ] then - echo "First time: moving /applicationSetup.n3 to /opt/vivo/home/config/applicationSetup.n3" - mv -n /applicationSetup.n3 /opt/vivo/home/config/applicationSetup.n3 + 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 else - echo "Using existing /opt/vivo/home/config/applicationSetup.n3" + echo "Using existing /usr/local/vivo/home/config/applicationSetup.n3" fi fi