Skip to content
Snippets Groups Projects
Dockerfile.dspace 6.34 KiB
Newer Older
##############################################################################
# Dockerfile to build LINDAT Dspace container images
# Based on Ubuntu
##############################################################################

ARG LABEL_VERSION
ARG LABEL_BUILD_DATE=now
ARG LABEL_VCS_URL="https://gitlab.inf.unibz.it/commul/docker/clarin-dspace"
ARG TOMCAT_VERSION="8.0.53"

LABEL maintainer="Alexander König <Alexander.Koenig@eurac.edu>" \
      maintainer="Egon W. Stemle <egon.stemleg@eurac.edu>" \
      org.label-schema.version=$LABEL_VERSION \
      org.label-schema.build-date=$LABEL_BUILD_DATE \
      org.label-schema.vcs-url=$LABEL_VCS_URL

# Set "APT::Get::{Assume-Yes, Fix-Broken} to true"
RUN echo 'APT { GET { Assume-Yes "true"; }; };\nAPT { GET { Fix-Broken "true"; }; };' \
    >> /etc/apt/apt.conf

# use fast(er) local mirrors
# http://layer0.authentise.com/docker-4-useful-tips-you-may-not-know-about.html
RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiverse" > /etc/apt/sources.list && \
    echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
    echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiverse" >> /etc/apt/sources.list && \
    DEBIAN_FRONTEND=noninteractive apt-get update && \
    apt-get upgrade --show-progress
# install cpanm and dependencies
# install jdk, ant, psql, mvn, make, libxml, xsltproc, zip, wget
RUN apt-get install \
    unzip curl wget git \
    make gcc \
    cpanminus \
    openjdk-8-jdk ant maven libxml2-utils xsltproc \
    libapr1-dev
RUN cpanm -n File::Spec::Functions && \
    cpanm Term::ReadLine

# install convenience apps for debug purposes (vim and jsbeautifier)
RUN apt-get install vim less python-pip
RUN pip install jsbeautifier
COPY commul-customization/__init__.py /usr/local/lib/python2.7/dist-packages/jsbeautifier/
RUN locale-gen en_US.UTF-8
COPY commul-customization/default_locale /etc/default/locale
RUN chmod 0755 /etc/default/locale

ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8

egon w. stemle's avatar
egon w. stemle committed
### Install Tomcat
#
# build tomcat $TOMCAT_VERSION (> 8.0.35), version recommended by LINDAT
RUN wget -O /tmp/apache-tomcat-$TOMCAT_VERSION.tar.gz \
        https://archive.apache.org/dist/tomcat/tomcat-8/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz && \
    wget -O /tmp/apache-tomcat-$TOMCAT_VERSION.tar.gz.sha512 \
        https://archive.apache.org/dist/tomcat/tomcat-8/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz.sha512
WORKDIR /tmp

# checksum check the download
RUN sha512sum --check apache-tomcat-$TOMCAT_VERSION.tar.gz.sha512

RUN mkdir /opt/tomcat8 && \
    tar xzf /tmp/apache-tomcat-$TOMCAT_VERSION.tar.gz \
        -C /opt/tomcat8/ \
        --strip-components=1 && \
    groupadd tomcat8 && \
    useradd -s /bin/false -g tomcat8 -d /opt/tomcat8/ tomcat8 && \
    chown -R tomcat8:tomcat8 /opt/tomcat8

# Install Apache Tomcat Native
# prerequisites: libopenssl, libapr1, jdk
RUN mkdir /opt/tomcat8/bin/tomcat-native && \
    tar xzf /opt/tomcat8/bin/tomcat-native.tar.gz \
        -C /opt/tomcat8/bin/tomcat-native \
        --strip-components=1 && \
    cd /opt/tomcat8/bin/tomcat-native/native && \
    ./configure \
        --with-java-home=/usr/lib/jvm/java-8-openjdk-amd64/ \
        --prefix=/usr/local/ && \
    make && make install

# copy config files etc. (setenv.sh,server.xml)
COPY commul-customization/tomcat-setenv.sh /opt/tomcat8/bin/
COPY commul-customization/tomcat-server.xml /opt/tomcat8/conf/server.xml

egon w. stemle's avatar
egon w. stemle committed
### Install Dspace
#
# pre-fetch maven dependencies
RUN git clone --depth 1 --branch commul-custom https://github.com/commul/clarin-dspace.git /opt/repository/sources/dspace
WORKDIR /opt/repository/sources/dspace
egon w. stemle's avatar
egon w. stemle committed
RUN mvn -B -T 1C \
    --quiet \
    --fail-never \
    dependency:copy-dependencies dependency:resolve-plugins dependency:go-offline
#
# this checks if there was a new commit since the last build
ADD https://api.github.com/repos/commul/clarin-dspace/git/refs/heads/commul-custom /tmp/version.json
RUN git pull
egon w. stemle's avatar
egon w. stemle committed
RUN mvn -B -T 1C clean compile
WORKDIR /opt/repository/sources/dspace/utilities/project_helpers
RUN ./setup.sh /opt/repository/workspace
COPY commul-customization/variable.makefile /opt/repository/workspace/config/variable.makefile
# COPY commul-customization/dspace.cfg /opt/repository/sources/dspace/dspace/config/dspace.cfg
# install python modules: magic dateutil, lxml
RUN apt-get install python-magic python-dateutil python-lxml
# copy over configs and startup scripts
COPY commul-customization/start_stack.sh /opt/repository/workspace/scripts/
COPY commul-customization/stop_stack.sh /opt/repository/workspace/scripts/
COPY commul-customization/local.properties /opt/repository/workspace/sources/
RUN chmod u+x /opt/repository/workspace/scripts/*_stack.sh

WORKDIR /opt/repository/workspace/scripts
RUN make install_libs

RUN make new_deploy

# DEBUG: to be able to access tomcat manager through browser
# COPY commul-customization/tomcat-users.xml /opt/tomcat8/conf/
# adapt some config files
RUN perl -pi -e 's/#useProxies = true/useProxies = true/' /opt/lindat-dspace/installation/config/dspace.cfg
RUN perl -pi -e 's#    (?s).*org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe.*#    (?s).*org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe.*,\\\n    (?s).*user-agent=.kube-probe.*#' /opt/lindat-dspace/installation/config/modules/lr.cfg
# set up handle server
COPY commul-customization/hdl-setup.tmp /tmp/
RUN cat /tmp/hdl-setup.tmp | /opt/lindat-dspace/installation/bin/dspace make-handle-config /opt/lindat-dspace/installation/handle-server/
COPY commul-customization/config.dct /opt/lindat-dspace/installation/handle-server/config.dct
RUN cp /opt/repository/workspace/config/etc/default/handle-server /etc/default/
RUN cp /opt/repository/workspace/config/etc/init.d/handle-server /etc/init.d/
RUN chmod +x /etc/init.d/handle-server
RUN perl -pi -e 's#DSPACE_INSTALLATION_DIRECTORY=#DSPACE_INSTALLATION_DIRECTORY=/opt/lindat-dspace/installation#' /etc/default/handle-server

# copy entrypoint script and start
COPY commul-customization/entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod u+x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]