From a9f08eaadc315ce367be833f423dc3954bdf9334 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Wed, 2 Aug 2023 16:34:35 +0200 Subject: [PATCH] Update variables and add git info to footer --- .env.example | 4 +-- .github/workflows/ngrok.yml | 4 +-- .github/workflows/publish.yml | 4 +-- Dockerfile | 30 +++++++++-------- Makefile | 18 +++++----- build-git.sh | 33 ++++++++++--------- deploy.sh | 5 +++ docker-compose.yml | 5 ++- overwrites/docker-compose-app-builder-git.yml | 9 +++-- 9 files changed, 65 insertions(+), 47 deletions(-) diff --git a/.env.example b/.env.example index 1f73f1a..56e5440 100644 --- a/.env.example +++ b/.env.example @@ -31,8 +31,8 @@ APP_BUILDER_RELEASE_SQL=kitodo_3-4-3.sql #Release assets SQL file name APP_BUILDER_RELEASE_CONFIG_MODULES_ZIP=kitodo_3-4-3_config_modules.zip #Release asset config modules zip file name # Kitodo.Production Git Builder (when using overwrite ./overwrites/docker-compose-builder-git.yml) -APP_BUILDER_GIT_COMMIT=master #Branch or commit of BUILDER_GIT_SOURCE_URL -APP_BUILDER_GIT_SOURCE_URL=https://github.com/kitodo/kitodo-production/ #Repository of BUILDER_GIT_COMMIT +APP_BUILDER_GIT_REF=master #Branch or commit of BUILDER_GIT_REPOSITORY +APP_BUILDER_GIT_REPOSITORY=kitodo/kitodo-production #Repository of BUILDER_GIT_REF # Kitodo.Production (when using overwrite ./overwrites/docker-compose-debug.yml) APP_DEBUG=true diff --git a/.github/workflows/ngrok.yml b/.github/workflows/ngrok.yml index e237938..1a95b6c 100644 --- a/.github/workflows/ngrok.yml +++ b/.github/workflows/ngrok.yml @@ -28,8 +28,8 @@ jobs: mv .env.example .env # Update .env - sed -i 's|APP_BUILDER_GIT_COMMIT=master|APP_BUILDER_GIT_COMMIT=${{ github.event.inputs.ref }}|g' .env - sed -i 's|APP_BUILDER_GIT_SOURCE_URL=https://github.com/kitodo/kitodo-production/|APP_BUILDER_GIT_SOURCE_URL=https://github.com/${{ github.event.inputs.repository }}/|g' .env + sed -i 's|APP_BUILDER_GIT_REF=master|APP_BUILDER_GIT_REF=${{ github.event.inputs.ref }}|g' .env + sed -i 's|APP_BUILDER_GIT_REPOSITORY=kitodo/kitodo-production|APP_BUILDER_GIT_REPOSITORY=${{ github.event.inputs.repository }}|g' .env - name: Run using docker run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 63a1a2f..d2562f2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,8 +53,8 @@ jobs: VCS_REF=${{ env.vcs_ref }} VCS_URL=https://github.com/kitodo/kitodo-production/ BUILDER_TYPE=git - BUILDER_GIT_COMMIT=master - BUILDER_GIT_SOURCE_URL=https://github.com/kitodo/kitodo-production/ + BUILDER_GIT_REF=master + BUILDER_GIT_REPOSITORY=kitodo/kitodo-production cache-from: type=gha cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index f2d57db..5a9b405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ RUN mkdir /data/ && \ # Kitodo.Production Git Builder -FROM maven:3.8.5-openjdk-11 AS kitodo-builder-git +FROM maven:3.8.6-openjdk-11-slim AS kitodo-builder-git RUN apt-get update && \ apt-get install -y \ @@ -42,10 +42,13 @@ RUN apt-get update && \ mariadb-server \ wget -ARG BUILDER_GIT_COMMIT=master -ARG BUILDER_GIT_SOURCE_URL=https://github.com/kitodo/kitodo-production/ +ARG BUILDER_GIT_REF=master +ARG BUILDER_GIT_REPOSITORY=kitodo/kitodo-production +ARG BUILDER_GIT_SERVER_URL=https://github.com +ARG BUILDER_GIT_SOURCE_URL=${BUILDER_GIT_SERVER_URL}/${BUILDER_GIT_REPOSITORY}/ ENV JAVA_OPTS="-Djava.awt.headless=true -XX:+UseConcMarkSweepGC -Xmx2048m -Xms1024m -XX:MaxPermSize=512m" +ENV MAVEN_OPTS="-Xms256m -Xmx512m" COPY wait-for-it.sh /wait-for-it.sh COPY build-git.sh /build.sh @@ -61,33 +64,34 @@ FROM kitodo-builder-${BUILDER_TYPE} AS kitodo-builder # Kitodo.Production -FROM tomcat:9.0.62-jre11-openjdk-slim AS kitodo +FROM tomcat:9.0.65-jre11-openjdk-slim AS kitodo -MAINTAINER markus.weigelt@slub-dresden.de - -ARG GH_REF -ARG GH_REPOSITORY +ARG GIT_REF=master +ARG GIT_REPOSITORY=kitodo/kitodo-production +ARG GIT_SERVER_URL=https://github.com ARG BUILD_DATE LABEL \ maintainer="https://slub-dresden.de" \ org.label-schema.vendor="Saxon State and University Library Dresden" \ org.label-schema.name="Kitodo.Production" \ - org.label-schema.vcs-ref=$GH_REF \ - org.label-schema.vcs-url="https://github.com/${GH_REPOSITORY}/" \ + org.label-schema.vcs-ref=$GIT_REF \ + org.label-schema.vcs-url="${GIT_SERVER_URL}/${GIT_REPOSITORY}/" \ org.label-schema.build-date=$BUILD_DATE \ org.opencontainers.image.vendor="Saxon State and University Library Dresden" \ org.opencontainers.image.title="Kitodo.Production" \ org.opencontainers.image.description="Kitodo.Production is the workflow management module in the Kitodo suite." \ - org.opencontainers.image.source="https://github.com/${GH_REPOSITORY}/" \ - org.opencontainers.image.documentation="https://github.com/${GH_REPOSITORY}/blob/${GH_REF}/README.md" \ - org.opencontainers.image.revision=$GH_REF \ + org.opencontainers.image.source="${GIT_SERVER_URL}/${GIT_REPOSITORY}/" \ + org.opencontainers.image.documentation="${GIT_SERVER_URL}/${GIT_REPOSITORY}/blob/${GIT_REF}/README.md" \ + org.opencontainers.image.revision=$GIT_REF \ org.opencontainers.image.created=$BUILD_DATE ENV JAVA_OPTS="-Djava.awt.headless=true -XX:+UseConcMarkSweepGC -Xmx2048m -Xms1024m -XX:MaxPermSize=512m" ENV JPDA=false ENV JPDA_ADDRESS=*:5005 +ENV APP_FOOTER_INFO="" + ENV DB_HOST=localhost ENV DB_PORT=3306 ENV DB_NAME=kitodo diff --git a/Makefile b/Makefile index a8e5a8e..f762930 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,9 @@ ifndef PROJECT_NAME $(error PROJECT_NAME is not set) endif -BUILDER ?= release -BUILDER_GIT_COMMIT ?= master -BUILDER_GIT_SOURCE_URL ?= https://github.com/kitodo/kitodo-production/ +BUILDER ?= git +BUILDER_GIT_REF ?= master +BUILDER_GIT_REPOSITORY ?= kitodo/kitodo-production ENVFILE = ./projects/${PROJECT_NAME}/.env ifeq (git,$(BUILDER)) @@ -52,8 +52,8 @@ info: $(info PROJECT_NAME is $(PROJECT_NAME)) $(info BUILDER is $(BUILDER)) @if [ "$(BUILDER)" = "git" ]; then\ - echo "BUILDER_GIT_COMMIT is $(BUILDER_GIT_COMMIT)";\ - echo "BUILDER_GIT_SOURCE_URL is $(BUILDER_GIT_SOURCE_URL)";\ + echo "BUILDER_GIT_REF is $(BUILDER_GIT_REF)";\ + echo "BUILDER_GIT_REPOSITORY is $(BUILDER_GIT_REPOSITORY)";\ fi $(info LOGVIEWER is $(LOGVIEWER)) $(info FILEBROWSER is $(FILEBROWSER)) @@ -76,8 +76,8 @@ prepare: ./projects/${PROJECT_NAME}/.env sed -i 's,#APP_DATA,APP_DATA,g' $@ sed -i 's,#APP_CONFIG,APP_CONFIG,g' $@ # Git builder variables - sed -i 's,APP_BUILDER_GIT_COMMIT=master,APP_BUILDER_GIT_COMMIT=$(BUILDER_GIT_COMMIT),g' $@ - sed -i 's,APP_BUILDER_GIT_SOURCE_URL=https://github.com/kitodo/kitodo-production/,APP_BUILDER_GIT_SOURCE_URL=$(BUILDER_GIT_SOURCE_URL),g' $@ + sed -i 's,APP_BUILDER_GIT_REF=master,APP_BUILDER_GIT_REF=$(BUILDER_GIT_REF),g' $@ + sed -i 's,APP_BUILDER_GIT_REPOSITORY=kitodo/kitodo-production,APP_BUILDER_GIT_REPOSITORY=$(BUILDER_GIT_REPOSITORY),g' $@ build: docker compose --env-file ${ENVFILE} build --no-cache @@ -113,8 +113,8 @@ Targets: Variables: - PROJECT_NAME name of project - BUILDER type of builder (e.g. release, git, local) - - BUILDER_GIT_COMMIT branch or commit number (is used when BUILDER=git) - - BUILDER_GIT_SOURCE_URL repository url of BUILDER_GIT_COMMIT (is used when BUILDER=git) + - BUILDER_GIT_REF branch or commit number (is used when BUILDER=git) + - BUILDER_GIT_REPOSITORY repository url of BUILDER_GIT_REF (is used when BUILDER=git) EOF endef export HELP diff --git a/build-git.sh b/build-git.sh index b8be37a..b793b68 100644 --- a/build-git.sh +++ b/build-git.sh @@ -2,37 +2,38 @@ set -e -if [ "x$BUILDER_GIT_COMMIT" = "x" ]; then - if [ "x$BUILDER_GIT_SOURCE_URL" = "x" ]; then - echo "Syntax: docker-compose run kitodo [] []" - echo "Either BUILDER_GIT_COMMIT or BUILDER_GIT_SOURCE_URL must be given." - echo "Use \"master\" for BUILDER_GIT_COMMIT to get the latest commit." - exit 1 +if [ -z "$BUILDER_GIT_REF" ]; then + if [ -z "$BUILDER_GIT_REPOSITORY" ]; then + echo "Syntax: docker-compose run kitodo [] []" + echo "Either BUILDER_GIT_REF or BUILDER_GIT_REPOSITORY must be given." + echo "Use \"master\" for BUILDER_GIT_REF to get the latest commit." + exit 1 fi - BUILDER_GIT_COMMIT="master" + BUILDER_GIT_REF="master" fi -if [ "x$BUILDER_GIT_SOURCE_URL" = "x" ]; then - if [ $BUILDER_GIT_COMMIT = "master" ]; then - BUILDER_GIT_SOURCE_URL="https://github.com/kitodo/kitodo-production/archive/master.zip" +if [ -z "$BUILDER_GIT_REPOSITORY" ]; then + if [ $BUILDER_GIT_REF = "master" ]; then + BUILDER_GIT_SOURCE_URL="https://github.com/kitodo/kitodo-production/archive/master.zip" else - BUILDER_GIT_SOURCE_URL="https://github.com/kitodo/kitodo-production/archive/$BUILDER_GIT_COMMIT.zip" + BUILDER_GIT_SOURCE_URL="https://github.com/kitodo/kitodo-production/archive/$BUILDER_GIT_REF.zip" fi elif [ `echo "$BUILDER_GIT_SOURCE_URL" | rev | cut -c 1-4` != 'piz.' ]; then if [ `echo "$BUILDER_GIT_SOURCE_URL" | rev | cut -c 1-1` != '/' ]; then BUILDER_GIT_SOURCE_URL="${BUILDER_GIT_SOURCE_URL}/" fi - BUILDER_GIT_SOURCE_URL="${BUILDER_GIT_SOURCE_URL}archive/$BUILDER_GIT_COMMIT.zip" + BUILDER_GIT_SOURCE_URL="${BUILDER_GIT_SOURCE_URL}archive/$BUILDER_GIT_REF.zip" fi + echo "Download source files" -echo "using commit $BUILDER_GIT_COMMIT" +echo "using commit $BUILDER_GIT_REF" echo "using $BUILDER_GIT_SOURCE_URL as download location" -curl -L $BUILDER_GIT_SOURCE_URL > checkout.zip -unzip -qq checkout.zip +curl $BUILDER_GIT_SOURCE_URL -L -o checkout.zip +unzip -q checkout.zip DIR=`ls -1 . | grep kitodo-prod` -if [ x$DIR = "x" ]; then +if [ -z "$DIR" ]; then echo "No Kitodo Production directory found in zip" exit 1 fi diff --git a/deploy.sh b/deploy.sh index 4361a5b..92a4706 100644 --- a/deploy.sh +++ b/deploy.sh @@ -40,6 +40,11 @@ echo "Replace activemq config parameters with environment variables" /bin/sed -i "s/#activeMQ.finalizeStep.queue=/activeMQ.finalizeStep.queue=/g" $KITODO_CONFIG /bin/sed -i "s/#activeMQ.taskAction.queue=/activeMQ.taskAction.queue=/g" $KITODO_CONFIG +if [ -n "$APP_FOOTER_INFO" ]; then + echo "Show info in footer" + /bin/sed -i "s|Version #{HelperForm.version}|Version #{HelperForm.version} ($APP_FOOTER_INFO)|" $CATALINA_HOME/webapps/kitodo/WEB-INF/templates/includes/footer.xhtml +fi + if $JPDA; then echo "Starting tomcat in debug mode" /usr/local/tomcat/bin/catalina.sh jpda start diff --git a/docker-compose.yml b/docker-compose.yml index 1d4c4df..d51ccc6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,8 +14,11 @@ services: - ${APP_DATA}:/usr/local/kitodo - ${APP_CONFIG}:/usr/local/tomcat/webapps/kitodo/WEB-INF/classes - type: bind - source: ./overwrites/app + source: ./overwrites/app/data target: /tmp/kitodo/overwrites/data + - type: bind + source: ./overwrites/app/sql/kitodo_post_init.sql + target: /tmp/kitodo/overwrites/sql/post_init.sql - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro diff --git a/overwrites/docker-compose-app-builder-git.yml b/overwrites/docker-compose-app-builder-git.yml index 8e1b5b3..ab8fcae 100644 --- a/overwrites/docker-compose-app-builder-git.yml +++ b/overwrites/docker-compose-app-builder-git.yml @@ -5,5 +5,10 @@ services: build: args: BUILDER_TYPE: git - BUILDER_GIT_COMMIT: ${APP_BUILDER_GIT_COMMIT} - BUILDER_GIT_SOURCE_URL: ${APP_BUILDER_GIT_SOURCE_URL} + BUILDER_GIT_REF: ${APP_BUILDER_GIT_REF} + BUILDER_GIT_REPOSITORY: ${APP_BUILDER_GIT_REPOSITORY} + + environment: + APP_FOOTER_INFO: "Repository: ${APP_BUILDER_GIT_REPOSITORY}, Ref: ${APP_BUILDER_GIT_REF}" + GIT_REF: ${APP_BUILDER_GIT_REF} + GIT_REPOSITORY: ${APP_BUILDER_GIT_REPOSITORY}