Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable war deployment model (#197.1) #3839

Closed
wants to merge 7 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -30,4 +30,4 @@ jobs:
- name: Maven Build
run: |
cd ../VIVO
mvn clean package -s installer/example-settings.xml
mvn clean install
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
FROM tomcat:9-jdk11-openjdk

ARG SOLR_URL=http://localhost:8983/solr/vivocore
ARG VIVO_DIR=/usr/local/vivo/home
ARG VIVO_DIR=/opt/vivo/home
ARG TDB_FILE_MODE=direct

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 /opt/vivo
RUN mkdir /opt/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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 install
docker-compose up
```

6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion home/pom.xml
Original file line number Diff line number Diff line change
@@ -69,4 +69,4 @@
<type>tar.gz</type>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -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.
22 changes: 0 additions & 22 deletions installer/example-settings.xml

This file was deleted.

88 changes: 13 additions & 75 deletions installer/home/pom.xml
Original file line number Diff line number Diff line change
@@ -18,86 +18,24 @@
<default-theme>wilma</default-theme>
</properties>

<profiles>
<profile>
<id>install</id>
<activation>
<property><name>vivo-dir</name></property>
</activation>
<build>
<finalName>${app-name}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/home.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>remove-webapp</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete includeemptydirs="true">
<fileset dir="${vivo-dir}/rdf">
<include name="**/*"/>
<exclude name="**/i18n/*_x_*/**"/>
</fileset>
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${vivo-dir}</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/${project.build.finalName}</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<skip>true</skip>
<descriptors>
<descriptor>src/main/assembly/home.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
1 change: 1 addition & 0 deletions installer/home/src/main/assembly/home.xml
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
<id>home</id>
<formats>
<format>dir</format>
<format>tar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
56 changes: 3 additions & 53 deletions installer/pom.xml
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
<name>VIVO Installer</name>

<properties>
<app-name>vivo</app-name>
<vitro-version>${project.version}</vitro-version>
<maven-site-plugin.skip>true</maven-site-plugin.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -24,12 +25,6 @@
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
@@ -150,12 +145,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
@@ -179,45 +168,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<phase/>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>install</id>
<activation>
<property><name>vivo-dir</name></property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-properties</id>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>app-name</property>
<message>You must provide an application name (app-name)</message>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
@@ -248,7 +198,7 @@
<repository>
<id>vivo-dependencies</id>
<name>VIVO Dependencies</name>
<url>https://raw.github.com/vivo-project/dependencies/main/</url>
<url>https://raw.github.com/vivo-project/dependencies/master/</url>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
@@ -262,4 +212,4 @@
</snapshots>
</repository>
</repositories>
</project>
</project>
158 changes: 61 additions & 97 deletions installer/webapp/pom.xml
Original file line number Diff line number Diff line change
@@ -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">

<modelVersion>4.0.0</modelVersion>

<groupId>org.vivoweb</groupId>
<artifactId>vivo-installer-vivo</artifactId>
<version>1.13.1-SNAPSHOT</version>
<packaging>war</packaging>

<parent>
<groupId>org.vivoweb</groupId>
<artifactId>vivo-installer</artifactId>
@@ -16,105 +19,9 @@

<name>VIVO Install Web App</name>

<profiles>
<profile>
<id>package</id>
<activation>
<property><name>app-name</name></property>
</activation>
<build>
<finalName>${app-name}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<archiveClasses>false</archiveClasses>
<overlays>
<overlay>
<groupId>org.vivoweb</groupId>
<artifactId>vivo-webapp</artifactId>
<type>war</type>
</overlay>
</overlays>
<webResources>
<resource>
<directory>src/main/webResources</directory>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>install</id>
<activation>
<property><name>tomcat-dir</name></property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>remove-webapp</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="${tomcat-dir}/webapps/${project.build.finalName}" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>war</type>
<overWrite>true</overWrite>
<outputDirectory>${tomcat-dir}/webapps/${project.build.finalName}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<finalName>${app-name}</finalName>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
@@ -125,6 +32,63 @@
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>include-home</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.vivoweb</groupId>
<artifactId>vivo-installer-home</artifactId>
<version>${project.version}</version>
<type>tar</type>
<destFileName>vivo-home.tar</destFileName>
<outputDirectory>${project.build.directory}/home-files</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<archiveClasses>false</archiveClasses>
<overlays>
<overlay>
<groupId>org.vivoweb</groupId>
<artifactId>vivo-webapp</artifactId>
<type>war</type>
</overlay>
</overlays>
<webResources>
<resource>
<directory>src/main/webResources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>${project.build.directory}/home-files/</directory>
<targetPath>WEB-INF/resources/home-files/</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>

49 changes: 46 additions & 3 deletions installer/webapp/src/main/webResources/META-INF/context.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
<Context> <!-- useHttpOnly="false" -->

<!--
# The 'home' property specifies the location of VIVO HOME.
# The system user used to run the VIVO web application must have write access
# to the parent directory of the directory defined in this property, if VIVO HOME
# does not already exist.
# If this directory already exists, the system user used to run the VIVO web application
# must have write access to this directory.
-->
<Environment
type="java.lang.String"
name="vitro/home"
value="${vivo-dir}" override="true"/>

<!--
# The name of the application (possibly not used).
-->
<Environment
type="java.lang.String"
name="vitro/appName"
value="${app-name}" override="true"/>

<!--
# 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.
-->
<Environment
type="java.lang.String"
name="vitro/rootUserAddress"
value="vivo_root@mydomain.edu" override="true"/>

<!--
# 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/
-->
<Environment
type="java.lang.String"
name="vitro/home"
value="${vivo-dir}" override="true"/>
name="vitro/defaultNamespace"
value="http://vivo.mydomain.edu/individual/" override="true"/>

<!-- Disable persist sessions on shut down.-->
<Manager pathname="" />
</Context>
</Context>
Original file line number Diff line number Diff line change
@@ -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/vivo.all.log
log4j.appender.AllAppender.MaxFileSize=10MB
log4j.appender.AllAppender.MaxBackupIndex=10
log4j.appender.AllAppender.layout=org.apache.log4j.PatternLayout
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@
</scm>

<properties>
<app-name>vivo</app-name>
<vitro-version>${project.version}</vitro-version>
<vivo-dir>${basedir}</vivo-dir>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
@@ -542,4 +543,4 @@
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>
</project>
60 changes: 28 additions & 32 deletions start.sh
Original file line number Diff line number Diff line change
@@ -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 /opt/vivo/home'
rm -rf /opt/vivo/home/*
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 /opt/vivo/home/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 /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
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 /opt/vivo/home/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 /opt/vivo/home/config/runtime.properties"
mv -n /runtime.properties /opt/vivo/home/config/runtime.properties
else
echo "Using existing /usr/local/vivo/home/config/runtime.properties"
echo "Using existing /opt/vivo/home/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 /opt/vivo/home/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 /opt/vivo/home/config/applicationSetup.n3"
mv -n /applicationSetup.n3 /opt/vivo/home/config/applicationSetup.n3
else
echo "Using existing /usr/local/vivo/home/config/applicationSetup.n3"
echo "Using existing /opt/vivo/home/config/applicationSetup.n3"
fi
fi

echo "Giving time for Solr to startup..."
sleep 15
echo "Starting Tomcat"

catalina.sh run