diff --git a/env_files/cqpserver.env.tpl b/.env.tpl
similarity index 100%
rename from env_files/cqpserver.env.tpl
rename to .env.tpl
diff --git a/.gitignore b/.gitignore
index d65559d..14b9f86 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
+data
+files
+registry
*.env
-volumes
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ea77125..3d97cac 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,44 +1,71 @@
-image: docker:stable
-
-services:
- - docker:stable-dind
+image: docker:19.03.13
variables:
- DOCKER_DRIVER: overlay2
+ DOCKER_TLS_CERTDIR: "/certs"
+
+services:
+ - docker:19.03.13-dind
stages:
- build
- push
-before_script:
- - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+.reg_setup:
+ before_script:
+ - apk add --no-cache curl
+ - curl --fail --show-error --location "https://github.com/genuinetools/reg/releases/download/v$REG_VERSION/reg-linux-amd64" --output /usr/local/bin/reg
+ - echo "$REG_SHA256 /usr/local/bin/reg" | sha256sum -c -
+ - chmod a+x /usr/local/bin/reg
+ variables:
+ REG_SHA256: ade837fc5224acd8c34732bf54a94f579b47851cc6a7fd5899a98386b782e228
+ REG_VERSION: 0.16.1
-Build:
+build_image:
script:
- - docker build --pull -t $CI_REGISTRY_IMAGE:tmp build/cqpserver
- - docker push $CI_REGISTRY_IMAGE:tmp
+ - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+ - docker build -t $INTERMEDIATE_IMAGE_TAG .
+ - docker push $INTERMEDIATE_IMAGE_TAG
stage: build
tags:
- - docker
+ - docker
+ variables:
+ INTERMEDIATE_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
-Push latest:
+push_master:
+ extends:
+ - .reg_setup
only:
- master
script:
- - docker pull $CI_REGISTRY_IMAGE:tmp
- - docker tag $CI_REGISTRY_IMAGE:tmp $CI_REGISTRY_IMAGE:latest
- - docker push $CI_REGISTRY_IMAGE:latest
+ - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+ - docker pull $INTERMEDIATE_IMAGE_TAG
+ - /usr/local/bin/reg rm -d --auth-url $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $INTERMEDIATE_IMAGE_TAG
+ - docker tag $INTERMEDIATE_IMAGE_TAG $IMAGE_TAG
+ - docker push $IMAGE_TAG
stage: push
tags:
- - docker
+ - docker
+ variables:
+ IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
+ INTERMEDIATE_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
-Push tag:
+push_other:
+ extends:
+ - .reg_setup
+ except:
+ - master
only:
+ - branches
- tags
script:
- - docker pull $CI_REGISTRY_IMAGE:tmp
- - docker tag $CI_REGISTRY_IMAGE:tmp $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+ - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+ - docker pull $INTERMEDIATE_IMAGE_TAG
+ - /usr/local/bin/reg rm -d --auth-url $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $INTERMEDIATE_IMAGE_TAG
+ - docker tag $INTERMEDIATE_IMAGE_TAG $IMAGE_TAG
+ - docker push $IMAGE_TAG
stage: push
tags:
- - docker
+ - docker
+ variables:
+ IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+ INTERMEDIATE_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
diff --git a/build/cqpserver/Dockerfile b/Dockerfile
similarity index 54%
rename from build/cqpserver/Dockerfile
rename to Dockerfile
index f995538..42a8d29 100644
--- a/build/cqpserver/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,7 @@
FROM debian:10-slim
-LABEL maintainer="inf_sfb1288@lists.uni-bielefeld.de"
+LABEL authors="Patrick Jentsch
, Stephan Porada "
ARG CWB_REVISION=1499
@@ -13,18 +13,15 @@ ENV LANG=C.UTF-8
EXPOSE 4877
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- subversion
-
-
WORKDIR /root
-# Installation: IMS Open Corpus Workbench
-RUN apt-get install -y --no-install-recommends \
- autoconf bison flex gcc make pkg-config libc6-dev libncurses5 libncurses5-dev libpcre3-dev libglib2.0-0 libglib2.0-dev libreadline7 libreadline-dev \
- && svn checkout http://svn.code.sf.net/p/cwb/code/cwb/trunk@${CWB_REVISION} cwb \
+## Install IMS Open Corpus Workbench ##
+RUN apt-get update \
+ && apt-get install --no-install-recommends --yes \
+ subversion autoconf bison flex gcc make pkg-config libc6-dev libncurses5 libncurses5-dev libpcre3-dev libglib2.0-0 libglib2.0-dev libreadline7 libreadline-dev \
+ && rm -r /var/lib/apt/lists/* \
+ && svn checkout "http://svn.code.sf.net/p/cwb/code/cwb/trunk@${CWB_REVISION}" cwb \
&& cd cwb \
&& make clean PLATFORM=${CWB_PLATFORM} SITE=${CWB_SITE} \
&& make depend PLATFORM=${CWB_PLATFORM} SITE=${CWB_SITE} \
@@ -34,9 +31,10 @@ RUN apt-get install -y --no-install-recommends \
&& cd .. \
&& rm -r cwb
-# Installation: Perl CWB package
+
+## Installation: Perl CWB package ##
RUN yes | cpan HTML::Entities \
- && svn checkout http://svn.code.sf.net/p/cwb/code/perl/trunk/CWB@${CWB_REVISION} perl-cwb \
+ && svn checkout "http://svn.code.sf.net/p/cwb/code/perl/trunk/CWB@${CWB_REVISION}" perl-cwb \
&& cd perl-cwb \
&& perl Makefile.PL \
&& make \
@@ -46,9 +44,6 @@ RUN yes | cpan HTML::Entities \
&& rm -r perl-cwb
-RUN rm -rf /var/lib/apt/lists/*
-
-
COPY docker-entrypoint.sh /usr/local/bin/
diff --git a/build/cqpserver/docker-entrypoint.sh b/build/cqpserver/docker-entrypoint.sh
deleted file mode 100755
index be87205..0000000
--- a/build/cqpserver/docker-entrypoint.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-
-if [ "${1}" == "build-corpus" ]; then
- # Input:
- # - Source file: "/root/files/corpus.vrt"
- # Output
- # - Corpus name: "CORPUS"
- # - Corpus data directory: "/corpora/data/corpus"
- # - Corpus registry file: "/usr/local/share/cwb/registry/corpus"
- mkdir -p /corpora/data/corpus
- cwb-encode \
- -c utf8 \
- -d /corpora/data/corpus \
- -f /root/files/corpus.vrt \
- -R /usr/local/share/cwb/registry/corpus \
- -P lemma -P simple_pos -P pos -P ner \
- -S text:0+address+author+booktitle+chapter+editor+institution+journal+pages+publisher+publishing_year+school+title -S s \
- -xsB -9
- cwb-make \
- -V CORPUS
-elif [ "${1}" == "cqpserver" ]; then
- CQPSERVER_HOST="${CQPSERVER_HOST:-*}"
- CQPSERVER_PASSWORD="${CQPSERVER_PASSWORD:-}"
- CQPSERVER_USER="${CQPSERVER_USER:-anonymous}"
-
- echo "host ${CQPSERVER_HOST};" > cqpserver.init
- echo "user ${CQPSERVER_USER} \"${CQPSERVER_PASSWORD}\";" >> cqpserver.init
-
- cqpserver -I cqpserver.init "${@:2}"
-else
- echo "Usage: ${0} {build-corpus|cqpserver [OPTION]...}"
-fi
diff --git a/docker-compose.yml b/docker-compose.yml
index 6fbcbe5..956f63d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,15 +1,12 @@
-version: '3'
+version: '3.5'
services:
cqpserver:
- command:
- - "cqpserver"
- build: ./build/cqpserver
- env_file: ./env_files/cqpserver.env
+ env_file: .env
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/cqpserver:latest
ports:
- - 4877:4877
+ - "4877:4877"
volumes:
- - ./volumes/cqpserver/data:/corpora/data
- - ./volumes/cqpserver/files:/root/files
- - ./volumes/cqpserver/registry:/usr/local/share/cwb/registry
+ - "${HOST_CQPSERVER_DATA_DIR:-./data}:/corpora/data"
+ - "${HOST_CQPSERVER_FILES_DIR:-./files}:/root/files"
+ - "${HOST_CQPSERVER_REGISTRY_DIR:-./registry}:/usr/local/share/cwb/registry"
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100755
index 0000000..b8a0062
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+if [[ "$#" -eq 0 || "${1}" == "cqpserver" ]]; then
+ CQPSERVER_HOST="${CQPSERVER_HOST:-*}"
+ CQPSERVER_PASSWORD="${CQPSERVER_PASSWORD:-}"
+ CQPSERVER_USER="${CQPSERVER_USER:-anonymous}"
+ echo "host ${CQPSERVER_HOST};" > cqpserver.init
+ echo "user ${CQPSERVER_USER} \"${CQPSERVER_PASSWORD}\";" >> cqpserver.init
+fi
+
+if [[ "$#" -eq 0 ]]; then
+ cqpserver -I cqpserver.init
+elif [[ "$1" == "build-corpus" ]]; then
+ # Input:
+ # - Source file: "/root/files/corpus.vrt"
+ # Output
+ # - Corpus name: "CORPUS"
+ # - Corpus data directory: "/corpora/data/corpus"
+ # - Corpus registry file: "/usr/local/share/cwb/registry/corpus"
+ mkdir -p /corpora/data/corpus
+ cwb-encode \
+ -c utf8 \
+ -d /corpora/data/corpus \
+ -f /root/files/corpus.vrt \
+ -R /usr/local/share/cwb/registry/corpus \
+ -P lemma -P simple_pos -P pos -P ner \
+ -S text:0+address+author+booktitle+chapter+editor+institution+journal+pages+publisher+publishing_year+school+title -S s \
+ -xsB -9
+ cwb-make \
+ -V CORPUS
+elif [ "${1}" == "cqpserver" ]; then
+ cqpserver -I cqpserver.init "${@:2}"
+else
+ exec ${@:1}
+ echo "$0 [COMMAND]"
+ echo ""
+ echo "cqpserver startup and corpus build script"
+ echo ""
+ echo "Commands:"
+ echo " build-corpus"
+ echo " cqpserver"
+fi