Skip to content
Snippets Groups Projects
Commit e8e8cb9b authored by Alexander König's avatar Alexander König
Browse files

spread out this build process into two separate images, one for the database and one for the rest

parent c02a664e
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
############################################################
FROM ubuntu
MAINTAINER Alexander König <Alexander.Koenig@eurac.edu>
LABEL maintainer="Alexander König <Alexander.Koenig@eurac.edu>"
# set Dspace environment variables
#ENV DSPACE_INSTANCE_NAME=repository
......
############################################################
# Dockerfile to build LINDAT Dspace container images
# Based on Ubuntu
############################################################
FROM ubuntu
LABEL maintainer="Alexander König <Alexander.Koenig@eurac.edu>"
# set Dspace environment variables
#ENV DSPACE_INSTANCE_NAME=repository
#ENV DSPACE_SOURCE_DIRECTORY=/opt/repository/sources/dspace
#ENV DSPACE_WORKSPACE=/opt/repository/workspace
#ENV DSPACE_INSTALLATION_DIRECTORY=/opt/lindat-dspace/installation
ENV CI=true
# install jdk, ant, psql, mvn, make, libxml, xsltproc, zip, wget
RUN apt-get update &&\
apt-get -y upgrade &&\
apt-get -y install openjdk-8-jdk ant maven make libxml2-utils xsltproc unzip wget locales
# set up a proper locale
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
# build tomcat 8.0.35, version recommended by LINDAT
RUN wget -O /tmp/apache-tomcat-8.0.35.tar.gz https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.35/bin/apache-tomcat-8.0.35.tar.gz
RUN mkdir /opt/tomcat8
RUN tar xvzf /tmp/apache-tomcat-8.0.35.tar.gz -C /opt/tomcat8/ --strip-components=1
RUN groupadd tomcat8
RUN useradd -s /bin/false -g tomcat8 -d /opt/tomcat8/ tomcat8
# doesn't this make more sense?
RUN chown -R tomcat8:tomcat8 /opt/tomcat8
# RUN chgrp -R tomcat8 /opt/tomcat8/
# RUN chmod -R g+r /opt/tomcat8/conf/
# RUN chmod g+x /opt/tomcat8/conf/
# RUN chown -R tomcat8 /opt/tomcat8/webapps/ /opt/tomcat8/work/ /opt/tomcat8/temp/ /opt/tomcat8/logs/
# copy the init script and the modified catalina.sh
COPY commul-customization/tomcat8 /etc/init.d/
RUN chmod a+x /etc/init.d/tomcat8
COPY commul-customization/catalina.sh /opt/tomcat8/bin/
COPY commul-customization/setenv.sh /opt/tomcat8/bin/
# build nginx
RUN apt-get install -y gcc zlib1g zlib1g-dev libpcre3 libpcre3-dev curl cpanminus
RUN cpanm File::Spec::Functions
RUN cpanm Term::ReadLine
COPY commul-customization/nginx_build.sh /tmp/nginx_build.sh
RUN chmod a+x /tmp/nginx_build.sh
WORKDIR /tmp/
RUN ./nginx_build.sh
# copy the init script
COPY commul-customization/nginx /etc/init.d/
RUN chmod a+x /etc/init.d/nginx
# add a symlink
RUN ln -s /opt/nginx/sbin/nginx /usr/sbin/nginx
# get aai project
RUN apt-get install -y git
RUN git clone https://github.com/ufal/lindat-aai-discovery.git /opt/repository/sources/lindat-aai-discovery
# install Dspace
RUN git clone https://github.com/commul/clarin-dspace.git -b clarin /opt/repository/sources/dspace
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
# installing backup2l, this might be unnecessary
RUN apt-get install -y devscripts
RUN git clone https://github.com/gkiefer/backup2l.git /tmp/backup2l
WORKDIR /tmp/backup2l/
RUN ./install-sh -fc
RUN mkdir -p /home/backup
# 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/
COPY commul-customization/tomcat-server.xml /opt/tomcat8/conf/server.xml
RUN chmod u+x /opt/repository/workspace/scripts/*_stack.sh
# install libs and make deploy
WORKDIR /opt/repository/workspace/scripts
RUN make install_libs
# this uses the database
RUN make new_deploy
# convenience apps for debug purposes (vim and jsbeautifier)
RUN apt-get -y install vim
RUN apt-get -y install python-pip
RUN pip install --upgrade pip
RUN pip install jsbeautifier
# install shibboleth
COPY commul-customization/shibboleth_sp_with_fastcgi.sh /tmp/
RUN chmod u+x /tmp/shibboleth_sp_with_fastcgi.sh
RUN /tmp/shibboleth_sp_with_fastcgi.sh
# copy the init script
RUN cp /opt/shibboleth-sp-fastcgi/etc/shibboleth/shibd-debian /etc/init.d/shibd
RUN chmod a+x /etc/init.d/shibd
# create the test secure folder
RUN mkdir /opt/repository/sources/secure
# install supervisor
RUN apt-get install -y python-setuptools
RUN easy_install supervisor
COPY commul-customization/supervisord.conf /etc/
RUN mkdir -p /var/log/supervisor
# copy over config files
COPY commul-customization/default-ssl /opt/nginx/conf/
COPY commul-customization/nginx.conf /opt/nginx/conf/
COPY commul-customization/repository_auth /opt/nginx/conf/
COPY commul-customization/shibboleth2.xml /opt/shibboleth-sp-fastcgi/etc/shibboleth/
COPY commul-customization/shib_clear_headers /opt/nginx/conf/
COPY commul-customization/aai_config.js /opt/lindat-dspace/installation/webapps/xmlui/themes/UFAL/lib/js/
COPY commul-customization/aai.js /opt/repository/sources/lindat-aai-discovery/
WORKDIR /opt/repository/sources/lindat-aai-discovery/
RUN make aai.min.js
# copy certificate for lindat-dev
COPY commul-customization/certs/lindat-dev.key /etc/ssl/private/
COPY commul-customization/certs/lindat-dev_eurac_edu.pem /etc/ssl/certs/
# if deployed on lindat instead of lindat-dev comment the two lines above and uncomment the following 6 lines
## copy certificate for lindat
# COPY commul-customization/certs/lindat_eurac_edu.key /etc/ssl/private/
# COPY commul-customization/certs/lindat_eurac_edu.crt /etc/ssl/certs/
# RUN grep -rl lindat-dev /opt/lindat-common/public/ | xargs -i perl -pi -e 's/lindat-dev/lindat/g' {}
# convenience setting of workdir
WORKDIR /opt/repository/workspace/scripts
ENTRYPOINT ["/usr/local/bin/supervisord", "-c", "/etc/supervisord.conf"]
# afterwards log into the container
# docker run -h lindat-dev.eurac.edu -p 8080:8080 -p 80:80 -p 443:443 -ti eurac_lindat
#
# and do these things by hand
#
# start background programs
# supervisord -c /etc/supervisord.conf
# /etc/init.d/postgresql start
#
# create dspace admin as tomcat8, so that the log files have the right owner
# su -s /bin/sh tomcat8
# /opt/lindat-dspace/installation/bin/dspace create-administrator
# (interactive)
# start the server
# cd /opt/repository/sources/dspace/utilities/project_helpers/scripts
# ./start_stack.sh
FROM postgres:9.6.3
LABEL maintainer="Alexander König <Alexander.Koenig@eurac.edu>"
# copy int db script
RUN mkdir -p /docker-entrypoint-initdb.d
COPY commul-customization/init-dspace-dbs.sh /docker-entrypoint-initdb.d/
# copy utilities.sql
RUN mkdir /tmp/sql/
COPY commul-customization/utilities.sql /tmp/sql/
COPY commul-customization/license_definition.txt /tmp/sql/
#!/bin/bash
git clone https://github.com/commul/clarin-dspace.git -b clarin /tmp/dspace
cp /tmp/dspace/utilities/utilities.sql ./commul-customization/
cp /tmp/dspace/utilities/license_definition.txt ./commul-customization/
perl -pi -e "s#afile :utildir '/license_definition.txt'#afile '/tmp/sql/license_definition.txt'#;" ./commul-customization/utilities.sql
rm -rf /tmp/dspace
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER dspace WITH PASSWORD 'dspace1234';
CREATE DATABASE "XXX-LR-DATABASE" OWNER dspace ENCODING "UTF-8" TEMPLATE template0;
CREATE DATABASE "XXX-UTILS-DATABASE" OWNER dspace ENCODING "UTF-8" TEMPLATE template0;
EOSQL
psql --username "$POSTGRES_USER" --set=utildir="/tmp/sql/" -p 5432 XXX-UTILS-DATABASE < /tmp/sql/utilities.sql
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER secretdspaceuser WITH PASSWORD 'secretdspacepassword';
CREATE DATABASE "secretdspacedbname" OWNER secretdspaceuser ENCODING "UTF-8" TEMPLATE template0;
CREATE DATABASE "secretdspaceutilsdbname" OWNER secretdspaceuser ENCODING "UTF-8" TEMPLATE template0;
EOSQL
psql --username "$POSTGRES_USER" --set=utildir="/tmp/sql/" -p 5432 secretdspaceutilsdbname < /tmp/sql/utilities.sql
#!/bin/bash
perl -pi -e 's/secretdspaceuser/yourdspaceusername/; s/secretdspacepassword/yourdspacepassword/;' Dockerfile
perl -pi -e 's/secretdspaceuser/yourdspaceusername/; s/secretdspacepassword/yourdspacepassword/;' Dockerfile.dspace
perl -pi -e 's/secretdspaceuser/yourdspaceusername/; s/secretdspacepassword/yourdspacepassword/; s/secretdspacedbname/yourdspacedbname/; s/secretdspaceutilsdbname/yourdspaceutilsdbname/;' init-dspace-dbs.sh
perl -pi -e 's/secretdspaceuser/yourdspaceusername/; s/secretdspacepassword/yourdspacepassword/; s/secretmailuser/yourmailuser/; s/secretmailpassword/yourmailpassword/;' commul-customization/local.properties
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment