Revision ed5ad657
Added by Andreas Kohlbecker about 5 years ago
pom.xml | ||
---|---|---|
456 | 456 |
</arguments> |
457 | 457 |
</configuration> |
458 | 458 |
</plugin> |
459 |
<!-- Build Docker image --> |
|
460 |
<plugin> |
|
461 |
<groupId>io.fabric8</groupId> |
|
462 |
<artifactId>docker-maven-plugin</artifactId> |
|
463 |
<version>0.28.0</version> |
|
464 |
<configuration> |
|
465 |
<images> |
|
466 |
<image> |
|
467 |
<!-- docker hub does not allow dots in organizations, so the name is |
|
468 |
just 'cybertaxonomy', this MUST NOT BE CHANGED!!!! --> |
|
469 |
<name>cybertaxonomy/${project.artifactId}:${project.version}</name> |
|
470 |
<build> |
|
471 |
<!-- use a Dockerfile in the directory src/main/docker/production --> |
|
472 |
<dockerFileDir>production</dockerFileDir> |
|
473 |
<!-- fabric8-maven-plugin filters given Dockerfile with Maven properties --> |
|
474 |
<!-- For example, the default <filter>${*}</filter> parse Maven properties |
|
475 |
in the format that we know. If you specify a single character for |
|
476 |
<filter> then this delimiter is taken for both, the start and the end. |
|
477 |
E.g a <filter>@</filter> triggers on parameters in the format @…@, --> |
|
478 |
<filter>@</filter> |
|
479 |
<assembly> |
|
480 |
<descriptorRef>artifact</descriptorRef> |
|
481 |
<!-- |
|
482 |
1. The maven plugin copies the jar to the artifacts assembly locaton at: |
|
483 |
./target/docker/eu.etaxonomy/cdm-server/${project.version}/build/maven/cdm-server-${project.version}.jar |
|
484 |
2. a tar is being created at target/docker/eu.etaxonomy/cdm-server/${project.version}/tmp/docker-build.tar |
|
485 |
which contains all files located in /target/docker/production and the artifacts. |
|
486 |
Artifacts are put into the folder maven/ inside the tar archive |
|
487 |
3. The tar archive is passed to the docker daemon and is used as working directory for the build |
|
488 |
--> |
|
489 |
</assembly> |
|
490 |
</build> |
|
491 |
|
|
492 |
<run> |
|
493 |
<ports>8080:8080</ports> |
|
494 |
<!-- TODO configure if needed, see src/main/docker/production/README for examples --> |
|
495 |
</run> |
|
496 |
</image> |
|
497 |
</images> |
|
498 |
|
|
499 |
</configuration> |
|
500 |
|
|
501 |
<!-- Connect start/stop to pre- and |
|
502 |
post-integration-test phase, respectively if you want to start |
|
503 |
your docker containers during integration tests --> |
|
504 |
<executions> |
|
505 |
<execution> |
|
506 |
<id>start</id> |
|
507 |
<phase>pre-integration-test</phase> |
|
508 |
<goals> |
|
509 |
<!-- "build" should be used to create the images with the |
|
510 |
artifact --> |
|
511 |
<goal>build</goal> |
|
512 |
<goal>start</goal> |
|
513 |
</goals> |
|
514 |
</execution> |
|
515 |
<execution> |
|
516 |
<id>stop</id> |
|
517 |
<phase>post-integration-test</phase> |
|
518 |
<goals> |
|
519 |
<goal>stop</goal> |
|
520 |
</goals> |
|
521 |
</execution> |
|
522 |
</executions> |
|
523 |
</plugin> |
|
459 | 524 |
<!-- ====== DEPLOY ====== --> |
460 | 525 |
<plugin> |
461 | 526 |
<groupId>org.apache.maven.plugins</groupId> |
src/main/docker/production/Dockerfile | ||
---|---|---|
1 |
FROM anapsix/alpine-java:8 |
|
2 |
|
|
3 |
# paths of files and directories will be interpreted as relative to the source of the context of the build. |
|
4 |
|
|
5 |
### ADD directive for the maven docker plugin |
|
6 |
# 1. The maven plugin copies the jar to the artifacts assembly locaton at: |
|
7 |
# ./target/docker/eu.etaxonomy/cdm-server/${project.version}/build/maven/cdm-server-${project.version}.jar |
|
8 |
# 2. a tar is being created at target/docker/eu.etaxonomy/cdm-server/${project.version}/tmp/docker-build.tar |
|
9 |
# which contains all files located in /target/docker/production and the artifacts. |
|
10 |
# Artifacts are put into the folder maven/ inside the tar archive |
|
11 |
# 3. The tar archive is passed to the dockerdaemon and is used as working directory for the build |
|
12 |
#ADD target/docker/@project.groupId@/@project.artifactId@/@project.version@/build/maven/@project.build.finalName@.jar /root/cdm-server.jar |
|
13 |
ADD maven/@project.artifactId@-@project.version@.jar /root/cdm-server.jar |
|
14 |
|
|
15 |
ARG CDMSERVER_PORT=8080 |
|
16 |
ARG HEAP_SIZE=1024M |
|
17 |
ARG LOGDIR="/log/cdmserver" |
|
18 |
|
|
19 |
ENV CDM_HOME=/data |
|
20 |
ENV NAME=cdmserver |
|
21 |
ENV DESC="CDM Server" |
|
22 |
# ENV CDMSERVER_SHUTDOWN=30 |
|
23 |
ENV CPU_CORES=1 |
|
24 |
ENV DATASOURCES=$CDM_HOME/.cdmLibrary/datasources.xml |
|
25 |
|
|
26 |
# java options which can be overwritten |
|
27 |
ENV JAVA_OPTIONS="-Dspring.profiles.active=remoting" |
|
28 |
|
|
29 |
# fixed java options which must not be overwritten |
|
30 |
ARG JAVA_OPTS="-Xmx$HEAP_SIZE \ |
|
31 |
-XX:+UseG1GC -XX:ParallelGCThreads=$CPU_CORES -XX:ConcGCThreads=$CPU_CORES \ |
|
32 |
-Duser.home=$CDM_HOME $JAVA_OPTIONS" |
|
33 |
|
|
34 |
ARG SERVER_ARGS="-forceSchemaUpdate -jmx" |
|
35 |
|
|
36 |
ENV CDMSERVER_ARGS="-httpPort=$CDMSERVER_PORT -logdir=$LOGDIR -datasources $DATASOURCES" |
|
37 |
|
|
38 |
EXPOSE $CDMSERVER_PORT |
|
39 |
|
|
40 |
CMD java $JAVA_OPTS $JAVA_OPTIONS -jar /root/cdm-server.jar $SERVER_ARGS $CDMSERVER_ARGS |
src/main/docker/production/Dockerfile.dev | ||
---|---|---|
1 |
FROM anapsix/alpine-java:8 |
|
2 |
|
|
3 |
# paths of files and directories will be interpreted as relative to the source of the context of the build. |
|
4 |
|
|
5 |
### ADD directive for building the image manually using the docker command |
|
6 |
ADD target/cdm-server-*.jar /root/cdm-server.jar |
|
7 |
|
|
8 |
ARG CDMSERVER_PORT=8080 |
|
9 |
ARG HEAP_SIZE=1024M |
|
10 |
ARG LOGDIR="/log/cdmserver" |
|
11 |
|
|
12 |
ENV CDM_HOME=/data |
|
13 |
ENV NAME=cdmserver |
|
14 |
ENV DESC="CDM Server" |
|
15 |
# ENV CDMSERVER_SHUTDOWN=30 |
|
16 |
ENV CPU_CORES=1 |
|
17 |
ENV DATASOURCES=$CDM_HOME/.cdmLibrary/datasources.xml |
|
18 |
|
|
19 |
# java options which can be overwritten |
|
20 |
ENV JAVA_OPTIONS="-Dspring.profiles.active=remoting" |
|
21 |
|
|
22 |
# fixed java options which must not be overwritten |
|
23 |
ARG JAVA_OPTS="-Xmx$HEAP_SIZE \ |
|
24 |
-XX:+UseG1GC -XX:ParallelGCThreads=$CPU_CORES -XX:ConcGCThreads=$CPU_CORES \ |
|
25 |
-Duser.home=$CDM_HOME $JAVA_OPTIONS" |
|
26 |
|
|
27 |
ARG SERVER_ARGS="-forceSchemaUpdate -jmx" |
|
28 |
|
|
29 |
ENV CDMSERVER_ARGS="-httpPort=$CDMSERVER_PORT -logdir=$LOGDIR -datasources $DATASOURCES" |
|
30 |
|
|
31 |
EXPOSE $CDMSERVER_PORT |
|
32 |
|
|
33 |
CMD java $JAVA_OPTS $JAVA_OPTIONS -jar /root/cdm-server.jar $SERVER_ARGS $CDMSERVER_ARGS |
src/main/docker/production/README.md | ||
---|---|---|
1 |
# CDM Server Docker Container |
|
2 |
|
|
3 |
## Requirements |
|
4 |
|
|
5 |
Install the latest version of Docker (you will need at least version 18.09.0, earlier versions might work also but are untested). Instructions on the installation process for various operation systems are found at https://docs.docker.com/install/ |
|
6 |
|
|
7 |
NOTE: On linux you may want to add your user to the docker group (https://docs.docker.com/install/linux/linux-postinstall/): |
|
8 |
|
|
9 |
sudo usermod -aG docker $USER |
|
10 |
|
|
11 |
Log out and in afterwards to update the group membership. |
|
12 |
|
|
13 |
If you plan to use docker-compose install it now: https://docs.docker.com/compose/install/ |
|
14 |
|
|
15 |
## Build docker container manually |
|
16 |
|
|
17 |
## with the `docker` command |
|
18 |
|
|
19 |
In the root of the cdm-server project execute: |
|
20 |
|
|
21 |
docker build --tag=cybertaxonomy/cdm-server:${version} -f src/main/docker/${project.version}/Dockerfile.dev ./ |
|
22 |
|
|
23 |
e.g. |
|
24 |
|
|
25 |
docker build --tag="cybertaxonomy/cdm-server:5.5.0-SNAPSHOT" -f src/main/docker/production/Dockerfile.dev ./ |
|
26 |
|
|
27 |
### with maven |
|
28 |
|
|
29 |
mvn docker:build |
|
30 |
|
|
31 |
## Running the image |
|
32 |
|
|
33 |
### with docker |
|
34 |
|
|
35 |
Running the cdmserver docker container as developer |
|
36 |
|
|
37 |
Expects the datasource file as `datasources-cdm-server.xml` (see cdm-server-dev.env) |
|
38 |
|
|
39 |
NOTE: If you are using **symlinks** in the `.cdmLibrary` these must be use path outside of this folder. Otherwise they mioght not be valid inside the container |
|
40 |
|
|
41 |
docker run -dit --restart unless-stopped \ |
|
42 |
-p 8080:8080 \ |
|
43 |
-h cdmserver-dev \ |
|
44 |
--env-file=src/main/docker/production/cdm-server-dev.env \ |
|
45 |
--mount type=bind,source=$HOME/.cdmLibrary,destination=/data/.cdmLibrary \ |
|
46 |
--mount type=bind,source=$(pwd)/,destination=/var/log/cdmserver \ |
|
47 |
cybertaxonomy.eu/cdm-server:${version} |
|
48 |
|
|
49 |
### with docker-compose |
|
50 |
|
|
51 |
### with maven |
|
52 |
|
|
53 |
... |
|
54 |
|
|
55 |
## Shell access to the running docker container |
|
56 |
|
|
57 |
1. find the `CONTAINER ID` or container name |
|
58 |
|
|
59 |
docker ps |
|
60 |
|
|
61 |
1. Start the shell inside the container |
|
62 |
|
|
63 |
docker exec -it $CONAINER_ID|$CONTAINER_NAME /bin/bash |
|
64 |
|
|
65 |
-i : --intertactive, -t: --tty |
src/main/docker/production/cdm-server-dev.env | ||
---|---|---|
1 |
########################################################################## |
|
2 |
# env_file for docker or docker compose |
|
3 |
# |
|
4 |
# see |
|
5 |
# - https://docs.docker.com/compose/compose-file/#env_file |
|
6 |
# ----------------------------------------------------------------------- |
|
7 |
# The commented ENV variables below show the default values as example! |
|
8 |
########################################################################## |
|
9 |
|
|
10 |
### |
|
11 |
# The name of the docker container in RUN mode |
|
12 |
#NAME=cdmserver |
|
13 |
|
|
14 |
### |
|
15 |
# Description of the docker container in RUN mode |
|
16 |
#DESC="CDM Server" |
|
17 |
|
|
18 |
### |
|
19 |
# The home directory for the cdm-server process. At this location the cdm-server will |
|
20 |
# create the .cdmLibrary folder which will contain per instance configurations, |
|
21 |
# lucene full text index, and other resources |
|
22 |
#CDM_HOME=/data |
|
23 |
|
|
24 |
### |
|
25 |
# The location of the datasources.xml file to be used by the cdm-server. The datasource.xml file |
|
26 |
# contains the spring bean definitions of the datasources to be loaded by the server. |
|
27 |
# NOTE: variable expansion does not work in this file, so the $CDM_HOME can not be used here. |
|
28 |
DATASOURCES=/data/.cdmLibrary/datasources-cdm-server.xml |
|
29 |
|
|
30 |
### |
|
31 |
# The numberof cpu cores available on the host machine, this value is |
|
32 |
# being used to configure effective jvm garbage collection |
|
33 |
#CPU_CORES=1 |
|
34 |
|
|
35 |
### |
|
36 |
# Alternative options for the JVM |
|
37 |
# You MUST NOT use any of: -Xmx, XX:+UseG1GC -XX:ParallelGCThreads, -XX:ConcGCThreads=, -Duser.home |
|
38 |
# since these are managed internally in the container |
|
39 |
#JAVA_OPTIONS=-Dspring.profiles.active=remoting |
|
40 |
|
|
41 |
### |
|
42 |
# Alternative arguments for the cdm-server. |
|
43 |
# You may only want to use the following options to avoid conflicts with the once managed in the container: |
|
44 |
# |
|
45 |
# -forceSchemaUpdate USE THIS OPTION WITH CARE! Outdated cdm database schema versions will |
|
46 |
# be forcably updated to the version of the cdm-server. This option is only intended to be |
|
47 |
# used for development purposes. |
|
48 |
# |
|
49 |
# -jmx Start the server with the Jetty MBeans in JMX Management mode. |
|
50 |
# For testing you can use the following jvm options: |
|
51 |
# -Dcom.sun.management.jmxremote.ssl=false |
|
52 |
# -Dcom.sun.management.jmxremote.authenticate=false |
|
53 |
# -Dcom.sun.management.jmxremote.port=9999 |
|
54 |
#CDMSERVER_ARGS=-forceSchemaUpdate -jmx |
src/main/docker/production/cdm-server.env | ||
---|---|---|
1 |
########################################################################## |
|
2 |
# env_file for docker or docker compose |
|
3 |
# |
|
4 |
# see |
|
5 |
# - https://docs.docker.com/compose/compose-file/#env_file |
|
6 |
# ----------------------------------------------------------------------- |
|
7 |
# The commented ENV variables below show the default values as example! |
|
8 |
########################################################################## |
|
9 |
|
|
10 |
### |
|
11 |
# The name of the docker container in RUN mode |
|
12 |
#NAME=cdmserver |
|
13 |
|
|
14 |
### |
|
15 |
# Description of the docker container in RUN mode |
|
16 |
#DESC="CDM Server" |
|
17 |
|
|
18 |
### |
|
19 |
# The home directory for the cdm-server process. At this location the cdm-server will |
|
20 |
# create the .cdmLibrary folder which will contain per instance configurations, |
|
21 |
# lucene full text index, and other resources |
|
22 |
#CDM_HOME=/data |
|
23 |
|
|
24 |
### |
|
25 |
# The location of the datasources.xml file to be used by the cdm-server. The datasource.xml file |
|
26 |
# contains the spring bean definitions of the datasources to be loaded by the server. |
|
27 |
# NOTE: variable expansion does not work in this file, so the $CDM_HOME can not be used here. |
|
28 |
#DATASOURCES=/data/.cdmLibrary/datasources.xml |
|
29 |
|
|
30 |
### |
|
31 |
# The numberof cpu cores available on the host machine, this value is |
|
32 |
# being used to configure effective jvm garbage collection |
|
33 |
#CPU_CORES=1 |
|
34 |
|
|
35 |
### |
|
36 |
# Alternative options for the JVM |
|
37 |
# You MUST NOT use any of: -Xmx, XX:+UseG1GC -XX:ParallelGCThreads, -XX:ConcGCThreads=, -Duser.home |
|
38 |
# since these are managed internally in the container |
|
39 |
#JAVA_OPTIONS=-Dspring.profiles.active=remoting |
|
40 |
|
|
41 |
### |
|
42 |
# Alternative arguments for the cdm-server. |
|
43 |
# You may only want to use the following options to avoid conflicts with the once managed in the container: |
|
44 |
# |
|
45 |
# -forceSchemaUpdate USE THIS OPTION WITH CARE! Outdated cdm database schema versions will |
|
46 |
# be forcably updated to the version of the cdm-server. This option is only intended to be |
|
47 |
# used for development purposes. |
|
48 |
# |
|
49 |
# -jmx Start the server with the Jetty MBeans in JMX Management mode. |
|
50 |
# For testing you can use the following jvm options: |
|
51 |
# -Dcom.sun.management.jmxremote.ssl=false |
|
52 |
# -Dcom.sun.management.jmxremote.authenticate=false |
|
53 |
# -Dcom.sun.management.jmxremote.port=9999 |
|
54 |
#CDMSERVER_ARGS=-forceSchemaUpdate -jmx |
src/main/docker/production/docker-compose-dev.yml | ||
---|---|---|
1 |
version: '3' |
|
2 |
services: |
|
3 |
cdmserver: |
|
4 |
ports: |
|
5 |
- "8080:8080" |
|
6 |
env_file: |
|
7 |
- ./cdm-server.env |
|
8 |
volumes: |
|
9 |
# recommended settings for development |
|
10 |
- type: bind |
|
11 |
source: ~/ # user-home as a cdm-server-home => use the .cdmLibrary in user home |
|
12 |
target: /data |
|
13 |
- type: bind |
|
14 |
source: ./ # log directly into the working directory |
|
15 |
target: /log/cdmserver |
|
16 |
|
src/main/docker/production/docker-compose.yml | ||
---|---|---|
1 |
version: '3' |
|
2 |
services: |
|
3 |
cdmserver: |
|
4 |
ports: |
|
5 |
- "8080:8080" |
|
6 |
env_file: |
|
7 |
- ./cdm-server.env |
|
8 |
restart: unless-stopped |
|
9 |
volumes: |
|
10 |
# recommended settings for production |
|
11 |
- type: bind |
|
12 |
source: /var/lib/cdmserver |
|
13 |
target: /data |
|
14 |
- type: bind |
|
15 |
source: /var/log/cdmserver |
|
16 |
target: /log/cdmserver |
|
17 |
# recommended settings for development |
|
18 |
#- type: bind |
|
19 |
# source: ~/ # user-home as a cdm-server-home => use the .cdmLibrary in user home |
|
20 |
# target: /data |
|
21 |
#- type: bind |
|
22 |
# source: ./ # log directly into the working directory |
|
23 |
# target: /log/cdmserver |
|
24 |
|
Also available in: Unified diff
ref #6522 adding fairly complete set of configuration and documentation for delpoying the cdm-server as docker image