Skip to content

Commit

Permalink
Enable war deployment model
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Sep 7, 2024
1 parent 1a25a31 commit 2346e63
Show file tree
Hide file tree
Showing 21 changed files with 389 additions and 397 deletions.
27 changes: 8 additions & 19 deletions .env
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ utilities/rdbmigration/.work
**/.project
**/bin/

vivo-cores/
vivo-solr/*
!vivo-solr/solr.xml
vivo-home/

.fake
Expand Down
47 changes: 35 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 [email protected]
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"]
113 changes: 81 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | [email protected] |
| 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
```

Expand All @@ -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:
Expand Down
58 changes: 31 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion home/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
<type>tar.gz</type>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [email protected]

#
# Argon2 password hashing parameters for time, memory and parallelism required to
# compute a hash.
Expand Down
Loading

0 comments on commit 2346e63

Please sign in to comment.