From 19eedc447645dc5430080a5d507cad31ecdfd157 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Wed, 18 Jan 2023 14:08:57 +0100 Subject: [PATCH] feat(ct): add first draft of application container image #8934 --- .../source/container/app-image.rst | 30 +++++++++ pom.xml | 66 ++++++++++++++++++- src/main/docker/Dockerfile | 48 ++++++++++++++ src/main/docker/assembly.xml | 44 +++++++++++++ 4 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 doc/sphinx-guides/source/container/app-image.rst create mode 100644 src/main/docker/Dockerfile create mode 100644 src/main/docker/assembly.xml diff --git a/doc/sphinx-guides/source/container/app-image.rst b/doc/sphinx-guides/source/container/app-image.rst new file mode 100644 index 00000000000..5c42a772987 --- /dev/null +++ b/doc/sphinx-guides/source/container/app-image.rst @@ -0,0 +1,30 @@ +Dataverse Application Image +=========================== + +Within the main repository, you may find the application image's files at ``/src/main/docker``. +This Maven module, which also build the Dataverse WAR, uses the `Maven Docker Plugin `_ +to build and ship the image within a special Maven profile. + +Contents +++++++++ + +The application image builds by convention upon the :doc:`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 ++++++ + diff --git a/pom.xml b/pom.xml index 8b6f98c5896..79227e0e6c8 100644 --- a/pom.xml +++ b/pom.xml @@ -15,10 +15,14 @@ doc/sphinx-guides/source/developers/dependencies.rst --> dataverse - war + ${packaging.type} dataverse false + + + war + 1.2.18.4 8.5.10 1.20.1 @@ -754,13 +758,69 @@ - tc + ct + true - 9.6 + + docker-build + 13.0 + + gdcc/dataverse:${app.image.tag} + unstable + gdcc/base:${base.image.tag} + unstable + + + + org.apache.maven.plugins + maven-war-plugin + + + prepare-package + + exploded + + + + + + + + + + io.fabric8 + docker-maven-plugin + true + + + + dataverse + ${app.image} + + + + linux/arm64 + linux/amd64 + + + Dockerfile + + ${base.image} + + @ + + assembly.xml + + + + + + + org.apache.maven.plugins maven-failsafe-plugin diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile new file mode 100644 index 00000000000..1c90d2af1ae --- /dev/null +++ b/src/main/docker/Dockerfile @@ -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 " \ + 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." diff --git a/src/main/docker/assembly.xml b/src/main/docker/assembly.xml new file mode 100644 index 00000000000..da33cd0ac63 --- /dev/null +++ b/src/main/docker/assembly.xml @@ -0,0 +1,44 @@ + + + + + target/${project.artifactId}-${project.version} + app + + WEB-INF/lib/**/* + + + + + target/${project.artifactId}-${project.version}/WEB-INF/lib + deps + + + + + conf/jhove + supplements + + + + conf/container/scripts + scripts + + + \ No newline at end of file