Skip to content

Commit

Permalink
Merge pull request #4265 from IQSS/develop
Browse files Browse the repository at this point in the history
v4.8.2
  • Loading branch information
kcondon authored Nov 8, 2017
2 parents e2682d1 + 529b1e7 commit ab613a3
Show file tree
Hide file tree
Showing 107 changed files with 2,311 additions and 543 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# See `conf/docker` for Docker images
42 changes: 42 additions & 0 deletions conf/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
# Creates images and pushes them to Docker Hub.
# The "kick-the-tires" tag should be relatively stable. No breaking changes.
# Push to custom tags or tags based on branch names to iterate on the images.
if [ -z "$1" ]; then
echo "No argument supplied. Please specify \"branch\" or \"custom my-custom-tag\" for experiments or \"stable\" if your change won't break anything."
exit 1
fi

if [ "$1" == 'branch' ]; then
echo "We'll push a tag to the branch you're on."
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
TAG=$GIT_BRANCH
elif [ "$1" == 'stable' ]; then
echo "We'll push a tag to the most stable tag (which isn't saying much!)."
TAG=kick-the-tires
elif [ "$1" == 'custom' ]; then
if [ -z "$1" ]; then
echo "You must provide a custom tag as the second argument."
exit 1
else
echo "We'll push a custom tag."
TAG=$2
fi
else
echo "Unexpected argument: $1. Exiting. Run with no arguments for help."
exit 1
fi
echo Images will be pushed to Docker Hub with the tag \"$TAG\".
# Use "conf" directory as context so we can copy schema.xml into Solr image.
docker build -t iqss/dataverse-solr:$TAG -f solr/Dockerfile ../../conf
docker push iqss/dataverse-solr:$TAG
# TODO: Think about if we really need dataverse.war because it's in dvinstall.zip.
# FIXME: Automate the building of dataverse.war and dvinstall.zip. Think about https://github.com/IQSS/dataverse/issues/3974 and https://github.com/IQSS/dataverse/pull/3975
cp ../../target/dataverse*.war dataverse-glassfish/dataverse.war
cp ../../scripts/installer/dvinstall.zip dataverse-glassfish
cp ../../doc/sphinx-guides/source/_static/util/default.config dataverse-glassfish
cp ../../downloads/glassfish-4.1.zip dataverse-glassfish
cp ../../downloads/weld-osgi-bundle-2.2.10.Final-glassfish4.jar dataverse-glassfish
docker build -t iqss/dataverse-glassfish:$TAG dataverse-glassfish
# FIXME: Check the output of `docker build` and only push on success.
docker push iqss/dataverse-glassfish:$TAG
5 changes: 5 additions & 0 deletions conf/docker/dataverse-glassfish/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
glassfish-4.1.zip
weld-osgi-bundle-2.2.10.Final-glassfish4.jar
dvinstall.zip
dataverse.war
default.config
98 changes: 98 additions & 0 deletions conf/docker/dataverse-glassfish/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
FROM centos:7.2.1511
MAINTAINER Dataverse ([email protected])

COPY glassfish-4.1.zip /tmp
COPY weld-osgi-bundle-2.2.10.Final-glassfish4.jar /tmp
COPY default.config /tmp
COPY dvinstall.zip /tmp

# Install dependencies
#RUN yum install -y unzip
RUN yum install -y \
cronie \
git \
java-1.8.0-openjdk-devel \
nc \
perl \
postgresql \
sha1sum \
unzip \
wget

ENV GLASSFISH_DOWNLOAD_SHA1 d1a103d06682eb08722fbc9a93089211befaa080
ENV GLASSFISH_DIRECTORY "/usr/local/glassfish4"
ENV HOST_DNS_ADDRESS "localhost"
ENV POSTGRES_DB "dvndb"
ENV POSTGRES_USER "dvnapp"
ENV RSERVE_USER "rserve"
ENV RSERVE_PASSWORD "rserve"

#RUN ls /tmp
#
RUN find /tmp
#
#RUN exitEarly

# Install Glassfish 4.1

RUN cd /tmp \
&& unzip glassfish-4.1.zip \
&& mv glassfish4 /usr/local \
&& cd /usr/local/glassfish4/glassfish/modules \
&& rm weld-osgi-bundle.jar \
&& cp /tmp/weld-osgi-bundle-2.2.10.Final-glassfish4.jar . \
#FIXME: Patch Grizzly too!
&& echo "Done installing and patching Glassfish"

RUN chmod g=u /etc/passwd

RUN mkdir -p /home/glassfish
RUN chgrp -R 0 /home/glassfish && \
chmod -R g=u /home/glassfish

RUN mkdir -p /usr/local/glassfish4
RUN chgrp -R 0 /usr/local/glassfish4 && \
chmod -R g=u /usr/local/glassfish4


#RUN exitEarlyBeforeJq
RUN yum -y install epel-release
RUN yum install -y jq

# Install jq
#RUN cd /tmp \
# && wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 \
# && mv jq-linux64 /usr/local/bin \
# && chmod +x /usr/local/bin/jq-linux64 \
# && ln -s /usr/local/bin/jq-linux64 /usr/local/bin/jq

# Customized persistence xml to avoid database recreation
#RUN mkdir -p /tmp/WEB-INF/classes/META-INF/
#COPY WEB-INF/classes/META-INF/persistence.xml /tmp/WEB-INF/classes/META-INF/

# Install iRods iCommands
#RUN cd /tmp \
# && yum -y install epel-release \
# && yum -y install ftp://ftp.renci.org/pub/irods/releases/4.1.6/centos7/irods-icommands-4.1.6-centos7-x86_64.rpm

#COPY config-glassfish /root/dvinstall
#COPY restart-glassfish /root/dvinstall
#COPY config-dataverse /root/dvinstall

#RUN cd /root/dvinstall && ./config-dataverse

COPY ./entrypoint.sh /
#COPY ./ddl /root/dvinstall
#COPY ./init-postgres /root/dvinstall
#COPY ./init-glassfish /root/dvinstall
#COPY ./init-dataverse /root/dvinstall
#COPY ./setup-all.sh /root/dvinstall
#COPY ./setup-irods.sh /root/dvinstall
COPY ./Dockerfile /

VOLUME /usr/local/glassfish4/glassfish/domains/domain1/files

EXPOSE 8080

ENTRYPOINT ["/entrypoint.sh"]
CMD ["dataverse"]
135 changes: 135 additions & 0 deletions conf/docker/dataverse-glassfish/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/bin/bash -x

# Entrypoint script for Dataverse web application. This script waits
# for dependent services (Rserve, Postgres, Solr) to start before
# initializing Glassfish.

echo "whoami before..."
whoami
if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
# Make `whoami` return the glassfish user. # See https://docs.openshift.org/3.6/creating_images/guidelines.html#openshift-origin-specific-guidelines
# Fancy bash magic from https://github.com/RHsyseng/container-rhel-examples/blob/1208dcd7d4f431fc6598184dba6341b9465f4197/starter-arbitrary-uid/bin/uid_entrypoint#L4
echo "${USER_NAME:-glassfish}:x:$(id -u):0:${USER_NAME:-glassfish} user:/home/glassfish:/bin/bash" >> /etc/passwd
fi
fi
echo "whoami after"
whoami

set -e

if [ "$1" = 'dataverse' ]; then

export GLASSFISH_DIRECTORY=/usr/local/glassfish4
export HOST_DNS_ADDRESS=localhost

TIMEOUT=30

if [ -n "$RSERVE_SERVICE_HOST" ]; then
RSERVE_HOST=$RSERVE_SERVICE_HOST
elif [ -n "$RSERVE_PORT_6311_TCP_ADDR" ]; then
RSERVE_HOST=$RSERVE_PORT_6311_TCP_ADDR
elif [ -z "$RSERVE_HOST" ]; then
RSERVE_HOST="localhost"
fi
export RSERVE_HOST

if [ -n "$RSERVE_SERVICE_PORT" ]; then
RSERVE_PORT=$RSERVE_SERVICE_PORT
elif [ -n "$RSERVE_PORT_6311_TCP_PORT" ]; then
RSERVE_PORT=$RSERVE_PORT_6311_TCP_PORT
elif [ -z "$RSERVE_PORT" ]; then
RSERVE_PORT="6311"
fi
export RSERVE_PORT

echo "Using Rserve at $RSERVE_HOST:$RSERVE_PORT"

if ncat $RSERVE_HOST $RSERVE_PORT -w $TIMEOUT --send-only < /dev/null > /dev/null 2>&1 ; then
echo Rserve running;
else
echo Optional service Rserve not running.
fi


# postgres
if [ -n "$POSTGRES_SERVICE_HOST" ]; then
POSTGRES_HOST=$POSTGRES_SERVICE_HOST
elif [ -n "$POSTGRES_PORT_5432_TCP_ADDR" ]; then
POSTGRES_HOST=$POSTGRES_PORT_5432_TCP_ADDR
elif [ -z "$POSTGRES_HOST" ]; then
POSTGRES_HOST="localhost"
fi
export POSTGRES_HOST

if [ -n "$POSTGRES_SERVICE_PORT" ]; then
POSTGRES_PORT=$POSTGRES_SERVICE_PORT
elif [ -n "$POSTGRES_PORT_5432_TCP_PORT" ]; then
POSTGRES_PORT=$POSTGRES_PORT_5432_TCP_PORT
else
POSTGRES_PORT=5432
fi
export POSTGRES_PORT

echo "Using Postgres at $POSTGRES_HOST:$POSTGRES_PORT"

if ncat $POSTGRES_HOST $POSTGRES_PORT -w $TIMEOUT --send-only < /dev/null > /dev/null 2>&1 ; then
echo Postgres running;
else
echo Required service Postgres not running. Have you started the required services?
exit 1
fi

# solr
if [ -n "$SOLR_SERVICE_HOST" ]; then
SOLR_HOST=$SOLR_SERVICE_HOST
elif [ -n "$SOLR_PORT_8983_TCP_ADDR" ]; then
SOLR_HOST=$SOLR_PORT_8983_TCP_ADDR
elif [ -z "$SOLR_HOST" ]; then
SOLR_HOST="localhost"
fi
export SOLR_HOST

if [ -n "$SOLR_SERVICE_PORT" ]; then
SOLR_PORT=$SOLR_SERVICE_PORT
elif [ -n "$SOLR_PORT_8983_TCP_PORT" ]; then
SOLR_PORT=$SOLR_PORT_8983_TCP_PORT
else
SOLR_PORT=8983
fi
export SOLR_PORT

echo "Using Solr at $SOLR_HOST:$SOLR_PORT"

if ncat $SOLR_HOST $SOLR_PORT -w $TIMEOUT --send-only < /dev/null > /dev/null 2>&1 ; then
echo Solr running;
else
echo Required service Solr not running. Have you started the required services?
exit 1
fi

GLASSFISH_INSTALL_DIR="/usr/local/glassfish4"
cd $GLASSFISH_INSTALL_DIR
cp /tmp/dvinstall.zip $GLASSFISH_INSTALL_DIR
unzip dvinstall.zip
cd dvinstall
echo Copying the non-interactive file into place
cp /tmp/default.config .
echo Looking at first few lines of default.config
head default.config
# non-interactive install
echo Running non-interactive install
#./install -y -f > install.out 2> install.err
./install -y -f

# if [ -n "$DVICAT_PORT_1247_TCP_PORT" ]; then
# ./setup-irods.sh
# fi

echo -e "\n\nDataverse started"

sleep infinity
else
exec "$@"
fi

3 changes: 3 additions & 0 deletions conf/docker/postgresql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PostgreSQL for Dataverse (but consider switching to the image from CentOS)
#
# See also conf/docker/dataverse-glassfish/Dockerfile
28 changes: 28 additions & 0 deletions conf/docker/solr/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM centos:7.2.1511
MAINTAINER Dataverse ([email protected])

RUN yum install -y wget unzip perl git java-1.8.0-openjdk-devel postgresql.x86_64

# Install Solr 4.6.0
# The context of the build is the "conf" directory.
COPY solr/4.6.0/schema.xml /tmp

RUN cd /tmp && wget https://archive.apache.org/dist/lucene/solr/4.6.0/solr-4.6.0.tgz && \
tar xvzf solr-4.6.0.tgz && \
mv solr-4.6.0 /usr/local/ && \
cd /usr/local/solr-4.6.0/example/solr/collection1/conf/ && \
mv schema.xml schema.xml.backup && \
cp /tmp/schema.xml . && \
rm /tmp/solr-4.6.0.tgz

RUN ln -s /usr/local/solr-4.6.0/example/logs /var/log/solr

VOLUME /usr/local/solr-4.6.0/example/solr/collection1/data

EXPOSE 8983

COPY docker/solr/Dockerfile /Dockerfile
COPY docker/solr/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
CMD ["solr"]
10 changes: 10 additions & 0 deletions conf/docker/solr/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

if [ "$1" = 'solr' ]; then
cd /usr/local/solr-4.6.0/example/
java -jar start.jar
elif [ "$1" = 'usage' ]; then
echo 'docker run -d iqss/dataverse-solr solr'
else
exec "$@"
fi
Loading

0 comments on commit ab613a3

Please sign in to comment.