Skip to content

Commit

Permalink
feat(ct): add first draft of application container image #8934
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm authored and pdurbin committed Mar 2, 2023
1 parent f817732 commit 19eedc4
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 3 deletions.
30 changes: 30 additions & 0 deletions doc/sphinx-guides/source/container/app-image.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Dataverse Application Image
===========================

Within the main repository, you may find the application image's files at ``<git root>/src/main/docker``.
This Maven module, which also build the Dataverse WAR, uses the `Maven Docker Plugin <https://dmp.fabric8.io>`_
to build and ship the image within a special Maven profile.

Contents
++++++++

The application image builds by convention upon the :doc:`base image <base-image>` and provides:

- Dataverse class files
- Resource files
- Scripts and associated data necessary for bootstrapping the application

The image is provided as a multi-arch image to support the most common architectures Dataverse usually runs on:
AMD64 (Windows/Linux/...) and ARM64 (Apple M1/M2). (Easy to extend.)

Build Instructions
++++++++++++++++++

Tunables
++++++++



Hints
+++++

66 changes: 63 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
doc/sphinx-guides/source/developers/dependencies.rst
-->
<artifactId>dataverse</artifactId>
<packaging>war</packaging>
<packaging>${packaging.type}</packaging>
<name>dataverse</name>
<properties>
<skipUnitTests>false</skipUnitTests>
<!-- By default, this module will produce a WAR file. -->
<!-- This will be switched within the container profile! -->
<packaging.type>war</packaging.type>

<reload4j.version>1.2.18.4</reload4j.version>
<flyway.version>8.5.10</flyway.version>
<jhove.version>1.20.1</jhove.version>
Expand Down Expand Up @@ -754,13 +758,69 @@
</profile>
<!-- TODO: Add a profile to run API tests (integration tests that end in IT.java. See conf/docker-aio/run-test-suite.sh -->
<profile>
<id>tc</id>
<id>ct</id>
<properties>
<!-- Let's go FAST here - building the image should be quick to do by default. -->
<skipUnitTests>true</skipUnitTests>
<postgresql.server.version>9.6</postgresql.server.version>
<!-- Once we truly run tests with Testcontainers, this should be switch to "docker", activating ITs -->
<packaging.type>docker-build</packaging.type>
<postgresql.server.version>13.0</postgresql.server.version>

<app.image>gdcc/dataverse:${app.image.tag}</app.image>
<app.image.tag>unstable</app.image.tag>
<base.image>gdcc/base:${base.image.tag}</base.image>
<base.image.tag>unstable</base.image.tag>
</properties>

<build>
<plugins>
<!-- Build the exploded WAR target directory -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
</configuration>
</plugin>

<!-- Build image via Docker Maven Plugin -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<images>
<image>
<alias>dataverse</alias>
<name>${app.image}</name>
<build>
<buildx>
<platforms>
<platform>linux/arm64</platform>
<platform>linux/amd64</platform>
</platforms>
</buildx>
<dockerFile>Dockerfile</dockerFile>
<args>
<BASE_IMAGE>${base.image}</BASE_IMAGE>
</args>
<filter>@</filter>
<assembly>
<descriptor>assembly.xml</descriptor>
</assembly>
</build>
</image>
</images>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down
48 changes: 48 additions & 0 deletions src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2022 Forschungszentrum Jülich GmbH
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
################################################################################################################
#
# THIS FILE IS TO BE USED WITH MAVEN DOCKER BUILD:
# mvn -Pct clean package docker:build
#
################################################################################################################
#
# Some commands used are inspired by https://github.com/payara/Payara/tree/master/appserver/extras/docker-images.
# Most parts origin from older versions of https://github.com/gdcc/dataverse-kubernetes.
#
# We are not using upstream Payara images because:
# - Using same base image as Solr (https://hub.docker.com/_/solr) is reducing pulls
# - Their image is less optimised for production usage and Dataverse by design choices
# - We provide multi-arch images
# - We provide some tweaks for development and monitoring
#

# Make the Java base image and version configurable (useful for trying newer Java versions and flavors)
ARG BASE_IMAGE="gdcc/base:unstable"
FROM $BASE_IMAGE

# Copy app and deps from assembly in proper layers
COPY --chown=payara:payara maven/deps ${DEPLOY_DIR}/dataverse/WEB-INF/lib/
COPY --chown=payara:payara maven/app ${DEPLOY_DIR}/dataverse/
COPY --chown=payara:payara maven/supplements ${DEPLOY_DIR}/dataverse/supplements/

# Create symlinks for jHove
RUN ln -s "${DEPLOY_DIR}/dataverse/supplements/jhove.conf" "${PAYARA_DIR}/glassfish/domains/${DOMAIN_NAME}/config/jhove.conf" && \
ln -s "${DEPLOY_DIR}/dataverse/supplements/jhoveConfig.xsd" "${PAYARA_DIR}/glassfish/domains/${DOMAIN_NAME}/config/jhoveConfig.xsd" && \
sed -i "${PAYARA_DIR}/glassfish/domains/${DOMAIN_NAME}/config/jhove.conf" -e "s:/usr/local/payara./glassfish/domains/domain1:${PAYARA_DIR}/glassfish/domains/${DOMAIN_NAME}:g"

LABEL org.opencontainers.image.created="@git.build.time@" \
org.opencontainers.image.authors="Research Data Management at FZJ <forschungsdaten@fz-juelich.de>" \
org.opencontainers.image.url="https://guides.dataverse.org/en/latest/container/" \
org.opencontainers.image.documentation="https://guides.dataverse.org/en/latest/container/" \
org.opencontainers.image.source="https://github.com/IQSS/dataverse" \
org.opencontainers.image.version="@project.version@" \
org.opencontainers.image.revision="@git.commit.id.abbrev@" \
org.opencontainers.image.vendor="Global Dataverse Community Consortium" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="Dataverse Application Image" \
org.opencontainers.image.description="This container image provides the research data repository software Dataverse in a box."
44 changes: 44 additions & 0 deletions src/main/docker/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<fileSets>
<!-- Get our app, but exclude deps -->
<fileSet>
<directory>target/${project.artifactId}-${project.version}</directory>
<outputDirectory>app</outputDirectory>
<excludes>
<exclude>WEB-INF/lib/**/*</exclude>
</excludes>
</fileSet>
<!-- Get our dependencies in a seperate folder (image layer cache!) -->
<fileSet>
<directory>target/${project.artifactId}-${project.version}/WEB-INF/lib</directory>
<outputDirectory>deps</outputDirectory>
</fileSet>
<!--
Supplemental data (configs, metadata, ...)
TODO: Commented out TSVs and bootstrap scripts for now until we decide *where* the bootstrapping etc will happen.
-->
<!--
<fileSet>
<directory>scripts/api</directory>
<outputDirectory>supplements</outputDirectory>
<includes>
<include>data/**/*</include>
<include>*.sh</include>
</includes>
<excludes>
<exclude>data/metadatablocks/custom*.tsv</exclude>
</excludes>
</fileSet>
-->
<fileSet>
<directory>conf/jhove</directory>
<outputDirectory>supplements</outputDirectory>
</fileSet>
<!-- Init scripts and usage scripts (bootstrapping, configuration, ...) -->
<fileSet>
<directory>conf/container/scripts</directory>
<outputDirectory>scripts</outputDirectory>
</fileSet>
</fileSets>
</assembly>

0 comments on commit 19eedc4

Please sign in to comment.