From 7dc1f27badc9b89045a811bc0ce39011379c582d Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Mon, 14 Oct 2024 15:36:36 +0200 Subject: [PATCH 01/52] initial commit of docker and publish workflow --- .github/workflows/publish-docker-image.yml | 53 ++++++ Docker/.env | 13 ++ Docker/Dockerfile | 90 ++++++++++ Docker/README.md | 45 +++++ Docker/apache2-dfg-viewer.conf | 13 ++ Docker/docker-compose.yml | 36 ++++ Docker/startup.sh | 35 ++++ Docker/wait-for-it.sh | 182 +++++++++++++++++++++ 8 files changed, 467 insertions(+) create mode 100644 .github/workflows/publish-docker-image.yml create mode 100644 Docker/.env create mode 100644 Docker/Dockerfile create mode 100644 Docker/README.md create mode 100644 Docker/apache2-dfg-viewer.conf create mode 100644 Docker/docker-compose.yml create mode 100644 Docker/startup.sh create mode 100644 Docker/wait-for-it.sh diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml new file mode 100644 index 00000000..565676cc --- /dev/null +++ b/.github/workflows/publish-docker-image.yml @@ -0,0 +1,53 @@ +name: Publish DFG-Viewer + +on: + workflow_dispatch: # run manually + +env: + IMAGE_TAG: latest + GIT_OWNER: markusweigelt + GIT_REPO: dfg-viewer + GIT_REF: docker + REGISTRY_PATH: ghcr.io/markusweigelt/dfg-viewer + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v4 + + # Activate cache export feature to reduce build time of images + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Determine build args + run: | + date -u +"build_date=%Y-%m-%dT%H:%M:%SZ" >> $GITHUB_ENV + echo "vcs_ref=`git rev-parse --short HEAD`" >> $GITHUB_ENV + + - name: Build the DFG-Viewer image from module and deploy to GitHub Container Repository + uses: docker/build-push-action@v3 + with: + context: ./Docker + push: true + tags: ${{ env.REGISTRY_PATH }}/dfg-viewer:${{ env.IMAGE_TAG }} + build-args: | + BUILD_DATE=${{ env.build_date }} + VCS_REF=${{ env.vcs_ref }} + VCS_URL=https://github.com/${{ env.GIT_OWNER }}/${{ env.GIT_REPO }}/tree/${{ env.GIT_REF }}/ + BUILDER_TYPE=git + BUILDER_GIT_COMMIT=${{ env.GIT_REF }} + BUILDER_GIT_SOURCE_URL=https://github.com/${{ env.GIT_OWNER }}/${{ env.GIT_REPO }}/ + cache-from: type=gha,scope=${{ env.vcs_ref }}-image + cache-to: type=gha,mode=max,scope=${{ env.vcs_ref }}-image diff --git a/Docker/.env b/Docker/.env new file mode 100644 index 00000000..6812a12f --- /dev/null +++ b/Docker/.env @@ -0,0 +1,13 @@ +# application image +APP_IMAGE=ghcr.io/slub/dfg-viewer/dfg-viewer:latest +APP_PORT=80 +APP_T3_USER=admin +APP_T3_PASSWORD=adminslub + +# database image +DB_IMAGE=mysql:8.0 +DB_PORT=3306 +DB_HOST=dfg-viewer-db +DB_NAME=typo3 +DB_USER=typo3 +DB_PASSWORD=password \ No newline at end of file diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 00000000..0922f7da --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,90 @@ +FROM php:8.2-apache-bookworm + +LABEL \ + maintainer="https://slub-dresden.de" \ + org.label-schema.vendor="Saxon State and University Library Dresden" \ + org.label-schema.name="DFG-Viewer" \ + 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="DFG-Viewer" \ + org.opencontainers.image.description="The DFG Viewer is a free web service for browsing digitized books from remote library repositories in a rich and dynamic environment." \ + 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 + +# We use this pre-installation of Martin Helmich https://github.com/martin-helmich/docker-typo3 to set up all the necessary system components. +# TYPO3 is installed manually by Martin Helmich, but we prefer an Composer-based setup. +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y --no-install-recommends \ + wget \ +# Configure PHP + libxml2-dev libfreetype6-dev \ + libjpeg62-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + libpq-dev \ + libzip-dev \ + zlib1g-dev \ +# Install required 3rd party tools + graphicsmagick && \ +# Configure extensions + docker-php-ext-configure gd --with-libdir=/usr/include/ --with-jpeg --with-freetype && \ + docker-php-ext-install -j$(nproc) mysqli soap gd zip opcache intl pgsql pdo_pgsql && \ + echo 'always_populate_raw_post_data = -1\nmax_execution_time = 240\nmax_input_vars = 1500\nupload_max_filesize = 32M\npost_max_size = 32M' > /usr/local/etc/php/conf.d/typo3.ini && \ +# Configure Apache as needed + a2enmod rewrite && \ + apt-get clean && \ + apt-get -y purge \ + libxml2-dev libfreetype6-dev \ + libjpeg62-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + libzip-dev \ + zlib1g-dev && \ + rm -rf /var/lib/apt/lists/* /usr/src/* + +# Install Composer +RUN curl -sS https://getcomposer.org/installer \ + | php -- --install-dir=/usr/bin --filename=composer + +# Install TYPO3 +RUN cd /var/www/html && \ + composer create-project typo3/cms-base-distribution dfg-viewer "^11" && \ + cp ./dfg-viewer/public/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess ./dfg-viewer/public/.htaccess && \ + touch ./dfg-viewer/public/FIRST_INSTALL && \ + chown -R www-data:www-data ./dfg-viewer + +WORKDIR /var/www/html/dfg-viewer + +# Configure Apache +COPY apache2-dfg-viewer.conf /etc/apache2/sites-available/dfg-viewer.conf +RUN a2ensite dfg-viewer.conf && \ +# Disable default behaviour + a2dissite 000-default.conf + +# Install extension path +RUN mkdir -p /var/www/extensions/ && \ + composer config repositories.local path /var/www/extensions/* + +COPY extensions /var/www/extensions + +# Install scripts +COPY startup.sh /usr/bin/ +COPY wait-for-it.sh /wait-for-it.sh + +ENV DB_HOST=localhost +ENV DB_PORT=3306 +ENV DB_NAME=typo3 +ENV DB_USER=typo3 +ENV DB_PASSWORD=password +ENV T3_USER=admin +ENV T3_PASSWORD=adminslub + +RUN chmod +x /usr/bin/startup.sh && \ + chmod +x /wait-for-it.sh + +CMD ["/usr/bin/startup.sh"] \ No newline at end of file diff --git a/Docker/README.md b/Docker/README.md new file mode 100644 index 00000000..d868ba27 --- /dev/null +++ b/Docker/README.md @@ -0,0 +1,45 @@ + +# DFG-Viewer Docker + + * [Prerequisites](#prerequisites) + * [Quickstart](#quickstart) + * [Services](#services) + +The Kitodo.Production can be started quickly with the provided Docker image. However, a MySQL/MariaDB database and ElasticSearch are required to start the application. Additionally, a Docker Compose file is available for a faster setup. + +## Prerequisites + +Install Docker Engine +https://docs.docker.com/get-docker/ + +Install Docker Compose +https://docs.docker.com/compose/install/ + +## Quickstart + +Go to the directory where you've put `docker-compose.yml`. + +Copy the environment file `.env.example` inside the directory and rename it to `.env`. + +Download images and start all service containers +``` +docker compose up -d --build +``` + +Stops all service containers +``` +docker compose stop +``` + +Stops and remove all service containers +``` +docker compose down +``` + +## Services + +When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container. + +### Environment file + +To configure our services copy the environment file `.env.example` inside the directory and rename it to `.env`. Adjust the configuration of the respective service to suit your needs. The variables are marked with the prefix of the service e.g. `APP_` for our Typo3 application with DFG-Viewer. \ No newline at end of file diff --git a/Docker/apache2-dfg-viewer.conf b/Docker/apache2-dfg-viewer.conf new file mode 100644 index 00000000..2e32f93d --- /dev/null +++ b/Docker/apache2-dfg-viewer.conf @@ -0,0 +1,13 @@ + + DocumentRoot /var/www/html/dfg-viewer/public + + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + + ErrorLog /var/log/apache2/dfg-viewer-error.log + CustomLog /var/log/apache2/dfg-viewer-access.log combined + \ No newline at end of file diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml new file mode 100644 index 00000000..c3694154 --- /dev/null +++ b/Docker/docker-compose.yml @@ -0,0 +1,36 @@ +services: + + dfg-viewer-app: + image: ${APP_IMAGE} + build: + no_cache: true + environment: + DB_HOST: ${DB_HOST} + T3_USER: ${APP_T3_USER} + T3_PASSWORD: ${APP_T3_PASSWORD} + ports: + - ${APP_PORT}:80 + networks: + - backend + + dfg-viewer-db: + image: ${DB_IMAGE} + command: + - --character-set-server=utf8 + - --collation-server=utf8_unicode_ci + environment: + MYSQL_USER: ${DB_USER} + MYSQL_PASSWORD: ${DB_PASSWORD} + MYSQL_DATABASE: ${DB_NAME} + MYSQL_RANDOM_ROOT_PASSWORD: yes + ports: + - ${DB_PORT}:3306 + networks: + - backend +volumes: + database: + fileadmin: + typo3conf: + uploads: +networks: + backend: diff --git a/Docker/startup.sh b/Docker/startup.sh new file mode 100644 index 00000000..09ade77d --- /dev/null +++ b/Docker/startup.sh @@ -0,0 +1,35 @@ +#!/bin/bash + + +echo "Wait for database container." +/wait-for-it.sh -t 0 $DB_HOST:$DB_PORT + +# run only once +if ! test -f "public/typo3conf/LocalConfiguration.php"; then + # Remove next line when Kitodo.Presentation 6 is released and DFG-Viewer supports this version + # composer require --dev kitodo/presentation:dev-master + + # Install extensions from mounted extension folder + composer req kitodo/presentation:@dev + composer req slub/slub-digitalcollections:@dev + composer req slub/dfgviewer:@dev + + ./vendor/bin/typo3cms install:setup --no-interaction \ + --database-user-name="$DB_USER" \ + --database-user-password="$DB_PASSWORD" \ + --database-host-name="$DB_HOST" \ + --database-port="$DB_PORT" \ + --database-name="$DB_NAME" \ + --admin-user-name="$T3_NAME" \ + --admin-password="$T3_PASSWORD" \ + --site-name="DFG-Viewer" \ + --use-existing-database + ./vendor/bin/typo3cms configuration:set 'EXTENSIONS/dlf/fileGrpAudio' 'AUDIO' + ./vendor/bin/typo3cms configuration:set 'EXTENSIONS/dlf/fileGrpVideo' 'VIDEO,DEFAULT' + ./vendor/bin/typo3cms configuration:set --json 'FE/cacheHash/requireCacheHashPresenceParameters' '["tx_dlf[id]"]' + ./vendor/bin/typo3cms configuration:set 'FE/pageNotFoundOnCHashError' 0 && \ + ./vendor/bin/typo3cms configuration:set 'EXTCONF/lang/availableLanguages' '["de"]' --json + ./vendor/bin/typo3cms language:update +fi + +exec apache2-foreground \ No newline at end of file diff --git a/Docker/wait-for-it.sh b/Docker/wait-for-it.sh new file mode 100644 index 00000000..d990e0d3 --- /dev/null +++ b/Docker/wait-for-it.sh @@ -0,0 +1,182 @@ +#!/usr/bin/env bash +# Use this script to test if a given TCP host/port are available + +WAITFORIT_cmdname=${0##*/} + +echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + else + echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" + fi + WAITFORIT_start_ts=$(date +%s) + while : + do + if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then + nc -z $WAITFORIT_HOST $WAITFORIT_PORT + WAITFORIT_result=$? + else + (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 + WAITFORIT_result=$? + fi + if [[ $WAITFORIT_result -eq 0 ]]; then + WAITFORIT_end_ts=$(date +%s) + echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" + break + fi + sleep 1 + done + return $WAITFORIT_result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $WAITFORIT_QUIET -eq 1 ]]; then + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + else + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + fi + WAITFORIT_PID=$! + trap "kill -INT -$WAITFORIT_PID" INT + wait $WAITFORIT_PID + WAITFORIT_RESULT=$? + if [[ $WAITFORIT_RESULT -ne 0 ]]; then + echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + fi + return $WAITFORIT_RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + WAITFORIT_hostport=(${1//:/ }) + WAITFORIT_HOST=${WAITFORIT_hostport[0]} + WAITFORIT_PORT=${WAITFORIT_hostport[1]} + shift 1 + ;; + --child) + WAITFORIT_CHILD=1 + shift 1 + ;; + -q | --quiet) + WAITFORIT_QUIET=1 + shift 1 + ;; + -s | --strict) + WAITFORIT_STRICT=1 + shift 1 + ;; + -h) + WAITFORIT_HOST="$2" + if [[ $WAITFORIT_HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + WAITFORIT_HOST="${1#*=}" + shift 1 + ;; + -p) + WAITFORIT_PORT="$2" + if [[ $WAITFORIT_PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + WAITFORIT_PORT="${1#*=}" + shift 1 + ;; + -t) + WAITFORIT_TIMEOUT="$2" + if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + WAITFORIT_TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + WAITFORIT_CLI=("$@") + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} +WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} +WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} +WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} + +# Check to see if timeout is from busybox? +WAITFORIT_TIMEOUT_PATH=$(type -p timeout) +WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) + +WAITFORIT_BUSYTIMEFLAG="" +if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then + WAITFORIT_ISBUSY=1 + # Check if busybox timeout uses -t flag + # (recent Alpine versions don't support -t anymore) + if timeout &>/dev/stdout | grep -q -e '-t '; then + WAITFORIT_BUSYTIMEFLAG="-t" + fi +else + WAITFORIT_ISBUSY=0 +fi + +if [[ $WAITFORIT_CHILD -gt 0 ]]; then + wait_for + WAITFORIT_RESULT=$? + exit $WAITFORIT_RESULT +else + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + wait_for_wrapper + WAITFORIT_RESULT=$? + else + wait_for + WAITFORIT_RESULT=$? + fi +fi + +if [[ $WAITFORIT_CLI != "" ]]; then + if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then + echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" + exit $WAITFORIT_RESULT + fi + exec "${WAITFORIT_CLI[@]}" +else + exit $WAITFORIT_RESULT +fi From c50980e083ba5a624e641810a70e47ff987f1949 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Mon, 14 Oct 2024 16:09:46 +0200 Subject: [PATCH 02/52] Add extension repositories to workflow --- .github/workflows/publish-docker-image.yml | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 565676cc..540df11b 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -17,9 +17,30 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository and submodules + - name: Checkout repository uses: actions/checkout@v4 + - name: Checkout DFG-Viewer repository + uses: actions/checkout@v4 + with: + repository: ${{ env.GIT_OWNER }}/${{ env.GIT_REPO }} + ref: ${{ env.GIT_REF }} + path: ./Docker/extensions/dfg-viewer + + - name: Checkout Kitodo.Presentation repository + uses: actions/checkout@v4 + with: + repository: ${{ env.GIT_OWNER }}/kitodo-presentation + ref: fix-get-document-type + path: ./Docker/extensions/kitodo-presentation + + - name: Checkout SLUB Digital Collections repository + uses: actions/checkout@v4 + with: + repository: ${{ env.GIT_OWNER }}/slub_digitalcollections + ref: dev-main + path: ./Docker/extensions/slub_digitalcollections + # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From d6db50309e501baede3032abb1cc68a6ed64d319 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Mon, 14 Oct 2024 16:29:27 +0200 Subject: [PATCH 03/52] Update workflow and env --- Docker/.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docker/.env b/Docker/.env index 6812a12f..cb096b15 100644 --- a/Docker/.env +++ b/Docker/.env @@ -1,5 +1,5 @@ # application image -APP_IMAGE=ghcr.io/slub/dfg-viewer/dfg-viewer:latest +APP_IMAGE=ghcr.io/markusweigelt/dfg-viewer/dfg-viewer:latest APP_PORT=80 APP_T3_USER=admin APP_T3_PASSWORD=adminslub @@ -10,4 +10,4 @@ DB_PORT=3306 DB_HOST=dfg-viewer-db DB_NAME=typo3 DB_USER=typo3 -DB_PASSWORD=password \ No newline at end of file +DB_PASSWORD=password From ab6bc344e948e4bd7a12141fcaed1305132de3e7 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Mon, 14 Oct 2024 17:24:09 +0200 Subject: [PATCH 04/52] Use dev-main branch for docker-image --- .github/workflows/publish-docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 540df11b..4d056fd1 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v4 with: repository: ${{ env.GIT_OWNER }}/${{ env.GIT_REPO }} - ref: ${{ env.GIT_REF }} + ref: dev-main path: ./Docker/extensions/dfg-viewer - name: Checkout Kitodo.Presentation repository @@ -58,7 +58,7 @@ jobs: echo "vcs_ref=`git rev-parse --short HEAD`" >> $GITHUB_ENV - name: Build the DFG-Viewer image from module and deploy to GitHub Container Repository - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: ./Docker push: true From 633630a4e9f23f2b4642f158af0a3b0b16301c2d Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Mon, 14 Oct 2024 17:44:28 +0200 Subject: [PATCH 05/52] Add sites configuration --- Docker/Dockerfile | 15 ++++++++------ Docker/docker-compose.yml | 2 +- Docker/sites/dfgviewer/config.yaml | 32 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 Docker/sites/dfgviewer/config.yaml diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 0922f7da..57e125cc 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -58,13 +58,13 @@ RUN cd /var/www/html && \ touch ./dfg-viewer/public/FIRST_INSTALL && \ chown -R www-data:www-data ./dfg-viewer -WORKDIR /var/www/html/dfg-viewer +WORKDIR /var/www/html/dfg-viewer -# Configure Apache +# Configure Apache COPY apache2-dfg-viewer.conf /etc/apache2/sites-available/dfg-viewer.conf RUN a2ensite dfg-viewer.conf && \ # Disable default behaviour - a2dissite 000-default.conf + a2dissite 000-default.conf # Install extension path RUN mkdir -p /var/www/extensions/ && \ @@ -72,7 +72,10 @@ RUN mkdir -p /var/www/extensions/ && \ COPY extensions /var/www/extensions -# Install scripts +# Sites configuration +COPY sites/dfgviewer/config.yaml ./sites/dfgviewer/config.yaml + +# Install scripts COPY startup.sh /usr/bin/ COPY wait-for-it.sh /wait-for-it.sh @@ -81,10 +84,10 @@ ENV DB_PORT=3306 ENV DB_NAME=typo3 ENV DB_USER=typo3 ENV DB_PASSWORD=password -ENV T3_USER=admin +ENV T3_USER=admin ENV T3_PASSWORD=adminslub RUN chmod +x /usr/bin/startup.sh && \ chmod +x /wait-for-it.sh -CMD ["/usr/bin/startup.sh"] \ No newline at end of file +CMD ["/usr/bin/startup.sh"] diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index c3694154..55805876 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -11,7 +11,7 @@ services: ports: - ${APP_PORT}:80 networks: - - backend + - backend dfg-viewer-db: image: ${DB_IMAGE} diff --git a/Docker/sites/dfgviewer/config.yaml b/Docker/sites/dfgviewer/config.yaml new file mode 100644 index 00000000..035f7ab7 --- /dev/null +++ b/Docker/sites/dfgviewer/config.yaml @@ -0,0 +1,32 @@ +base: '/' +baseVariants: { } +errorHandling: { } +languages: + - + title: Deutsch + enabled: true + base: / + typo3Language: de + locale: de_DE.UTF-8 + iso-639-1: de + navigationTitle: German + hreflang: de-DE + direction: ltr + flag: de + languageId: '0' + - + title: Englisch + enabled: true + base: /en/ + typo3Language: default + locale: en_US.UTF-8 + iso-639-1: en + navigationTitle: English + hreflang: en-US + direction: ltr + fallbackType: strict + fallbacks: '0' + flag: gb + languageId: '1' +rootPageId: 1 +routes: { } From 0d516ac07293c2e7b7753491ae13d2573f09602d Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Mon, 14 Oct 2024 17:53:52 +0200 Subject: [PATCH 06/52] Update site configuration --- Docker/Dockerfile | 2 +- Docker/{sites => site}/dfgviewer/config.yaml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Docker/{sites => site}/dfgviewer/config.yaml (100%) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 57e125cc..6214ebc9 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -73,7 +73,7 @@ RUN mkdir -p /var/www/extensions/ && \ COPY extensions /var/www/extensions # Sites configuration -COPY sites/dfgviewer/config.yaml ./sites/dfgviewer/config.yaml +COPY site/dfgviewer/config.yaml ./site/dfgviewer/config.yaml # Install scripts COPY startup.sh /usr/bin/ diff --git a/Docker/sites/dfgviewer/config.yaml b/Docker/site/dfgviewer/config.yaml similarity index 100% rename from Docker/sites/dfgviewer/config.yaml rename to Docker/site/dfgviewer/config.yaml From 5c561568b799cd7ec661488f22ac173477a0d969 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Mon, 14 Oct 2024 18:08:40 +0200 Subject: [PATCH 07/52] Improve site configuration --- Docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 6214ebc9..99350ab1 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -73,7 +73,7 @@ RUN mkdir -p /var/www/extensions/ && \ COPY extensions /var/www/extensions # Sites configuration -COPY site/dfgviewer/config.yaml ./site/dfgviewer/config.yaml +COPY site/dfgviewer/config.yaml ./config/sites/dfgviewer/config.yaml # Install scripts COPY startup.sh /usr/bin/ From 19db23efc9a215c2507d271b7354bb4704da31a1 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 15 Oct 2024 12:32:49 +0200 Subject: [PATCH 08/52] Rename workflow and change image name --- .github/workflows/{publish-docker-image.yml => publish.yml} | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) rename .github/workflows/{publish-docker-image.yml => publish.yml} (89%) diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish.yml similarity index 89% rename from .github/workflows/publish-docker-image.yml rename to .github/workflows/publish.yml index 4d056fd1..ae67ff29 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish.yml @@ -62,13 +62,10 @@ jobs: with: context: ./Docker push: true - tags: ${{ env.REGISTRY_PATH }}/dfg-viewer:${{ env.IMAGE_TAG }} + tags: ${{ env.REGISTRY_PATH }}:${{ env.IMAGE_TAG }} build-args: | BUILD_DATE=${{ env.build_date }} VCS_REF=${{ env.vcs_ref }} VCS_URL=https://github.com/${{ env.GIT_OWNER }}/${{ env.GIT_REPO }}/tree/${{ env.GIT_REF }}/ - BUILDER_TYPE=git - BUILDER_GIT_COMMIT=${{ env.GIT_REF }} - BUILDER_GIT_SOURCE_URL=https://github.com/${{ env.GIT_OWNER }}/${{ env.GIT_REPO }}/ cache-from: type=gha,scope=${{ env.vcs_ref }}-image cache-to: type=gha,mode=max,scope=${{ env.vcs_ref }}-image From f4e418b21550b46ffae297e400e7eb6ce3e1baa3 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Thu, 7 Nov 2024 18:14:24 +0100 Subject: [PATCH 09/52] Update to TYPO3 12 --- Docker/.env | 4 ++-- Docker/Dockerfile | 12 ++++++++---- Docker/startup.sh | 34 +++++++++++++++++----------------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Docker/.env b/Docker/.env index cb096b15..179a9fe2 100644 --- a/Docker/.env +++ b/Docker/.env @@ -1,8 +1,8 @@ # application image -APP_IMAGE=ghcr.io/markusweigelt/dfg-viewer/dfg-viewer:latest +APP_IMAGE=ghcr.io/markusweigelt/dfg-viewer:latest APP_PORT=80 APP_T3_USER=admin -APP_T3_PASSWORD=adminslub +APP_T3_PASSWORD="dvAdmin.1" # database image DB_IMAGE=mysql:8.0 diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 99350ab1..91fd3156 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -53,8 +53,8 @@ RUN curl -sS https://getcomposer.org/installer \ # Install TYPO3 RUN cd /var/www/html && \ - composer create-project typo3/cms-base-distribution dfg-viewer "^11" && \ - cp ./dfg-viewer/public/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess ./dfg-viewer/public/.htaccess && \ + composer create-project typo3/cms-base-distribution dfg-viewer "^12" && \ + # cp ./dfg-viewer/public/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess ./dfg-viewer/public/.htaccess && \ touch ./dfg-viewer/public/FIRST_INSTALL && \ chown -R www-data:www-data ./dfg-viewer @@ -73,7 +73,7 @@ RUN mkdir -p /var/www/extensions/ && \ COPY extensions /var/www/extensions # Sites configuration -COPY site/dfgviewer/config.yaml ./config/sites/dfgviewer/config.yaml +COPY --chown=www-data site/dfgviewer/config.yaml ./config/sites/dfgviewer/config.yaml # Install scripts COPY startup.sh /usr/bin/ @@ -88,6 +88,10 @@ ENV T3_USER=admin ENV T3_PASSWORD=adminslub RUN chmod +x /usr/bin/startup.sh && \ - chmod +x /wait-for-it.sh + chmod +x /wait-for-it.sh && \ + # make /var/www writable for composer + chown www-data:www-data /var/www + +USER www-data CMD ["/usr/bin/startup.sh"] diff --git a/Docker/startup.sh b/Docker/startup.sh index 09ade77d..f0b1a5aa 100644 --- a/Docker/startup.sh +++ b/Docker/startup.sh @@ -1,20 +1,21 @@ #!/bin/bash - -echo "Wait for database container." +echo "Waiting for database container." /wait-for-it.sh -t 0 $DB_HOST:$DB_PORT # run only once -if ! test -f "public/typo3conf/LocalConfiguration.php"; then - # Remove next line when Kitodo.Presentation 6 is released and DFG-Viewer supports this version - # composer require --dev kitodo/presentation:dev-master +if ! test -f "config/system/settings.php"; then + # Install common extension + composer req helhum/typo3-console "^8.2" # Install extensions from mounted extension folder - composer req kitodo/presentation:@dev - composer req slub/slub-digitalcollections:@dev - composer req slub/dfgviewer:@dev + composer req kitodo/presentation "@dev" + composer req slub/slub-digitalcollections "@dev" + composer req slub/dfgviewer "@dev" + + ./vendor/bin/typo3 install:fixfolderstructure - ./vendor/bin/typo3cms install:setup --no-interaction \ + ./vendor/bin/typo3 install:setup --no-interaction \ --database-user-name="$DB_USER" \ --database-user-password="$DB_PASSWORD" \ --database-host-name="$DB_HOST" \ @@ -23,13 +24,12 @@ if ! test -f "public/typo3conf/LocalConfiguration.php"; then --admin-user-name="$T3_NAME" \ --admin-password="$T3_PASSWORD" \ --site-name="DFG-Viewer" \ - --use-existing-database - ./vendor/bin/typo3cms configuration:set 'EXTENSIONS/dlf/fileGrpAudio' 'AUDIO' - ./vendor/bin/typo3cms configuration:set 'EXTENSIONS/dlf/fileGrpVideo' 'VIDEO,DEFAULT' - ./vendor/bin/typo3cms configuration:set --json 'FE/cacheHash/requireCacheHashPresenceParameters' '["tx_dlf[id]"]' - ./vendor/bin/typo3cms configuration:set 'FE/pageNotFoundOnCHashError' 0 && \ - ./vendor/bin/typo3cms configuration:set 'EXTCONF/lang/availableLanguages' '["de"]' --json - ./vendor/bin/typo3cms language:update + --use-existing-database \ + --web-server-config="apache" + ./vendor/bin/typo3 configuration:set 'EXTENSIONS/dlf/fileGrpAudio' 'AUDIO' + ./vendor/bin/typo3 configuration:set 'EXTENSIONS/dlf/fileGrpVideo' 'VIDEO,DEFAULT' + ./vendor/bin/typo3 configuration:set --json 'FE/cacheHash/requireCacheHashPresenceParameters' '["tx_dlf[id]"]' + ./vendor/bin/typo3 configuration:set 'FE/pageNotFoundOnCHashError' 0 fi -exec apache2-foreground \ No newline at end of file +exec apache2-foreground From 819a9a9b2e06e1075fe0064e691948bb4a2ab3ca Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Thu, 7 Nov 2024 18:26:33 +0100 Subject: [PATCH 10/52] Update php version --- Docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 91fd3156..6018884d 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.2-apache-bookworm +FROM php:8.3-apache-bookworm LABEL \ maintainer="https://slub-dresden.de" \ From 81c27430cf1e6272b981983c9b107f1908933feb Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Thu, 7 Nov 2024 18:33:21 +0100 Subject: [PATCH 11/52] Update publish workflow --- .github/workflows/publish.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae67ff29..32760238 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,7 +13,6 @@ env: jobs: build: - runs-on: ubuntu-latest steps: @@ -24,21 +23,20 @@ jobs: uses: actions/checkout@v4 with: repository: ${{ env.GIT_OWNER }}/${{ env.GIT_REPO }} - ref: dev-main + ref: update-typo12 path: ./Docker/extensions/dfg-viewer - name: Checkout Kitodo.Presentation repository uses: actions/checkout@v4 with: - repository: ${{ env.GIT_OWNER }}/kitodo-presentation - ref: fix-get-document-type + repository: kitodo/kitodo-presentation path: ./Docker/extensions/kitodo-presentation - name: Checkout SLUB Digital Collections repository uses: actions/checkout@v4 with: repository: ${{ env.GIT_OWNER }}/slub_digitalcollections - ref: dev-main + ref: update-typo12 path: ./Docker/extensions/slub_digitalcollections # Activate cache export feature to reduce build time of images From 8c33bdc5ef0e437cc28ff49d9e5df3463dfadcaf Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Fri, 8 Nov 2024 11:52:35 +0100 Subject: [PATCH 12/52] Updates regarding building docker image --- Docker/.env.example | 13 ++++ Docker/README.md | 62 ++++++++++++++++--- Docker/{ => build}/Dockerfile | 2 +- Docker/{ => build}/apache2-dfg-viewer.conf | 0 Docker/build/extensions/.gitkeep | 0 Docker/{ => build}/site/dfgviewer/config.yaml | 0 Docker/{ => build}/startup.sh | 2 +- Docker/{ => build}/wait-for-it.sh | 0 Docker/docker-compose.yml | 3 +- 9 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 Docker/.env.example rename Docker/{ => build}/Dockerfile (99%) rename Docker/{ => build}/apache2-dfg-viewer.conf (100%) create mode 100644 Docker/build/extensions/.gitkeep rename Docker/{ => build}/site/dfgviewer/config.yaml (100%) rename Docker/{ => build}/startup.sh (100%) rename Docker/{ => build}/wait-for-it.sh (100%) diff --git a/Docker/.env.example b/Docker/.env.example new file mode 100644 index 00000000..179a9fe2 --- /dev/null +++ b/Docker/.env.example @@ -0,0 +1,13 @@ +# application image +APP_IMAGE=ghcr.io/markusweigelt/dfg-viewer:latest +APP_PORT=80 +APP_T3_USER=admin +APP_T3_PASSWORD="dvAdmin.1" + +# database image +DB_IMAGE=mysql:8.0 +DB_PORT=3306 +DB_HOST=dfg-viewer-db +DB_NAME=typo3 +DB_USER=typo3 +DB_PASSWORD=password diff --git a/Docker/README.md b/Docker/README.md index d868ba27..3bbe2996 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -1,9 +1,8 @@ - # DFG-Viewer Docker * [Prerequisites](#prerequisites) - * [Quickstart](#quickstart) - * [Services](#services) + * [Usage](#usage) + * [Development](#development) The Kitodo.Production can be started quickly with the provided Docker image. However, a MySQL/MariaDB database and ElasticSearch are required to start the application. Additionally, a Docker Compose file is available for a faster setup. @@ -15,17 +14,19 @@ https://docs.docker.com/get-docker/ Install Docker Compose https://docs.docker.com/compose/install/ -## Quickstart +## Usage Go to the directory where you've put `docker-compose.yml`. -Copy the environment file `.env.example` inside the directory and rename it to `.env`. +Copy the environment file `.env.example` inside the directory and rename it to `.env`. Adjust the configuration of the respective service to suit your needs. The variables are marked with the prefix of the service e.g. `APP_` for our Typo3 application with DFG-Viewer. Download images and start all service containers ``` -docker compose up -d --build +docker compose up -d ``` +*When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container.* + Stops all service containers ``` docker compose stop @@ -36,10 +37,51 @@ Stops and remove all service containers docker compose down ``` -## Services +## Development + +To build the image, a folder named `extensions` must be added under folder `build`. + +``` +mkdir -p build/extensions +``` + +Then, the three extension repositories, [DFG Viewer](https://github.com/slub/dfg-viewer), [Kitodo.Presentation](https://github.com/kitodo/kitodo-presentation), [SLUB Digital Collections](https://github.com/slub/slub_digitalcollections), must be cloned into this folder. + +``` +git clone https://github.com/slub/dfg-viewer build/extensions +git clone https://github.com/kitodo/kitodo-presentation build/extensions +git clone https://github.com/slub/slub_digitalcollections build/extensions +``` + +Adjust the `composer.json` files of the checkouts as follows. + + +`composer.json` of the [DFG Viewer](https://github.com/slub/dfg-viewer) checkout `build/extensions/dfg-viewer`: + +``` + ... + "require": { + ... + "kitodo/presentation": "@dev" + ... + }, + ... +``` + +`composer.json` of the [SLUB Digital Collections](https://github.com/slub/slub_digitalcollections) checkout `build/extensions/slub_digitalcollections`: + +``` + ... + "require": { + ... + "kitodo/presentation": "@dev" + ... + }, + ... +``` -When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container. +Build the image. -### Environment file +*Ensure that the .env file has been created. It is recommended to adjust the `APP_IMAGE` name for custom images.* -To configure our services copy the environment file `.env.example` inside the directory and rename it to `.env`. Adjust the configuration of the respective service to suit your needs. The variables are marked with the prefix of the service e.g. `APP_` for our Typo3 application with DFG-Viewer. \ No newline at end of file +`docker compose build dfg-viewer-app` diff --git a/Docker/Dockerfile b/Docker/build/Dockerfile similarity index 99% rename from Docker/Dockerfile rename to Docker/build/Dockerfile index 6018884d..aeb7bc74 100644 --- a/Docker/Dockerfile +++ b/Docker/build/Dockerfile @@ -85,7 +85,7 @@ ENV DB_NAME=typo3 ENV DB_USER=typo3 ENV DB_PASSWORD=password ENV T3_USER=admin -ENV T3_PASSWORD=adminslub +ENV T3_PASSWORD="dvAdmin.1" RUN chmod +x /usr/bin/startup.sh && \ chmod +x /wait-for-it.sh && \ diff --git a/Docker/apache2-dfg-viewer.conf b/Docker/build/apache2-dfg-viewer.conf similarity index 100% rename from Docker/apache2-dfg-viewer.conf rename to Docker/build/apache2-dfg-viewer.conf diff --git a/Docker/build/extensions/.gitkeep b/Docker/build/extensions/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Docker/site/dfgviewer/config.yaml b/Docker/build/site/dfgviewer/config.yaml similarity index 100% rename from Docker/site/dfgviewer/config.yaml rename to Docker/build/site/dfgviewer/config.yaml diff --git a/Docker/startup.sh b/Docker/build/startup.sh similarity index 100% rename from Docker/startup.sh rename to Docker/build/startup.sh index f0b1a5aa..b2bc5cb6 100644 --- a/Docker/startup.sh +++ b/Docker/build/startup.sh @@ -9,9 +9,9 @@ if ! test -f "config/system/settings.php"; then composer req helhum/typo3-console "^8.2" # Install extensions from mounted extension folder + composer req slub/dfgviewer "@dev" composer req kitodo/presentation "@dev" composer req slub/slub-digitalcollections "@dev" - composer req slub/dfgviewer "@dev" ./vendor/bin/typo3 install:fixfolderstructure diff --git a/Docker/wait-for-it.sh b/Docker/build/wait-for-it.sh similarity index 100% rename from Docker/wait-for-it.sh rename to Docker/build/wait-for-it.sh diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index 55805876..e9f5cb63 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -1,9 +1,8 @@ services: - dfg-viewer-app: image: ${APP_IMAGE} build: - no_cache: true + context: build environment: DB_HOST: ${DB_HOST} T3_USER: ${APP_T3_USER} From cc8d0404bd9f4f5982f31bebfef6169770c86e49 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Fri, 8 Nov 2024 11:57:19 +0100 Subject: [PATCH 13/52] Improvements --- Docker/.env | 13 ------------- Docker/build/apache2-dfg-viewer.conf | 2 +- Docker/docker-compose.yml | 5 ----- 3 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 Docker/.env diff --git a/Docker/.env b/Docker/.env deleted file mode 100644 index 179a9fe2..00000000 --- a/Docker/.env +++ /dev/null @@ -1,13 +0,0 @@ -# application image -APP_IMAGE=ghcr.io/markusweigelt/dfg-viewer:latest -APP_PORT=80 -APP_T3_USER=admin -APP_T3_PASSWORD="dvAdmin.1" - -# database image -DB_IMAGE=mysql:8.0 -DB_PORT=3306 -DB_HOST=dfg-viewer-db -DB_NAME=typo3 -DB_USER=typo3 -DB_PASSWORD=password diff --git a/Docker/build/apache2-dfg-viewer.conf b/Docker/build/apache2-dfg-viewer.conf index 2e32f93d..e4d8c33b 100644 --- a/Docker/build/apache2-dfg-viewer.conf +++ b/Docker/build/apache2-dfg-viewer.conf @@ -10,4 +10,4 @@ ErrorLog /var/log/apache2/dfg-viewer-error.log CustomLog /var/log/apache2/dfg-viewer-access.log combined - \ No newline at end of file + diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index e9f5cb63..db5af375 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -26,10 +26,5 @@ services: - ${DB_PORT}:3306 networks: - backend -volumes: - database: - fileadmin: - typo3conf: - uploads: networks: backend: From 205e74fd9010de5871aa27d1ce519f290785ce87 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Fri, 8 Nov 2024 12:08:49 +0100 Subject: [PATCH 14/52] Add missing build args, ignore .env --- Docker/build/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index aeb7bc74..cd6eb6b1 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -1,5 +1,10 @@ FROM php:8.3-apache-bookworm +ARG GIT_REF=master +ARG GIT_REPOSITORY=slub/dfg-viewer +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" \ From a7890f63110e9edac7aad97f1fffea2d76eb9d01 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 09:24:15 +0100 Subject: [PATCH 15/52] Update workflow and gitignore --- .github/workflows/publish.yml | 22 +++++++++++++++------- .gitignore | 3 +++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 32760238..efd1c57a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,8 @@ name: Publish DFG-Viewer on: + push: + branches: [ "master" ] workflow_dispatch: # run manually env: @@ -19,25 +21,31 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Checkout DFG-Viewer repository uses: actions/checkout@v4 with: - repository: ${{ env.GIT_OWNER }}/${{ env.GIT_REPO }} + repository: markusweigelt/dfg-viewer ref: update-typo12 - path: ./Docker/extensions/dfg-viewer + path: ./Docker/build/extensions/dfg-viewer - name: Checkout Kitodo.Presentation repository uses: actions/checkout@v4 with: repository: kitodo/kitodo-presentation - path: ./Docker/extensions/kitodo-presentation + path: ./Docker/build/extensions/kitodo-presentation - name: Checkout SLUB Digital Collections repository uses: actions/checkout@v4 with: - repository: ${{ env.GIT_OWNER }}/slub_digitalcollections + repository: markusweigelt/slub_digitalcollections ref: update-typo12 - path: ./Docker/extensions/slub_digitalcollections + path: ./Docker/build/extensions/slub_digitalcollections + + - name: Prepare environment + run: | + # Rename example .env file + mv ./Docker/.env.example ./Docker/.env # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx @@ -53,12 +61,12 @@ jobs: - name: Determine build args run: | date -u +"build_date=%Y-%m-%dT%H:%M:%SZ" >> $GITHUB_ENV - echo "vcs_ref=`git rev-parse --short HEAD`" >> $GITHUB_ENV + echo "vcs_ref=`git -C ./Docker/build/extensions/dfg-viewer rev-parse HEAD`" >> $GITHUB_ENV - name: Build the DFG-Viewer image from module and deploy to GitHub Container Repository uses: docker/build-push-action@v6 with: - context: ./Docker + context: ./Docker/build push: true tags: ${{ env.REGISTRY_PATH }}:${{ env.IMAGE_TAG }} build-args: | diff --git a/.gitignore b/.gitignore index 4c5f4df2..ef6f160a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ Documentation-GENERATED-temp/ public/ vendor/ composer.lock +.env +Docker/build/extensions +!Docker/build/extensions/.gitkeep From de7fa4da86f0a8fd8ca6ff963141c2e0902728e3 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 10:04:19 +0100 Subject: [PATCH 16/52] Update composer.json --- .github/workflows/publish.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index efd1c57a..a6b48c2e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ env: jobs: - build: + build & publish: runs-on: ubuntu-latest steps: @@ -42,11 +42,22 @@ jobs: ref: update-typo12 path: ./Docker/build/extensions/slub_digitalcollections + - name: Update DFG-Viewer composer.json + uses: restackio/update-json-file-action@2.1 + with: + file: ./Docker/build/extensions/dfg-viewer/composer.json + fields: "{'require.kitodo/presentation': '@dev', 'require.slub/slub-digitalcollections': '@dev'}" + + - name: Update SLUB Digital Collections composer.json + uses: restackio/update-json-file-action@2.1 + with: + file: ./Docker/build/extensions/slub_digitalcollections/composer.json + fields: "{'require.kitodo/presentation': '@dev'}" + - name: Prepare environment run: | # Rename example .env file mv ./Docker/.env.example ./Docker/.env - # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From 683fb8756713d7cffb1bce741e313d146f543b0e Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 10:05:57 +0100 Subject: [PATCH 17/52] Update job name --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a6b48c2e..548638d2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ env: jobs: - build & publish: + build-publish: runs-on: ubuntu-latest steps: From 080d025766884e9f9aaf0f489a41164b557021c9 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 11:03:50 +0100 Subject: [PATCH 18/52] Replace required version --- .github/workflows/publish.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 548638d2..05acfaea 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -58,6 +58,13 @@ jobs: run: | # Rename example .env file mv ./Docker/.env.example ./Docker/.env + + # Replace required versions with @dev + cd ./Docker/build/extensions/ + echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json + echo "`jq '.require."slub/slub-digitalcollections"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json + echo "`jq '.require."kitodo/presentation"="@dev"' slub_digitalcollections/composer.json`" > slub_digitalcollections/composer.json + # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From 66079d6b1ab64e69397f3e61de12b2e96be85bd0 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 11:05:58 +0100 Subject: [PATCH 19/52] Remove unused actions --- .github/workflows/publish.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 05acfaea..13abd166 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,18 +42,6 @@ jobs: ref: update-typo12 path: ./Docker/build/extensions/slub_digitalcollections - - name: Update DFG-Viewer composer.json - uses: restackio/update-json-file-action@2.1 - with: - file: ./Docker/build/extensions/dfg-viewer/composer.json - fields: "{'require.kitodo/presentation': '@dev', 'require.slub/slub-digitalcollections': '@dev'}" - - - name: Update SLUB Digital Collections composer.json - uses: restackio/update-json-file-action@2.1 - with: - file: ./Docker/build/extensions/slub_digitalcollections/composer.json - fields: "{'require.kitodo/presentation': '@dev'}" - - name: Prepare environment run: | # Rename example .env file From eb03fec1d21d5283e97efe0ee198c69a3cd2390c Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 13:33:12 +0100 Subject: [PATCH 20/52] echo cat --- .github/workflows/publish.yml | 2 ++ Docker/docker-compose.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 13abd166..860b5fc1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -52,6 +52,8 @@ jobs: echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."slub/slub-digitalcollections"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."kitodo/presentation"="@dev"' slub_digitalcollections/composer.json`" > slub_digitalcollections/composer.json + cat dfg-viewer/composer.json >> $GITHUB_OUTPUT + cat dfg-viewer/composer.json # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index db5af375..f986284d 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -1,6 +1,7 @@ services: dfg-viewer-app: image: ${APP_IMAGE} + pull_policy: always build: context: build environment: From 6d42cf3def5daca112a5bfe2b73a032c1d4dcd25 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 13:36:00 +0100 Subject: [PATCH 21/52] Update publish action --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 860b5fc1..e6aa9ca7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,7 +53,7 @@ jobs: echo "`jq '.require."slub/slub-digitalcollections"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."kitodo/presentation"="@dev"' slub_digitalcollections/composer.json`" > slub_digitalcollections/composer.json cat dfg-viewer/composer.json >> $GITHUB_OUTPUT - cat dfg-viewer/composer.json + cat slub_digitalcollections/composer.json >> $GITHUB_OUTPUT # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx From e71f6817b33c7877e5211b15eb95abd9a944f6ec Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 13:37:39 +0100 Subject: [PATCH 22/52] Update publish --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e6aa9ca7..ed2985f8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -52,8 +52,8 @@ jobs: echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."slub/slub-digitalcollections"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."kitodo/presentation"="@dev"' slub_digitalcollections/composer.json`" > slub_digitalcollections/composer.json - cat dfg-viewer/composer.json >> $GITHUB_OUTPUT - cat slub_digitalcollections/composer.json >> $GITHUB_OUTPUT + cat dfg-viewer/composer.json + cat slub_digitalcollections/composer.json # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx From 7ad8c534f67490f0675b6397d88569361955c6fd Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 13:45:21 +0100 Subject: [PATCH 23/52] Add minimum stability --- Docker/build/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index cd6eb6b1..413aae29 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -73,7 +73,8 @@ RUN a2ensite dfg-viewer.conf && \ # Install extension path RUN mkdir -p /var/www/extensions/ && \ - composer config repositories.local path /var/www/extensions/* + composer config repositories.local path /var/www/extensions/* && \ + composer config minimum-stability dev COPY extensions /var/www/extensions From eac31f4f9b0760e3da4a86daebf88f6c973f35ba Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 15:21:43 +0100 Subject: [PATCH 24/52] Add Dockerfile and improve workflow --- Docker/build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index 413aae29..40147445 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -71,7 +71,7 @@ RUN a2ensite dfg-viewer.conf && \ # Disable default behaviour a2dissite 000-default.conf -# Install extension path +# Install extension path and support of dev dependencies RUN mkdir -p /var/www/extensions/ && \ composer config repositories.local path /var/www/extensions/* && \ composer config minimum-stability dev From c401b56d03b88d291aa44055c11096bd3064aa47 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 15:33:22 +0100 Subject: [PATCH 25/52] Update workflow --- .github/workflows/publish.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ed2985f8..9b5c56d8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,13 +5,6 @@ on: branches: [ "master" ] workflow_dispatch: # run manually -env: - IMAGE_TAG: latest - GIT_OWNER: markusweigelt - GIT_REPO: dfg-viewer - GIT_REF: docker - REGISTRY_PATH: ghcr.io/markusweigelt/dfg-viewer - jobs: build-publish: @@ -21,7 +14,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - + # Deprecated should be set to the main repository if the update-typo12 branch is merged. - name: Checkout DFG-Viewer repository uses: actions/checkout@v4 with: @@ -35,6 +28,7 @@ jobs: repository: kitodo/kitodo-presentation path: ./Docker/build/extensions/kitodo-presentation + # Deprecated should be set to the main repository if the update-typo12 branch is merged. - name: Checkout SLUB Digital Collections repository uses: actions/checkout@v4 with: @@ -52,8 +46,6 @@ jobs: echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."slub/slub-digitalcollections"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."kitodo/presentation"="@dev"' slub_digitalcollections/composer.json`" > slub_digitalcollections/composer.json - cat dfg-viewer/composer.json - cat slub_digitalcollections/composer.json # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx @@ -63,7 +55,7 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Determine build args @@ -76,10 +68,10 @@ jobs: with: context: ./Docker/build push: true - tags: ${{ env.REGISTRY_PATH }}:${{ env.IMAGE_TAG }} + tags: ghcr.io/${{ github.repository }}:latest build-args: | BUILD_DATE=${{ env.build_date }} VCS_REF=${{ env.vcs_ref }} - VCS_URL=https://github.com/${{ env.GIT_OWNER }}/${{ env.GIT_REPO }}/tree/${{ env.GIT_REF }}/ + VCS_URL=https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/ cache-from: type=gha,scope=${{ env.vcs_ref }}-image cache-to: type=gha,mode=max,scope=${{ env.vcs_ref }}-image From a76101b5dd666891c06c0491de472e618779e913 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 12 Nov 2024 16:07:27 +0100 Subject: [PATCH 26/52] Improvements --- Docker/.env.example | 2 +- Docker/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Docker/.env.example b/Docker/.env.example index 179a9fe2..3f723cf7 100644 --- a/Docker/.env.example +++ b/Docker/.env.example @@ -1,5 +1,5 @@ # application image -APP_IMAGE=ghcr.io/markusweigelt/dfg-viewer:latest +APP_IMAGE=ghcr.io/slub/dfg-viewer:latest APP_PORT=80 APP_T3_USER=admin APP_T3_PASSWORD="dvAdmin.1" diff --git a/Docker/README.md b/Docker/README.md index 3bbe2996..43102013 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -55,7 +55,6 @@ git clone https://github.com/slub/slub_digitalcollections build/extensions Adjust the `composer.json` files of the checkouts as follows. - `composer.json` of the [DFG Viewer](https://github.com/slub/dfg-viewer) checkout `build/extensions/dfg-viewer`: ``` @@ -63,6 +62,7 @@ Adjust the `composer.json` files of the checkouts as follows. "require": { ... "kitodo/presentation": "@dev" + "slub/slub-digitalcollection": "@dev" ... }, ... From 4960b58436f5f06f0f1df4c5a5e8b701402cc45c Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Wed, 13 Nov 2024 16:59:01 +0100 Subject: [PATCH 27/52] Add image test --- .github/scripts/test-image.sh | 24 ++++++++++++ .github/workflows/publish.yml | 71 +++++++++++++++++++++++------------ 2 files changed, 70 insertions(+), 25 deletions(-) create mode 100644 .github/scripts/test-image.sh diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh new file mode 100644 index 00000000..68307327 --- /dev/null +++ b/.github/scripts/test-image.sh @@ -0,0 +1,24 @@ +#!/bin/bash +docker compose up -d + +# run wait for it +chmod +x ./build/wait-for-it.sh +./build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" + +# wait 60 seconds until the installation process has finished +sleep 60 + +# testing the container +HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" localhost); +if [ $HTTP_CODE -ne 200 ]; then + echo "Expected HTTP status code to be 200, but got $HTTP_CODE" + exit 1 +fi + +HTML_TITLE=$(curl localhost | grep -m 1 -oP '(?<=).+?(?=)'); +if [ "$HTML_TITLE" != "DFG Viewer" ]; then + echo "Expected content of the HTML tag should to be \"DFG Viewer\", but got \"$HTML_TITLE\"" + exit 1 +fi + + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9b5c56d8..4591a149 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,10 +6,11 @@ on: workflow_dispatch: # run manually jobs: - build-publish: runs-on: ubuntu-latest - + defaults: + run: + working-directory: ./Docker steps: - name: Checkout repository uses: actions/checkout@v4 @@ -20,13 +21,13 @@ jobs: with: repository: markusweigelt/dfg-viewer ref: update-typo12 - path: ./Docker/build/extensions/dfg-viewer + path: ./build/extensions/dfg-viewer - name: Checkout Kitodo.Presentation repository uses: actions/checkout@v4 with: - repository: kitodo/kitodo-presentation - path: ./Docker/build/extensions/kitodo-presentation + repository: kitodo/kitodo-presentation + path: ./build/extensions/kitodo-presentation # Deprecated should be set to the main repository if the update-typo12 branch is merged. - name: Checkout SLUB Digital Collections repository @@ -34,44 +35,64 @@ jobs: with: repository: markusweigelt/slub_digitalcollections ref: update-typo12 - path: ./Docker/build/extensions/slub_digitalcollections + path: ./build/extensions/slub_digitalcollections - name: Prepare environment run: | # Rename example .env file - mv ./Docker/.env.example ./Docker/.env + mv .env.example .env # Replace required versions with @dev - cd ./Docker/build/extensions/ + cd ./build/extensions/ echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."slub/slub-digitalcollections"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."kitodo/presentation"="@dev"' slub_digitalcollections/composer.json`" > slub_digitalcollections/composer.json - # Activate cache export feature to reduce build time of images - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Determine build args run: | date -u +"build_date=%Y-%m-%dT%H:%M:%SZ" >> $GITHUB_ENV - echo "vcs_ref=`git -C ./Docker/build/extensions/dfg-viewer rev-parse HEAD`" >> $GITHUB_ENV + echo "vcs_ref=`git -C ./build/extensions/dfg-viewer rev-parse HEAD`" >> $GITHUB_ENV - - name: Build the DFG-Viewer image from module and deploy to GitHub Container Repository + # Activate cache export feature to reduce build time of images + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build the DFG-Viewer image uses: docker/build-push-action@v6 with: - context: ./Docker/build - push: true + context: ./build tags: ghcr.io/${{ github.repository }}:latest build-args: | BUILD_DATE=${{ env.build_date }} VCS_REF=${{ env.vcs_ref }} VCS_URL=https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/ - cache-from: type=gha,scope=${{ env.vcs_ref }}-image - cache-to: type=gha,mode=max,scope=${{ env.vcs_ref }}-image + + - name: Test the DFG-Viewer image + run: ./../.github/scripts/test-image.sh + + - name: Collect docker logs on failure + if: failure() + uses: jwalton/gh-docker-logs@v2 + with: + dest: './docker-logs' + + - name: Tar docker logs on failure + if: failure() + run: tar cvzf ./docker-logs.tgz ./docker-logs + + - name: Upload docker logs to GitHub + if: failure() + uses: actions/upload-artifact@master + with: + name: docker-logs.tgz + path: ./docker-logs.tgz + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Deploy to GitHub Container Repository + run: docker image push ghcr.io/${{ github.repository }}:latest From e919ae9149cffb952bdd7daa59550f32f5c821f8 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 17:08:12 +0100 Subject: [PATCH 28/52] Improve path for extension checkout --- .github/workflows/publish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4591a149..9186e619 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,13 +21,13 @@ jobs: with: repository: markusweigelt/dfg-viewer ref: update-typo12 - path: ./build/extensions/dfg-viewer + path: ./Docker/build/extensions/dfg-viewer - name: Checkout Kitodo.Presentation repository uses: actions/checkout@v4 with: repository: kitodo/kitodo-presentation - path: ./build/extensions/kitodo-presentation + path: ./Docker/extensions/kitodo-presentation # Deprecated should be set to the main repository if the update-typo12 branch is merged. - name: Checkout SLUB Digital Collections repository @@ -35,7 +35,7 @@ jobs: with: repository: markusweigelt/slub_digitalcollections ref: update-typo12 - path: ./build/extensions/slub_digitalcollections + path: ./Docker/build/extensions/slub_digitalcollections - name: Prepare environment run: | @@ -82,7 +82,7 @@ jobs: - name: Upload docker logs to GitHub if: failure() - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: name: docker-logs.tgz path: ./docker-logs.tgz From c46ea2342256207c61fd4bb09de1a7a3e75050d6 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 17:11:47 +0100 Subject: [PATCH 29/52] Reset to default working directory --- .github/workflows/publish.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9186e619..799a3867 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -40,10 +40,10 @@ jobs: - name: Prepare environment run: | # Rename example .env file - mv .env.example .env + mv ./Docker/.env.example ./Docker/.env # Replace required versions with @dev - cd ./build/extensions/ + cd ./Docker/build/extensions/ echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."slub/slub-digitalcollections"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json echo "`jq '.require."kitodo/presentation"="@dev"' slub_digitalcollections/composer.json`" > slub_digitalcollections/composer.json @@ -51,7 +51,7 @@ jobs: - name: Determine build args run: | date -u +"build_date=%Y-%m-%dT%H:%M:%SZ" >> $GITHUB_ENV - echo "vcs_ref=`git -C ./build/extensions/dfg-viewer rev-parse HEAD`" >> $GITHUB_ENV + echo "vcs_ref=`git -C ./Docker/build/extensions/dfg-viewer rev-parse HEAD`" >> $GITHUB_ENV # Activate cache export feature to reduce build time of images - name: Set up Docker Buildx @@ -60,7 +60,7 @@ jobs: - name: Build the DFG-Viewer image uses: docker/build-push-action@v6 with: - context: ./build + context: ./Docker/build tags: ghcr.io/${{ github.repository }}:latest build-args: | BUILD_DATE=${{ env.build_date }} @@ -68,7 +68,7 @@ jobs: VCS_URL=https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/ - name: Test the DFG-Viewer image - run: ./../.github/scripts/test-image.sh + run: ./.github/scripts/test-image.sh - name: Collect docker logs on failure if: failure() From 74e77aa526b9923408e3adbf1a351ef5d7617dde Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 17:15:52 +0100 Subject: [PATCH 30/52] Reset to default working directory --- .github/workflows/publish.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 799a3867..99f2e6d8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,9 +8,6 @@ on: jobs: build-publish: runs-on: ubuntu-latest - defaults: - run: - working-directory: ./Docker steps: - name: Checkout repository uses: actions/checkout@v4 From 2140e211319da88862b52093a36edf9a0f0ea26a Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 17:20:12 +0100 Subject: [PATCH 31/52] Update test of image and rename workflow --- .github/workflows/{publish.yml => build-test-publish.yml} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename .github/workflows/{publish.yml => build-test-publish.yml} (94%) diff --git a/.github/workflows/publish.yml b/.github/workflows/build-test-publish.yml similarity index 94% rename from .github/workflows/publish.yml rename to .github/workflows/build-test-publish.yml index 99f2e6d8..714ef110 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -1,4 +1,4 @@ -name: Publish DFG-Viewer +name: Build, test and publish DFG-Viewer image on: push: @@ -6,7 +6,7 @@ on: workflow_dispatch: # run manually jobs: - build-publish: + build-test-publish: runs-on: ubuntu-latest steps: - name: Checkout repository @@ -65,7 +65,9 @@ jobs: VCS_URL=https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/ - name: Test the DFG-Viewer image - run: ./.github/scripts/test-image.sh + run: | + chmod +x ./.github/scripts/test-image.sh + ./.github/scripts/test-image.sh - name: Collect docker logs on failure if: failure() From a160e0427b45bb8dcdb1a891902cff6a71d8f8cb Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 17:23:26 +0100 Subject: [PATCH 32/52] Update path --- .github/scripts/test-image.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh index 68307327..53a29fe7 100644 --- a/.github/scripts/test-image.sh +++ b/.github/scripts/test-image.sh @@ -2,8 +2,8 @@ docker compose up -d # run wait for it -chmod +x ./build/wait-for-it.sh -./build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" +chmod +x ./Docker/build/wait-for-it.sh +./Docker/build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" # wait 60 seconds until the installation process has finished sleep 60 From f0604f56e8fc3bf365b8f9e0408add1832a0b48e Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 17:30:16 +0100 Subject: [PATCH 33/52] Fix path --- .github/scripts/test-image.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh index 53a29fe7..bc25c983 100644 --- a/.github/scripts/test-image.sh +++ b/.github/scripts/test-image.sh @@ -1,9 +1,11 @@ #!/bin/bash +cd ./Docker || exit 1 + docker compose up -d # run wait for it -chmod +x ./Docker/build/wait-for-it.sh -./Docker/build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" +chmod +x ./build/wait-for-it.sh +./build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" # wait 60 seconds until the installation process has finished sleep 60 From dc9c12fcdafee161c525775104b68c4298dd98c8 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 17:50:07 +0100 Subject: [PATCH 34/52] Improve deploy image to GitHub Container Repository --- .github/scripts/test-image.sh | 2 +- .github/workflows/build-test-publish.yml | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh index bc25c983..a648c6df 100644 --- a/.github/scripts/test-image.sh +++ b/.github/scripts/test-image.sh @@ -7,7 +7,7 @@ docker compose up -d chmod +x ./build/wait-for-it.sh ./build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" -# wait 60 seconds until the installation process has finished +echo "Wait 60 seconds until the installation process has finished" sleep 60 # testing the container diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 714ef110..96165116 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -63,6 +63,7 @@ jobs: BUILD_DATE=${{ env.build_date }} VCS_REF=${{ env.vcs_ref }} VCS_URL=https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/ + cache-to: type=gha,mode=max,scope=${{ env.vcs_ref }}-image - name: Test the DFG-Viewer image run: | @@ -93,5 +94,15 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy to GitHub Container Repository - run: docker image push ghcr.io/${{ github.repository }}:latest + - name: Build the DFG-Viewer image using GitHub Actions cache and deploy to GitHub Container Repository + uses: docker/build-push-action@v6 + with: + context: ./Docker/build + push: true + tags: ghcr.io/${{ github.repository }}:latest + build-args: | + BUILD_DATE=${{ env.build_date }} + VCS_REF=${{ env.vcs_ref }} + VCS_URL=https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/ + cache-from: type=gha,scope=${{ env.vcs_ref }}-image + From 16c5c085a891b9b10a4e7abbe03485f7356b6ade Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 18:14:14 +0100 Subject: [PATCH 35/52] Update doc --- .github/scripts/test-image.sh | 2 -- Docker/README.md | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh index a648c6df..a572da97 100644 --- a/.github/scripts/test-image.sh +++ b/.github/scripts/test-image.sh @@ -22,5 +22,3 @@ if [ "$HTML_TITLE" != "DFG Viewer" ]; then echo "Expected content of the HTML <title> tag should to be \"DFG Viewer\", but got \"$HTML_TITLE\"" exit 1 fi - - diff --git a/Docker/README.md b/Docker/README.md index 43102013..4fa193f7 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -20,6 +20,8 @@ Go to the directory where you've put `docker-compose.yml`. Copy the environment file `.env.example` inside the directory and rename it to `.env`. Adjust the configuration of the respective service to suit your needs. The variables are marked with the prefix of the service e.g. `APP_` for our Typo3 application with DFG-Viewer. +*It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general, especially in an productive environment.* + Download images and start all service containers ``` docker compose up -d @@ -82,6 +84,6 @@ Adjust the `composer.json` files of the checkouts as follows. Build the image. -*Ensure that the .env file has been created. It is recommended to adjust the `APP_IMAGE` name for custom images.* +*Ensure that the `.env` file has been created. It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general and the `APP_IMAGE` name for building custom images in `.env` file.* `docker compose build dfg-viewer-app` From ab8a257f0b684f42c4cde9e36d4aaeb7e95951aa Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 18:31:04 +0100 Subject: [PATCH 36/52] Using local image for tests --- .github/scripts/test-image.sh | 2 ++ .github/workflows/build-test-publish.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh index a572da97..a3bfe7a5 100644 --- a/.github/scripts/test-image.sh +++ b/.github/scripts/test-image.sh @@ -3,6 +3,8 @@ cd ./Docker || exit 1 docker compose up -d +echo $APP_IMAGE + # run wait for it chmod +x ./build/wait-for-it.sh ./build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 96165116..842e507a 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -67,6 +67,9 @@ jobs: - name: Test the DFG-Viewer image run: | + # overwrite env to use + set APP_IMAGE=ghcr.io/${{ github.repository }}:latest + chmod +x ./.github/scripts/test-image.sh ./.github/scripts/test-image.sh From e45f252beb9a1c89f8655ef4b3439b1753249935 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 18:44:38 +0100 Subject: [PATCH 37/52] Overwrite image path --- .github/scripts/test-image.sh | 2 -- .github/workflows/build-test-publish.yml | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh index a3bfe7a5..a572da97 100644 --- a/.github/scripts/test-image.sh +++ b/.github/scripts/test-image.sh @@ -3,8 +3,6 @@ cd ./Docker || exit 1 docker compose up -d -echo $APP_IMAGE - # run wait for it chmod +x ./build/wait-for-it.sh ./build/wait-for-it.sh localhost:80 --strict -- echo "Application container is up" diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 842e507a..15b3ef2b 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -39,6 +39,9 @@ jobs: # Rename example .env file mv ./Docker/.env.example ./Docker/.env + # overwrite image path + sed -i "s|ghcr.io/slub/dfg-viewer|ghcr.io/${{ github.repository }}|g" .env + # Replace required versions with @dev cd ./Docker/build/extensions/ echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json @@ -67,9 +70,6 @@ jobs: - name: Test the DFG-Viewer image run: | - # overwrite env to use - set APP_IMAGE=ghcr.io/${{ github.repository }}:latest - chmod +x ./.github/scripts/test-image.sh ./.github/scripts/test-image.sh From 715d6659a4b64ad34be8abbef5c7aabed3f512c3 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 18:47:04 +0100 Subject: [PATCH 38/52] Improve env path --- .github/workflows/build-test-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 15b3ef2b..0fbb5b47 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -40,7 +40,7 @@ jobs: mv ./Docker/.env.example ./Docker/.env # overwrite image path - sed -i "s|ghcr.io/slub/dfg-viewer|ghcr.io/${{ github.repository }}|g" .env + sed -i "s|ghcr.io/slub/dfg-viewer|ghcr.io/${{ github.repository }}|g" ./Docker/.env # Replace required versions with @dev cd ./Docker/build/extensions/ From a1fdcf7d87023b3a3c8eef0d1cf3fb3f5f55390c Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 18:55:49 +0100 Subject: [PATCH 39/52] Show env file --- .github/workflows/build-test-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 0fbb5b47..eabe0797 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -42,6 +42,8 @@ jobs: # overwrite image path sed -i "s|ghcr.io/slub/dfg-viewer|ghcr.io/${{ github.repository }}|g" ./Docker/.env + cat ./Docker/.env + # Replace required versions with @dev cd ./Docker/build/extensions/ echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json From 29248d10b73458a6f957cf2e1a34833917bc752d Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Wed, 13 Nov 2024 19:02:02 +0100 Subject: [PATCH 40/52] Upate publish workflow --- .github/workflows/build-test-publish.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index eabe0797..b2e01ead 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -42,8 +42,6 @@ jobs: # overwrite image path sed -i "s|ghcr.io/slub/dfg-viewer|ghcr.io/${{ github.repository }}|g" ./Docker/.env - cat ./Docker/.env - # Replace required versions with @dev cd ./Docker/build/extensions/ echo "`jq '.require."kitodo/presentation"="@dev"' dfg-viewer/composer.json`" > dfg-viewer/composer.json @@ -59,7 +57,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build the DFG-Viewer image + - name: Build the DFG-Viewer image and cache to GitHub Actions cache uses: docker/build-push-action@v6 with: context: ./Docker/build From c001294d665adab28054d2e66d10280ce934e4d4 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Mon, 18 Nov 2024 18:38:38 +0100 Subject: [PATCH 41/52] Add documentation of 3d viewer installation, diverse improvements --- Docker/.env.example | 5 +- Docker/README.md | 53 ++++++++++++++++++- Docker/build/Dockerfile | 3 ++ Docker/docker-compose.yml | 9 ++-- .../docker-compose-mount-fileadmin.yml | 5 ++ 5 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 Docker/overwrites/docker-compose-mount-fileadmin.yml diff --git a/Docker/.env.example b/Docker/.env.example index 3f723cf7..95db2969 100644 --- a/Docker/.env.example +++ b/Docker/.env.example @@ -1,3 +1,6 @@ +# name identifying the compose project +COMPOSE_PROJECT_NAME=dfg-viewer + # application image APP_IMAGE=ghcr.io/slub/dfg-viewer:latest APP_PORT=80 @@ -7,7 +10,7 @@ APP_T3_PASSWORD="dvAdmin.1" # database image DB_IMAGE=mysql:8.0 DB_PORT=3306 -DB_HOST=dfg-viewer-db +DB_HOST=db DB_NAME=typo3 DB_USER=typo3 DB_PASSWORD=password diff --git a/Docker/README.md b/Docker/README.md index 4fa193f7..b1836374 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -3,6 +3,7 @@ * [Prerequisites](#prerequisites) * [Usage](#usage) * [Development](#development) + * [Further information](#further-information) The Kitodo.Production can be started quickly with the provided Docker image. However, a MySQL/MariaDB database and ElasticSearch are required to start the application. Additionally, a Docker Compose file is available for a faster setup. @@ -41,7 +42,7 @@ docker compose down ## Development -To build the image, a folder named `extensions` must be added under folder `build`. +To build the image, a `build` folder with a subfolder `extension` must be added. ``` mkdir -p build/extensions @@ -87,3 +88,53 @@ Build the image. *Ensure that the `.env` file has been created. It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general and the `APP_IMAGE` name for building custom images in `.env` file.* `docker compose build dfg-viewer-app` + +## Further information + +### Usage of 3D viewer integrations + +*There are multiple ways to install the 3D viewer integration. The simplest is to upload the folder that is generated during the [viewer integration installation](https://github.com/slub/dlf-3d-viewers#installation). We have decided to provide an installation based on commands here.* + +Once all containers have been started (see [Usage](#usage)), you can continue as follows. + +1. Login into `dfg-viewer-app-1` container as root user. + +`` +docker exec -u root -it dfg-viewer-app-1 bash +`` + +2. Install unzip command line tool. + +`` +apt-get update && apt-get install unzip +`` + +3. Download the current state of main branch of repository [3D viewer integrations for DFG-Viewer](https://github.com/slub/dlf-3d-viewers) as zip file + +`` +wget "https://github.com/slub/dlf-3d-viewers/archive/refs/heads/main.zip" -O /tmp/dlf-3d-viewers.zip +`` + +4. Navigate to `fileadmin` folder, unzip the zip file, rename unzipped folder to `dlf_3d_viewers` and remove zip file + +``` +cd /var/www/html/dfg-viewer/public/fileadmin + +unzip /tmp/dlf-3d-viewers.zip + +mv dlf-3d-viewers-main dlf_3d_viewers + +rm /tmp/dlf-3d-viewers.zip +``` + +5. Download libraries and frameworks for each viewer integration + +`` +sh dlf_3d_viewers/install.sh +`` + +6. Change owner of integration folder, subfolder and files + +`` +chown -R www-data:www-data dlf_3d_viewers +`` diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index 40147445..878cc69c 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -61,6 +61,7 @@ RUN cd /var/www/html && \ composer create-project typo3/cms-base-distribution dfg-viewer "^12" && \ # cp ./dfg-viewer/public/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess ./dfg-viewer/public/.htaccess && \ touch ./dfg-viewer/public/FIRST_INSTALL && \ + mkdir -p ./dfg-viewer/public/fileadmin && \ chown -R www-data:www-data ./dfg-viewer WORKDIR /var/www/html/dfg-viewer @@ -101,3 +102,5 @@ RUN chmod +x /usr/bin/startup.sh && \ USER www-data CMD ["/usr/bin/startup.sh"] + +VOLUME /var/www/html/dfg-viewer/public/fileadmin diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index f986284d..4567857c 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -1,7 +1,6 @@ services: - dfg-viewer-app: + app: image: ${APP_IMAGE} - pull_policy: always build: context: build environment: @@ -10,10 +9,12 @@ services: T3_PASSWORD: ${APP_T3_PASSWORD} ports: - ${APP_PORT}:80 + volumes: + - t3_fileadmin:/var/www/html/dfg-viewer/public/fileadmin networks: - backend - dfg-viewer-db: + db: image: ${DB_IMAGE} command: - --character-set-server=utf8 @@ -27,5 +28,7 @@ services: - ${DB_PORT}:3306 networks: - backend +volumes: + t3_fileadmin: networks: backend: diff --git a/Docker/overwrites/docker-compose-mount-fileadmin.yml b/Docker/overwrites/docker-compose-mount-fileadmin.yml new file mode 100644 index 00000000..05a25b70 --- /dev/null +++ b/Docker/overwrites/docker-compose-mount-fileadmin.yml @@ -0,0 +1,5 @@ +services: + dfg-viewer-app: + + volumes: + - ./fileadmin:/var/www/html/dfg-viewer/public/fileadmin From e0e3f95867d30d786e6b31adf35d84edf8c4a1c5 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Mon, 18 Nov 2024 18:40:36 +0100 Subject: [PATCH 42/52] Update documentation --- Docker/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/Docker/README.md b/Docker/README.md index b1836374..26dc52ba 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -5,8 +5,6 @@ * [Development](#development) * [Further information](#further-information) -The Kitodo.Production can be started quickly with the provided Docker image. However, a MySQL/MariaDB database and ElasticSearch are required to start the application. Additionally, a Docker Compose file is available for a faster setup. - ## Prerequisites Install Docker Engine From f50bbd068ce28b30c83467e2394ced7495cf21ee Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Mon, 18 Nov 2024 18:43:08 +0100 Subject: [PATCH 43/52] Remove unused overwrite and improve documentation --- Docker/README.md | 2 +- Docker/overwrites/docker-compose-mount-fileadmin.yml | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 Docker/overwrites/docker-compose-mount-fileadmin.yml diff --git a/Docker/README.md b/Docker/README.md index 26dc52ba..75fe3d98 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -17,7 +17,7 @@ https://docs.docker.com/compose/install/ Go to the directory where you've put `docker-compose.yml`. -Copy the environment file `.env.example` inside the directory and rename it to `.env`. Adjust the configuration of the respective service to suit your needs. The variables are marked with the prefix of the service e.g. `APP_` for our Typo3 application with DFG-Viewer. +Copy the environment file `.env.example` inside the directory and rename it to `.env`. Adjust the configuration of the respective service to suit your needs. The variables are marked with the prefix of the service e.g. `APP_` for our TYPO3 application with DFG-Viewer. *It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general, especially in an productive environment.* diff --git a/Docker/overwrites/docker-compose-mount-fileadmin.yml b/Docker/overwrites/docker-compose-mount-fileadmin.yml deleted file mode 100644 index 05a25b70..00000000 --- a/Docker/overwrites/docker-compose-mount-fileadmin.yml +++ /dev/null @@ -1,5 +0,0 @@ -services: - dfg-viewer-app: - - volumes: - - ./fileadmin:/var/www/html/dfg-viewer/public/fileadmin From 499e7b7f99c6eeb3b386a2d79a0a67c7f12e4146 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Mon, 18 Nov 2024 18:56:40 +0100 Subject: [PATCH 44/52] Update doc --- Docker/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Docker/README.md b/Docker/README.md index 75fe3d98..f4228c90 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -26,7 +26,11 @@ Download images and start all service containers docker compose up -d ``` -*When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container.* +It may take about a minute for TYPO3 and the extension to be installed at the initial start. + +The DFG Viewer instance can then be accessed under `localhost`. + +*When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container. * Stops all service containers ``` From 361151c03000fcfbb8722ef5319b4bb82d5bf03a Mon Sep 17 00:00:00 2001 From: Markus Weigelt <Markus.Weigelt@slub-dresden.de> Date: Tue, 19 Nov 2024 10:19:36 +0100 Subject: [PATCH 45/52] Update Docker/build/Dockerfile Improve qualified path Co-authored-by: Stefan Weil <sw@weilnetz.de> --- Docker/build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index 878cc69c..dc6c23f6 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3-apache-bookworm +FROM docker.io/php:8.3-apache-bookworm ARG GIT_REF=master ARG GIT_REPOSITORY=slub/dfg-viewer From cbf4ff5bf68b89dbe3852e152260fc117db28df5 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <Markus.Weigelt@slub-dresden.de> Date: Tue, 19 Nov 2024 10:59:50 +0100 Subject: [PATCH 46/52] Update Dockerfile Add comment for using qualified path --- Docker/build/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index dc6c23f6..94c99657 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -1,3 +1,4 @@ +# Using a qualified path allows, for example, running with Podman out of the box FROM docker.io/php:8.3-apache-bookworm ARG GIT_REF=master From fbbbea66a319c0739cb86d714a985d8c4ee58d92 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Thu, 21 Nov 2024 15:49:25 +0100 Subject: [PATCH 47/52] Fix codacy yaml --- .github/scripts/test-image.sh | 2 +- Docker/README.md | 68 ++++++++++++++++++----------------- Docker/docker-compose.yml | 1 + 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/.github/scripts/test-image.sh b/.github/scripts/test-image.sh index a572da97..24aa9686 100644 --- a/.github/scripts/test-image.sh +++ b/.github/scripts/test-image.sh @@ -12,7 +12,7 @@ sleep 60 # testing the container HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" localhost); -if [ $HTTP_CODE -ne 200 ]; then +if [ "$HTTP_CODE" -ne 200 ]; then echo "Expected HTTP status code to be 200, but got $HTTP_CODE" exit 1 fi diff --git a/Docker/README.md b/Docker/README.md index f4228c90..cd331768 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -1,9 +1,9 @@ # DFG-Viewer Docker - * [Prerequisites](#prerequisites) - * [Usage](#usage) - * [Development](#development) - * [Further information](#further-information) +* [Prerequisites](#prerequisites) +* [Usage](#usage) +* [Development](#development) +* [Further information](#further-information) ## Prerequisites @@ -22,7 +22,7 @@ Copy the environment file `.env.example` inside the directory and rename it to ` *It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general, especially in an productive environment.* Download images and start all service containers -``` +```bash docker compose up -d ``` @@ -33,12 +33,12 @@ The DFG Viewer instance can then be accessed under `localhost`. *When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container. * Stops all service containers -``` +```bash docker compose stop ``` Stops and remove all service containers -``` +```bash docker compose down ``` @@ -46,13 +46,13 @@ docker compose down To build the image, a `build` folder with a subfolder `extension` must be added. -``` +```bash mkdir -p build/extensions ``` Then, the three extension repositories, [DFG Viewer](https://github.com/slub/dfg-viewer), [Kitodo.Presentation](https://github.com/kitodo/kitodo-presentation), [SLUB Digital Collections](https://github.com/slub/slub_digitalcollections), must be cloned into this folder. -``` +```bash git clone https://github.com/slub/dfg-viewer build/extensions git clone https://github.com/kitodo/kitodo-presentation build/extensions git clone https://github.com/slub/slub_digitalcollections build/extensions @@ -62,7 +62,7 @@ Adjust the `composer.json` files of the checkouts as follows. `composer.json` of the [DFG Viewer](https://github.com/slub/dfg-viewer) checkout `build/extensions/dfg-viewer`: -``` +```json ... "require": { ... @@ -75,7 +75,7 @@ Adjust the `composer.json` files of the checkouts as follows. `composer.json` of the [SLUB Digital Collections](https://github.com/slub/slub_digitalcollections) checkout `build/extensions/slub_digitalcollections`: -``` +```json ... "require": { ... @@ -89,7 +89,9 @@ Build the image. *Ensure that the `.env` file has been created. It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general and the `APP_IMAGE` name for building custom images in `.env` file.* -`docker compose build dfg-viewer-app` +```bash +docker compose build dfg-viewer-app +``` ## Further information @@ -101,42 +103,42 @@ Once all containers have been started (see [Usage](#usage)), you can continue as 1. Login into `dfg-viewer-app-1` container as root user. -`` -docker exec -u root -it dfg-viewer-app-1 bash -`` + ```bash + docker exec -u root -it dfg-viewer-app-1 bash + ``` 2. Install unzip command line tool. -`` -apt-get update && apt-get install unzip -`` + ```bash + apt-get update && apt-get install unzip + ``` 3. Download the current state of main branch of repository [3D viewer integrations for DFG-Viewer](https://github.com/slub/dlf-3d-viewers) as zip file -`` -wget "https://github.com/slub/dlf-3d-viewers/archive/refs/heads/main.zip" -O /tmp/dlf-3d-viewers.zip -`` + ```bash + wget "https://github.com/slub/dlf-3d-viewers/archive/refs/heads/main.zip" -O /tmp/dlf-3d-viewers.zip + ``` 4. Navigate to `fileadmin` folder, unzip the zip file, rename unzipped folder to `dlf_3d_viewers` and remove zip file -``` -cd /var/www/html/dfg-viewer/public/fileadmin + ```bash + cd /var/www/html/dfg-viewer/public/fileadmin -unzip /tmp/dlf-3d-viewers.zip + unzip /tmp/dlf-3d-viewers.zip -mv dlf-3d-viewers-main dlf_3d_viewers + mv dlf-3d-viewers-main dlf_3d_viewers -rm /tmp/dlf-3d-viewers.zip -``` + rm /tmp/dlf-3d-viewers.zip + ``` 5. Download libraries and frameworks for each viewer integration -`` -sh dlf_3d_viewers/install.sh -`` + ```bash + sh dlf_3d_viewers/install.sh + ``` 6. Change owner of integration folder, subfolder and files -`` -chown -R www-data:www-data dlf_3d_viewers -`` + ```bash + chown -R www-data:www-data dlf_3d_viewers + ``` diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index 4567857c..c3917dcd 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -1,6 +1,7 @@ services: app: image: ${APP_IMAGE} + pull_policy: always build: context: build environment: From 52f93aadce595861a5f6807f48bcdecf1eda6624 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Thu, 21 Nov 2024 16:11:35 +0100 Subject: [PATCH 48/52] Improve syntax of doc --- Docker/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Docker/README.md b/Docker/README.md index cd331768..2bacf8f8 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -8,10 +8,10 @@ ## Prerequisites Install Docker Engine -https://docs.docker.com/get-docker/ +<https://docs.docker.com/get-docker/> Install Docker Compose -https://docs.docker.com/compose/install/ +<https://docs.docker.com/compose/install/> ## Usage @@ -19,9 +19,10 @@ Go to the directory where you've put `docker-compose.yml`. Copy the environment file `.env.example` inside the directory and rename it to `.env`. Adjust the configuration of the respective service to suit your needs. The variables are marked with the prefix of the service e.g. `APP_` for our TYPO3 application with DFG-Viewer. -*It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general, especially in an productive environment.* +*It is recommended to adjust the password of the TYPO3 admin user `APP_T3_PASSWORD`, the database password `DB_PASSWORD` in general, especially in a productive environment.* Download images and start all service containers + ```bash docker compose up -d ``` @@ -30,7 +31,7 @@ It may take about a minute for TYPO3 and the extension to be installed at the in The DFG Viewer instance can then be accessed under `localhost`. -*When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container. * +*When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container.* Stops all service containers ```bash @@ -62,7 +63,7 @@ Adjust the `composer.json` files of the checkouts as follows. `composer.json` of the [DFG Viewer](https://github.com/slub/dfg-viewer) checkout `build/extensions/dfg-viewer`: -```json +```text ... "require": { ... @@ -75,7 +76,7 @@ Adjust the `composer.json` files of the checkouts as follows. `composer.json` of the [SLUB Digital Collections](https://github.com/slub/slub_digitalcollections) checkout `build/extensions/slub_digitalcollections`: -```json +```text ... "require": { ... From 9d85bb953278bfc6972a4dc481fe56d9cdda82bf Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Thu, 21 Nov 2024 16:23:28 +0100 Subject: [PATCH 49/52] Fix codacy issues --- Docker/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Docker/README.md b/Docker/README.md index 2bacf8f8..960f87ee 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -1,4 +1,4 @@ -# DFG-Viewer Docker +# DFG Viewer Docker * [Prerequisites](#prerequisites) * [Usage](#usage) @@ -34,11 +34,13 @@ The DFG Viewer instance can then be accessed under `localhost`. *When running `docker compose up` all services e.g. DFG-Viewer (APP) and database (DB) in our `docker-compose.yml` will be started and each as separate Docker container.* Stops all service containers + ```bash docker compose stop ``` Stops and remove all service containers + ```bash docker compose down ``` From 6c0c6c9c7769fab1c4ce5f454db6e975dd0ca631 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Thu, 21 Nov 2024 18:18:28 +0100 Subject: [PATCH 50/52] Improve doc for installing 3d viewer --- Docker/README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Docker/README.md b/Docker/README.md index 960f87ee..19fcc70e 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -102,7 +102,21 @@ docker compose build dfg-viewer-app *There are multiple ways to install the 3D viewer integration. The simplest is to upload the folder that is generated during the [viewer integration installation](https://github.com/slub/dlf-3d-viewers#installation). We have decided to provide an installation based on commands here.* -Once all containers have been started (see [Usage](#usage)), you can continue as follows. +Once all containers have been started (see [Usage](#usage)), you can run following command: + +```bash +docker exec -u root -i dfg-viewer-app-1 sh -c "\ +apt-get update && apt-get install unzip \ +&& wget "https://github.com/slub/dlf-3d-viewers/archive/refs/heads/main.zip" -O /tmp/dlf-3d-viewers.zip \ +&& cd /var/www/html/dfg-viewer/public/fileadmin\ +&& unzip /tmp/dlf-3d-viewers.zip\ +&& mv dlf-3d-viewers-main dlf_3d_viewers\ +&& rm /tmp/dlf-3d-viewers.zip\ +&& sh dlf_3d_viewers/install.sh\ +&& chown -R www-data:www-data dlf_3d_viewers" +``` + +The steps of this long command can also be executed individually: 1. Login into `dfg-viewer-app-1` container as root user. From 1ce6923a869b6a6ed57bf8012b6e23487e050413 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <Markus.Weigelt@slub-dresden.de> Date: Mon, 25 Nov 2024 16:47:40 +0100 Subject: [PATCH 51/52] Update Dockerfile Add `T3_SYS_TRUSTEDHOSTSPATTERN` env variable for configuration of hosts names in a reverse proxy environment --- Docker/build/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index 94c99657..7e3825d8 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -94,6 +94,7 @@ ENV DB_USER=typo3 ENV DB_PASSWORD=password ENV T3_USER=admin ENV T3_PASSWORD="dvAdmin.1" +ENV T3_SYS_TRUSTEDHOSTSPATTERN= RUN chmod +x /usr/bin/startup.sh && \ chmod +x /wait-for-it.sh && \ From 3e0883dc96dffefbadfbf864fa9e26c2ff7542c3 Mon Sep 17 00:00:00 2001 From: Markus Weigelt <markus.weigelt@slub-dresden.de> Date: Mon, 25 Nov 2024 17:07:10 +0100 Subject: [PATCH 52/52] add env to configure trusted host pattern --- Docker/.env.example | 1 + Docker/build/Dockerfile | 2 +- Docker/build/startup.sh | 9 ++++++++- Docker/docker-compose.yml | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Docker/.env.example b/Docker/.env.example index 95db2969..e9e5a2e4 100644 --- a/Docker/.env.example +++ b/Docker/.env.example @@ -6,6 +6,7 @@ APP_IMAGE=ghcr.io/slub/dfg-viewer:latest APP_PORT=80 APP_T3_USER=admin APP_T3_PASSWORD="dvAdmin.1" +APP_T3_CONFIG_SYS_TRUSTEDHOSTSPATTERN="" # database image DB_IMAGE=mysql:8.0 diff --git a/Docker/build/Dockerfile b/Docker/build/Dockerfile index 7e3825d8..b6e95f1d 100644 --- a/Docker/build/Dockerfile +++ b/Docker/build/Dockerfile @@ -94,7 +94,7 @@ ENV DB_USER=typo3 ENV DB_PASSWORD=password ENV T3_USER=admin ENV T3_PASSWORD="dvAdmin.1" -ENV T3_SYS_TRUSTEDHOSTSPATTERN= +ENV T3_CONFIG_SYS_TRUSTEDHOSTSPATTERN="" RUN chmod +x /usr/bin/startup.sh && \ chmod +x /wait-for-it.sh && \ diff --git a/Docker/build/startup.sh b/Docker/build/startup.sh index b2bc5cb6..9afcaafc 100644 --- a/Docker/build/startup.sh +++ b/Docker/build/startup.sh @@ -1,7 +1,7 @@ #!/bin/bash echo "Waiting for database container." -/wait-for-it.sh -t 0 $DB_HOST:$DB_PORT +/wait-for-it.sh -t 0 "$DB_HOST:$DB_PORT" # run only once if ! test -f "config/system/settings.php"; then @@ -26,10 +26,17 @@ if ! test -f "config/system/settings.php"; then --site-name="DFG-Viewer" \ --use-existing-database \ --web-server-config="apache" + + # set base configuration ./vendor/bin/typo3 configuration:set 'EXTENSIONS/dlf/fileGrpAudio' 'AUDIO' ./vendor/bin/typo3 configuration:set 'EXTENSIONS/dlf/fileGrpVideo' 'VIDEO,DEFAULT' ./vendor/bin/typo3 configuration:set --json 'FE/cacheHash/requireCacheHashPresenceParameters' '["tx_dlf[id]"]' ./vendor/bin/typo3 configuration:set 'FE/pageNotFoundOnCHashError' 0 + + # set config if environment variable is not empty + if test ! -z "$T3_CONFIG_SYS_TRUSTEDHOSTSPATTERN"; then + ./vendor/bin/typo3 configuration:set 'SYS/trustedHostsPattern' "$T3_CONFIG_SYS_TRUSTEDHOSTSPATTERN" + fi fi exec apache2-foreground diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index c3917dcd..6354ce8f 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -8,6 +8,7 @@ services: DB_HOST: ${DB_HOST} T3_USER: ${APP_T3_USER} T3_PASSWORD: ${APP_T3_PASSWORD} + T3_CONFIG_SYS_TRUSTEDHOSTSPATTERN: ${APP_T3_CONFIG_SYS_TRUSTEDHOSTSPATTERN} ports: - ${APP_PORT}:80 volumes: