Commit 3636c17a authored by root's avatar root

first push

parents
File added
File added
File added
*.iml
.idea
\ No newline at end of file
#
# DSpace image
#
FROM openjdk:latest
MAINTAINER Bikram Dhoju <bikram.dhoju@olenepal.org>
# Environment variables
ENV DSPACE_VERSION=5.4 TOMCAT_MAJOR=8 TOMCAT_VERSION=8.0.45
ENV TOMCAT_TGZ_URL=https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz \
MAVEN_TGZ_URL=http://apache.mirror.iweb.ca/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \
DPSACE_TGZ_URL=https://github.com/DSpace/DSpace/releases/download/dspace-${DSPACE_VERSION}/dspace-${DSPACE_VERSION}-release.tar.gz
ENV CATALINA_HOME=/usr/local/tomcat DSPACE_HOME=/dspace
ENV PATH=$CATALINA_HOME/bin:$DSPACE_HOME/bin:$PATH
WORKDIR /tmp
# Install runtime and dependencies
RUN apt-get update && apt-get install -y ant postgresql-client \
&& mkdir -p maven dspace "$CATALINA_HOME" \
&& curl -fSL "$TOMCAT_TGZ_URL" -o tomcat.tar.gz \
&& curl -fSL "$MAVEN_TGZ_URL" -o maven.tar.gz \
&& curl -L "$DPSACE_TGZ_URL" -o dspace.tar.gz \
&& tar -xvf tomcat.tar.gz --strip-components=1 -C "$CATALINA_HOME" \
&& tar -xvf maven.tar.gz --strip-components=1 -C maven \
&& tar -xvf dspace.tar.gz --strip-components=1 -C dspace \
&& cd dspace && ../maven/bin/mvn package \
&& cd dspace/target/dspace-installer \
&& ant init_installation init_configs install_code copy_webapps \
&& rm -fr "$CATALINA_HOME/webapps" && mv -f /dspace/webapps "$CATALINA_HOME" \
&& sed -i s/CONFIDENTIAL/NONE/ /usr/local/tomcat/webapps/rest/WEB-INF/web.xml \
&& rm -fr ~/.m2 && rm -fr /tmp/* && apt-get remove -y ant
# Install root filesystem
ADD ./rootfs /
WORKDIR /dspace
# Build info
RUN echo "Debian GNU/Linux 8 (jessie) image. (`uname -rsv`)" >> /root/.built && \
echo "- with `java -version 2>&1 | awk 'NR == 2'`" >> /root/.built && \
echo "- with DSpace $DSPACE_VERSION on Tomcat $TOMCAT_VERSION" >> /root/.built
EXPOSE 8080
CMD ["start-dspace"]
Copyright (c) 2016 1science Devops Team <devops@1science.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
[![](https://badge.imagelayers.io/1science/dspace:latest.svg)](https://imagelayers.io/?images=1science/dspace:latest 'Get your own badge on imagelayers.io')
# What is DSpace?
![logo](https://wiki.duraspace.org/download/attachments/31655033/DSpace_logo_1in.png)
[DSpace](https://wiki.duraspace.org/display/DSDOC5x/Introduction) is an open source repository software package typically used for creating open access repositories for scholarly and/or published digital content. While DSpace shares some feature overlap with content management systems and document management systems, the DSpace repository software serves a specific need as a digital archives system, focused on the long-term storage, access and preservation of digital content.
This image is based on official [Java image](https://hub.docker.com/_/java/) and use [Tomcat](http://tomcat.apache.org/) to run DSpace as defined in the [installation guide](https://wiki.duraspace.org/display/DSDOC5x/Installing+DSpace).
# Usage
DSpace use [PostgreSQL](http://www.postgresql.org/) as database.
We might use an external database or create a PostgreSQL container linked to the DSpace container.
## Postgres as a container
First, we have to create the PostgreSQL container:
```
docker run -d --name dspace_db -p 5432:5432 postgres
```
then run DSpace linking the PostgreSQL container:
```
docker run -d --link dspace_db:postgres -p 8080:8080 1science/dspace
```
By default the database schema is created with the name `dspace` for a user `dspace` and password `dspace`, but it's possible to override this default settings :
```
docker run -d --link dspace_db:postgres \
-e POSTGRES_SCHEMA=my_dspace \
-e POSTGRES_USER=my_user \
-e POSTGRES_PASSWORD=my_password \
-p 8080:8080 1science/dspace
```
We might also used the Docker compose project in the `sample` directory.
## External database
When you use an external Postgres, you have to set some environment variables :
- `POSTGRES_DB_HOST` (required): The server host name or ip.
- `POSTGRES_DB_PORT` (optional): The server port (`5432` by default)
- `POSTGRES_SCHEMA` (optional): The database schema (`dspace` by default)
- `POSTGRES_USER` (optional): The user used by DSpace (`dspace` by default)
- `POSTGRES_PASSWORD` (optional): The password of the user used by DSpace (`dspace` by default)
- `POSTGRES_ADMIN_USER` (optional): The admin user creating the Database and the user (`postgres` by default)
- `POSTGRES_ADMIN_PASSWORD` (optional): The password of the admin user
```
docker run -d \
-e POSTGRES_DB_HOST=my_host \
-e POSTGRES_ADMIN_USER=my_admin \
-e POSTGRES_ADMIN_PASSWORD=my_admin_password \
-e POSTGRES_SCHEMA=my_dspace \
-e POSTGRES_USER=my_user \
-e POSTGRES_PASSWORD=my_password \
-p 8080:8080 1science/dspace
```
After few seconds DSpace should be accessible from:
- JSP User Interface: http://localhost:8080/jspui
- XML User Interface: http://localhost:8080/xmlui
- OAI-PMH Interface: http://localhost:8080/oai/request?verb=Identify
- REST: http://localhost:8080/rest
Note: The security constraint to tunnel request with SSL on the `/rest` endpoint has been removed, but it's very important to securize this endpoint in production through [Nginx](https://github.com/1science/docker-nginx) for example.
## Configure webapps installed
DSpace consumed a lot of memory, and sometimes we don't really need all the DSpace webapps. So iy's possible to set an environment variables to control the webapps installed :
```
docker run -d --link dspace_db:postgres \
-e DSPACE_WEBAPPS="jspui xmlui rest" \
-p 8080:8080 1science/dspace
```
The command above only installed the webapps `jspui` `xmlui` and `rest`.
# Build
This project is configured as an [automated build in Dockerhub](https://hub.docker.com/r/1science/java/).
Each branch give the related image tag.
# License
All the code contained in this repository, unless explicitly stated, is
licensed under ISC license.
A copy of the license can be found inside the [LICENSE](LICENSE) file.
#
# DSpace image with Consul Template
#
FROM 1science/dspace:5.4
# Consul template for configuration management
ENV S6_OVERLAY_VERSION=1.9.1.3 CONSUL_TEMPLATE_VERSION=0.11.0
# Install S6 Overlay, Consul Template
RUN curl -Ls https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-amd64.tar.gz | tar -xz -C / && \
curl -Ls https://github.com/hashicorp/consul-template/releases/download/v${CONSUL_TEMPLATE_VERSION}/consul_template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip -o consul-template.zip && unzip consul-template.zip -d /usr/local/bin && \
rm -f consul-template* && \
echo -ne "- with `consul-template -v 2>&1`\n" >> /root/.built
\ No newline at end of file
#!/usr/bin/with-contenv sh
set -e
if [ -z ${RUN_ON_AWS} ]; then
CONSUL_URL=${CONSUL_URL:-localhost:8500}
else
# Resolve the EC2 IP running a Consul Agent through API
# This a workaround for this issue : https://github.com/aws/amazon-ecs-agent/issues/185
HOST_IP=$(curl http://169.254.169.254/latest/meta-data/local-hostname)
CONSUL_URL="$HOST_IP:8500"
fi
if [ -d /etc/consul-template/conf ]; then
exec consul-template \
-consul ${CONSUL_URL} \
-config "/etc/consul-template/conf"
fi
\ No newline at end of file
logo.png

12.5 KB

#!/usr/bin/env bash
set -e
POSTGRES_DB_HOST=${POSTGRES_DB_HOST:-$POSTGRES_PORT_5432_TCP_ADDR}
POSTGRES_DB_PORT=${POSTGRES_DB_PORT:-$POSTGRES_PORT_5432_TCP_PORT}
POSTGRES_DB_PORT=${POSTGRES_DB_PORT:-5432}
POSTGRES_USER=${POSTGRES_USER:-dspace}
POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-dspace}
POSTGRES_SCHEMA=${POSTGRES_SCHEMA:-dspace}
POSTGRES_ADMIN_USER=${POSTGRES_ADMIN_USER:-postgres}
POSTGRES_ADMIN_PASSWORD=${POSTGRES_ADMIN_PASSWORD}
if [ -z $POSTGRES_DB_HOST -a -z $POSTGRES_DB_PORT ]; then
echo "Please create a postgres container and link it to this one:"
echo "> docker run -d --name dspace_db postgres"
echo "> docker run --link dspace_db:postgres -p 8080:8080 1science/dspace setup-postgres"
exit 1
fi
DSPACE_CFG=/dspace/config/dspace.cfg
if [ -n $POSTGRES_ADMIN_PASSWORD ]; then
export PGPASSWORD=$POSTGRES_ADMIN_PASSWORD
fi
# Create database if not exists
SCHEMA_EXISTS=$(psql -h "$POSTGRES_DB_HOST" -p "$POSTGRES_DB_PORT" -U "$POSTGRES_ADMIN_USER" -lqt | cut -d \| -f 1 | grep -qw "$POSTGRES_SCHEMA";echo $?)
if [ $SCHEMA_EXISTS -eq 1 ]; then
psql -h "$POSTGRES_DB_HOST" -p "$POSTGRES_DB_PORT" -d postgres -U "$POSTGRES_ADMIN_USER" -c "CREATE DATABASE $POSTGRES_SCHEMA;" 2>&1 > /dev/null
echo "Database '${POSTGRES_SCHEMA}' created"
fi
# Create user
USER_EXISTS=$(psql -h "$POSTGRES_DB_HOST" -p "$POSTGRES_DB_PORT" -d postgres -U "$POSTGRES_ADMIN_USER" -c "SELECT 1 FROM pg_roles WHERE rolname='${POSTGRES_USER}';" | grep "1" 2>&1 > /dev/null; echo $?)
if [ $USER_EXISTS -eq 1 ]; then
psql -h "$POSTGRES_DB_HOST" -p "$POSTGRES_DB_PORT" -d postgres -U "$POSTGRES_ADMIN_USER" -c "CREATE USER $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD';" 2>&1 > /dev/null
psql -h "$POSTGRES_DB_HOST" -p "$POSTGRES_DB_PORT" -d postgres -U "$POSTGRES_ADMIN_USER" -c "GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_SCHEMA to $POSTGRES_USER;" 2>&1 > /dev/null
echo "User '${POSTGRES_USER}' created"
fi
# Configure database in dspace.cfg
sed -i "s#db.url = jdbc:postgresql://localhost:5432/dspace#db.url = jdbc:postgresql://${POSTGRES_DB_HOST}:${POSTGRES_DB_PORT}/${POSTGRES_SCHEMA}#" ${DSPACE_CFG}
sed -i "s#db.username = dspace#db.username = ${POSTGRES_USER}#" ${DSPACE_CFG}
sed -i "s#db.password = dspace#db.password = ${POSTGRES_PASSWORD}#" ${DSPACE_CFG}
echo "Dspace configuration changed"
# Create DSpace administrator
dspace create-administrator -e ${ADMIN_EMAIL:-devops@1science.com} -f ${ADMIN_FIRSTNAME:-DSpace} -l ${ADMIN_LASTNAME:-Admin} -p ${ADMIN_PASSWD:-admin123} -c ${ADMIN_LANGUAGE:-en}
#!/usr/bin/env bash
POSTGRES_DB_HOST=${POSTGRES_DB_HOST:-$POSTGRES_PORT_5432_TCP_ADDR}
POSTGRES_DB_PORT=${POSTGRES_DB_PORT:-$POSTGRES_PORT_5432_TCP_PORT}
POSTGRES_DB_PORT=${POSTGRES_DB_PORT:-5432}
# Create an configure database
if [ -n $POSTGRES_DB_HOST -a -n $POSTGRES_DB_PORT ]; then
# Setup postgres
setup-postgres
fi
# Remove unused webapps
# see https://wiki.duraspace.org/display/DSDOC5x/Performance+Tuning+DSpace
if [ -n "$DSPACE_WEBAPPS" ]; then
webapps=($(ls /usr/local/tomcat/webapps | tr -d '/'))
webapps_to_keep=($(echo "$DSPACE_WEBAPPS solr"))
for element in ${webapps_to_keep[@]}; do
webapps=(${webapps[@]/$element})
done
for webapp in ${webapps[@]}; do
rm -rf /usr/local/tomcat/webapps/$webapp
done
fi
# Start Tomcat
exec catalina.sh run
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
___ _ ____ _____
< /_________(_)__ ____ ________ / __ \/ ___/____ ____ _________
/ / ___/ ___/ / _ \/ __ \/ ___/ _ \ / / / /\__ \/ __ \/ __ `/ ___/ _ \
/ (__ ) /__/ / __/ / / / /__/ __/ / /_/ /___/ / /_/ / /_/ / /__/ __/
/_/____/\___/_/\___/_/ /_/\___/\___/ /_____//____/ .___/\__,_/\___/\___/
/_/
# Display banner
if [ -f "$HOME/.banner" ]; then
cat "$HOME/.banner"
fi
# Display build message
if [ -f "$HOME/.built" ]; then
cat "$HOME/.built"
fi
export PS1="\[\e[32;1m\]\u@\w > \[\e[0m\]"
# Alias definitions.
#
alias df='df -h'
alias du='du -h'
alias ls='ls -p'
alias ll='ls -l'
alias la='ls -la'
# Avoid errors... use -f to skip confirmation.
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
# This Dockerfile is needed just to control the startup order
# see: https://docs.docker.com/compose/startup-order/
FROM 1science/dspace:5.4
ADD wait-for-postgres.sh /usr/local/bin
ENTRYPOINT ["wait-for-postgres.sh", "postgres"]
CMD ["start-dspace"]
#!/bin/bash
set -e
host="$1"
shift
cmd="$@"
until psql -h "$host" -U "postgres" -c '\l'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up - executing command"
exec $cmd
# Postgres database
postgres:
image: postgres:9.5
ports:
- 5432:5432
# DSpace
app:
build: ./app
ports:
- 8080:8080
links:
- postgres
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment