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

Improvement Dockerfile #23

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ngrok.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

30 changes: 17 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 17 additions & 16 deletions build-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<BUILDER_GIT_COMMIT>] [<BUILDER_GIT_SOURCE_URL>]"
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 [<BUILDER_GIT_REF>] [<BUILDER_GIT_REPOSITORY>]"
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
Expand Down
5 changes: 5 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ services:
- type: bind
source: ${APP_OVERWRITES_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

Expand Down
9 changes: 7 additions & 2 deletions overwrites/docker-compose-app-builder-git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: <a href=\"https://github.com/${APP_BUILDER_GIT_REPOSITORY}/\">${APP_BUILDER_GIT_REPOSITORY}</a>, Ref: <a href=\"https://github.com/${APP_BUILDER_GIT_REPOSITORY}/tree/${APP_BUILDER_GIT_REF}\">${APP_BUILDER_GIT_REF}</a>"
GIT_REF: ${APP_BUILDER_GIT_REF}
GIT_REPOSITORY: ${APP_BUILDER_GIT_REPOSITORY}