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

Docker updates #3844

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
94a9351
Enable war deployment model (#197.1)
wwelling Feb 23, 2023
70da572
Delay startup for Solr to start when using docker-compose
wwelling Feb 27, 2023
4c5ebb3
Docker improvements (WIP)
wwelling Feb 27, 2023
70d029c
Update VIVO Dependencies GitHub branch reference
wwelling Mar 1, 2023
20e8799
Use app-name variable for log file naming
wwelling Mar 1, 2023
687f27f
Update README to build using package
wwelling Mar 1, 2023
3b11f1b
Merge branch 'VIVO-3034-psuedo-rebase' of https://github.com/vivo-pro…
wwelling Mar 1, 2023
3017d81
Merge branch 'main' of https://github.com/vivo-project/VIVO into VIVO…
wwelling Mar 1, 2023
31a3002
Merge branch 'VIVO-3034-psuedo-rebase' of https://github.com/vivo-pro…
wwelling Mar 1, 2023
f504b43
Cleanup and README updates
wwelling Mar 1, 2023
70bc159
Environment variables added to java opts on start
wwelling Mar 1, 2023
3b6cde3
Afford reconfigure on restart
wwelling Mar 1, 2023
e14d58c
Switch to /usr/local/vivo/home for default VIVO home
wwelling Mar 1, 2023
c9207a9
Afford changing context path on restart
wwelling Mar 2, 2023
9b83c59
Build digest on start to preserve existing VIVO home
wwelling Mar 2, 2023
3e78d45
Switch back to /usr/local/vivo/home for default home directory
wwelling Mar 3, 2023
8b14696
Merge branch 'VIVO-3034-psuedo-rebase' of https://github.com/vivo-pro…
wwelling Mar 3, 2023
68cb8fa
Update README.md
wwelling Mar 3, 2023
f23b0a2
Update docker-compose.yml
wwelling Mar 3, 2023
87a424f
Remove spurious whitespace in log4j.properties
wwelling Mar 6, 2023
72e9466
Move wait for solr to docker-compose
wwelling Mar 6, 2023
88bf752
Merge branch 'VIVO-3034-psuedo-rebase' of https://github.com/vivo-pro…
wwelling Mar 6, 2023
dd98a1d
Update docker-compose.yml
wwelling Mar 6, 2023
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
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
LOCAL_SOLR_DATA=./vivo-solr
RESET_CORE=false

LOCAL_VIVO_HOME=./vivo-home
RESET_HOME=false
RESET_CORE=false

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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ utilities/rdbmigration/.work
**/bin/

vivo-home/
vivo-solr/

.fake
.ionide
Expand Down
44 changes: 33 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
FROM tomcat:9-jdk11-openjdk
ARG USER_ID=3001
ARG USER_NAME=vivo
ARG USER_HOME_DIR=/home/$USER_NAME

ARG SOLR_URL=http://localhost:8983/solr/vivocore
ARG VIVO_DIR=/usr/local/vivo/home
ARG TDB_FILE_MODE=direct
ENV TOMCAT_CONTEXT_PATH=ROOT
ENV VIVO_HOME_DIR=/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 SOLR_URL=${SOLR_URL}
ENV JAVA_OPTS="${JAVA_OPTS} -Dtdb:fileMode=$TDB_FILE_MODE"
ENV SOLR_URL=http://localhost:8983/solr/vivocore
ENV SELF_ID_MATCHING_PROPERTY=http://vivo.mydomain.edu/ns

RUN mkdir /usr/local/vivo
RUN mkdir /usr/local/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=openvivo
chenejac marked this conversation as resolved.
Show resolved Hide resolved

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
RUN \
apt-get update -y && \
apt-get upgrade -y && \
apt install git -y

RUN \
addgroup --disabled-password --gid $USER_ID $USER_NAME && \
adduser --disabled-password --home $USER_HOME_DIR --uid $USER_ID --gid $USER_ID $USER_NAME

RUN mkdir -p $VIVO_HOME_DIR

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

EXPOSE 8080

CMD ["/bin/bash", "/start.sh"]
CMD ["/bin/bash", "/usr/local/vivo/start.sh"]
75 changes: 69 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,93 @@ https://wiki.lyrasis.org/display/VIVODOC112x/Installing+VIVO

### 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 are 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_DIR | 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 environment variables:

.env defaults
```
LOCAL_SOLR_DATA=./vivo-solr
RESET_CORE=false

LOCAL_VIVO_HOME=./vivo-home
RESET_HOME=false
RESET_CORE=false

VERBOSE=no
```

- `LOCAL_VIVO_HOME`: 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.

- `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.
- `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.
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.

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 Down
37 changes: 26 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
version: '3.2'

networks:
net:

services:

solr:
image: vivoweb/vivo-solr:latest
hostname: solr
environment:
- RESET_CORE=${RESET_CORE}
- VERBOSE=${VERBOSE}
- RESET_CORE=true
ports:
- 8983:8983
volumes:
- ${LOCAL_SOLR_DATA}:/opt/solr/server/solr/mycores
networks:
- vivo
- net

tomcat:
container_name: vivo
hostname: vivo
build:
context: ./
dockerfile: Dockerfile
args:
- VIVO_DIR=/usr/local/vivo/home
- TDB_FILE_MODE=direct
- SOLR_URL=http://solr:8983/solr/vivocore
environment:
- RESET_HOME=${RESET_HOME}
- VERBOSE=${VERBOSE}
- RESET_HOME=true
- 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=true
- SAMPLE_DATA_REPO_URL=https://github.com/chenejac/sample-data.git
- SAMPLE_DATA_BRANCH=reorganization
- SAMPLE_DATA_DIRECTORY=i18n
ports:
- 8080:8080
volumes:
- ${LOCAL_VIVO_HOME}:/usr/local/vivo/home
depends_on:
- solr
networks:
- vivo

networks:
vivo:
- net
entrypoint:
- /bin/bash
- '-c'
- |
while (!</dev/tcp/solr/8983) > /dev/null 2>&1; do sleep 1; done;
sleep 5
/usr/local/vivo/start.sh
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 = vivo_root@mydomain.edu

#
# Argon2 password hashing parameters for time, memory and parallelism required to
# compute a hash.
Expand Down
22 changes: 0 additions & 22 deletions installer/example-settings.xml

This file was deleted.

Loading