Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image for GERBIL #396

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git
#src except src/main/properties (gerbil_keys.properties may contain secrets)
src/main/java
src/main/resources
src/main/properties/gerbil_keys.properties
src/test
# data directories
gerbil_data
indexes
repository
# block target, except war file and WEB-INF
target/*
!target/gerbil*
# block the gerbil_keys file in case it is in the target directory
target/gerbil-*/WEB-INF/classes/gerbil_keys.properties

40 changes: 20 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#############################
# BUILD THE WAR FILE
#############################

FROM maven:3.6.0-jdk-8 AS build

COPY src /tmp/src/
COPY repository /tmp/repository/
COPY pom.xml /tmp/

# overwrite gerbil-data path:
COPY docker-config/* /tmp/src/main/properties/
FROM tomcat:7-jre8-alpine
# Remove example projects, etc.
RUN rm -rf /usr/local/tomcat/webapps/*

WORKDIR /tmp/
# Download gerbil_data
RUN mkdir /data && mkdir /usr/local/tomcat/gerbil_data && mkdir /usr/local/tomcat/gerbil_data/cache && mkdir /usr/local/tomcat/gerbil_data/configs && mkdir /usr/local/tomcat/gerbil_data/database && mkdir /usr/local/tomcat/gerbil_data/datasets && mkdir /usr/local/tomcat/gerbil_data/indexes && mkdir /usr/local/tomcat/gerbil_data/output && mkdir /usr/local/tomcat/gerbil_data/resources && mkdir /usr/local/tomcat/gerbil_data/upload && mkdir /usr/local/tomcat/gerbil_data/systems
COPY scripts/download_data.sh download_data.sh
COPY scripts/functions.sh functions.sh
RUN ./download_data.sh /data

RUN mvn package -U -DskipTests
# Copy GERBIL's war file
COPY target/gerbil-*.war /usr/local/tomcat/webapps/gerbil.war

#############################
# BUILD THE DOCKER CONTAINER
#############################
# Copy GERBIL's properties files (from target, not from source!)
COPY target/gerbil-*/WEB-INF/classes/*.properties /data/properties/
RUN touch /data/properties/gerbil_keys.properties

FROM tomcat:7-jre8-alpine
# Set path to properties files
ENV GERBIL_PROP_DIR=/usr/local/tomcat/gerbil_properties/
# Create directory for properties
RUN mkdir /usr/local/tomcat/gerbil_properties/

RUN touch 20190115.txt
# Copy start script
COPY start_in_docker.sh start_in_docker.sh

COPY --from=build /tmp/target/gerbil-*.war $CATALINA_HOME/webapps/$gerbil.war
CMD ./start_in_docker.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GERBIL
[![BCH compliance](https://bettercodehub.com/edge/badge/AKSW/gerbil)](https://bettercodehub.com/)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/5634b1a7508f475886b027feac9da228)](https://www.codacy.com/gh/dice-group/gerbil/dashboard?utm_source=github.com&utm_medium=referral&utm_content=dice-group/gerbil&utm_campaign=Badge_Grade)

<img style="height: auto; width: auto; max-width: 300px; max-height: 300px;" src="http://139.18.2.164/mroeder/gerbil/gerbil_logo.png">
<img style="height: auto; width: auto; max-width: 300px; max-height: 300px;" src="https://hobbitdata.informatik.uni-leipzig.de/gerbil/gerbil_logo.png">

### General Information

Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.3"
services:
gerbil:
image: dicegroup/gerbil
ports:
- "1234:8080"
volumes:
# Properties files
- ./gerbil_properties:/usr/local/tomcat/gerbil_properties
# Database (Should be mounted to persist data!)
- ./gerbil_data/database:/usr/local/tomcat/gerbil_data/database
# Cache directory (Should be mounted to speed up new GERBIL instances)
- ./gerbil_data/cache:/usr/local/tomcat/gerbil_data/cache
# Datasets
- ./gerbil_data/datasets:/usr/local/tomcat/gerbil_data/datasets
# SameAs and Entity Indexes
- ./indexes:/usr/local/tomcat/indexes
44 changes: 36 additions & 8 deletions docker_build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
#!/bin/bash

export PROJECT="gerbil"
PROJECT="gerbil"
VERSION=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
echo "Building image for version ${VERSION} ..."

# build the docker container
docker build --no-cache -t philippkuntschik/$PROJECT .
#docker build -t "dicegroup/${PROJECT}:latest" .

docker tag philippkuntschik/$PROJECT philippkuntschik/$PROJECT:$VERSION
docker tag philippkuntschik/$PROJECT philippkuntschik/$PROJECT:latest
tagged_versions=("latest")

# If this is a snapshot version
if [[ "${VERSION}" == *-SNAPSHOT ]]
then
echo "The image will be tagged as snapshot"
#docker tag dicegroup/$PROJECT:latest "dicegroup/${PROJECT}:snapshot"
tagged_versions+=("snapshot")
else
# Tag the image with the versions by splitting the version string
IFS="."
read -r -a version_array <<< "${VERSION}"
TAG=""
for i in "${version_array[@]}"
do
# If the tag is empty so far
if [[ -z "${TAG}" ]]
then
TAG="${i}"
else
TAG="${TAG}.${i}"
fi
echo "The image will be tagged as ${TAG}"
docker tag dicegroup/$PROJECT:latest "dicegroup/${PROJECT}:${TAG}"
tagged_versions+=("${TAG}")
done
fi

# upload the image
if [[ $1 == "--upload" ]]
then
then
echo 'uploading...'
sudo docker push philippkuntschik/$PROJECT:$VERSION
sudo docker push philippkuntschik/$PROJECT:latest
fi
for i in "${tagged_versions[@]}"
do
sudo docker push "dicegroup/${PROJECT}:${i}"
done
fi
Loading