diff --git a/docker/Dockerfile b/docker/Dockerfile index 3b687eba7..00eccbecb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,7 @@ RUN rm -rf ./node_modules ############## BASE-SLIM ############## -FROM python:3.14-slim-bookworm as base-slim +FROM python:3.14-slim-bookworm AS base-slim RUN groupadd "arch" -g 1001 && \ useradd "arch" -u 1001 -g "arch" -G sudo,tape -m -s /bin/bash && \ @@ -47,7 +47,7 @@ RUN echo "arch ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers ############## BUILD-DOCS ############## -FROM base-slim as build-docs +FROM base-slim AS build-docs WORKDIR /code/ESSArch_Core/docs # Add source @@ -72,7 +72,7 @@ RUN for lang in "en" "sv"; do make html LANGUAGE="$lang"; done ############## BUILD-SDIST ############## -FROM base-slim as build-sdist +FROM base-slim AS build-sdist WORKDIR /code # Add source @@ -90,12 +90,12 @@ RUN python setup.py sdist ############## BASE ############## -FROM base-slim as base +FROM base-slim AS base WORKDIR /code ENV ESSARCH_DIR=/ESSArch -ENV PYTHONUNBUFFERED 1 -ENV DJANGO_SETTINGS_MODULE ESSArch_Core.config.settings +ENV PYTHONUNBUFFERED=1 +ENV DJANGO_SETTINGS_MODULE=ESSArch_Core.config.settings ENV PYTHONPATH=/ESSArch/config ENV LANG=en_US.UTF-8 ENV TZ="Europe/Stockholm" @@ -126,7 +126,7 @@ RUN pip install --no-cache-dir datasette ############## PROD ############## -FROM base as prod +FROM base AS prod EXPOSE 8443 8080 ARG ESSARCH_DIR=./ @@ -169,6 +169,9 @@ ADD docker ./docker RUN pip install --no-cache-dir --upgrade `ls -t dist/essarch-*.tar.gz | head -n1`[apache,libreoffice_file_conversion,mysql,saml2,ldap] +# ESSArch Search +RUN pip install --no-cache-dir --extra-index-url="https://files.essarch.org/pypi" essarch-search + RUN mkdir -p ./config RUN mkdir -p ./log RUN essarch settings generate --debug --overwrite -p ./config/local_essarch_settings.py @@ -191,7 +194,7 @@ USER arch ############## DEV ############## -FROM base as dev +FROM base AS dev EXPOSE 8000 RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/docker/entrypoint-celery-worker.sh b/docker/entrypoint-celery-worker.sh index 91e1f221c..3e294c8b4 100755 --- a/docker/entrypoint-celery-worker.sh +++ b/docker/entrypoint-celery-worker.sh @@ -5,11 +5,11 @@ set -o errexit # safety switch, uninitialized variables will stop script. Full command of shortcut `set -u` set -o nounset -CELERYD_NODES=${CELERYD_NODES="worker_celery worker_validation worker_file_operation worker_io_disk worker_io_tape"} +CELERYD_NODES=${CELERYD_NODES="worker_celery worker_poller worker_validation worker_file_operation worker_io_disk worker_io_tape"} CELERY_BIN=${CELERY_BIN="/usr/local/bin/celery"} CELERY_APP=${CELERY_APP="ESSArch_Core.config"} CELERYD_CHDIR=${CELERYD_CHDIR="${ESSARCH_DIR}"} -CELERYD_OPTS=${CELERYD_OPTS="-Q:worker_celery celery -c:worker_celery 4 -Q:worker_validation validation -c:worker_validation 4 -Q:worker_file_operation file_operation -c:worker_file_operation 4 -Q:worker_io_disk io_disk -c:worker_io_disk 4 -Q:worker_io_tape io_tape -c:worker_io_tape 4 -Ofair"} +CELERYD_OPTS=${CELERYD_OPTS="-Q:worker_celery celery -c:worker_celery 4 -Q:worker_poller poller -c:worker_poller 4 -Q:worker_validation validation -c:worker_validation 4 -Q:worker_file_operation file_operation -c:worker_file_operation 4 -Q:worker_io_disk io_disk -c:worker_io_disk 4 -Q:worker_io_tape io_tape -c:worker_io_tape 4 -Ofair"} CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL=INFO} CELERYD_LOG_FILE=${CELERYD_LOG_FILE="${ESSARCH_DIR}/log/celery_%N.log"} CELERYD_PID_FILE=${CELERYD_PID_FILE="${ESSARCH_DIR}/log/proc/celery_%N.pid"} diff --git a/docker/entrypoint-essarch.sh b/docker/entrypoint-essarch.sh index 71891610c..b1633abc3 100755 --- a/docker/entrypoint-essarch.sh +++ b/docker/entrypoint-essarch.sh @@ -2,6 +2,11 @@ set -e +# Dynamically locate ESSArch Search installation +export ESSARCH_SEARCH=$(python -c "import essarch_search, os; print(os.path.dirname(essarch_search.__file__))") + +echo "ESSARCH_SEARCH = $ESSARCH_SEARCH" + if hostname -f > /dev/null 2>&1; then FQDN="`hostname -f`" else @@ -54,6 +59,31 @@ if [ ! -f $ESSARCH_DIR/config/httpd.conf ]; then fi fi +if [ ! -f $ESSARCH_DIR/config/httpd-essarch-search.conf ]; then + echo "Configure apache http for ESSArch Search" + mkdir -p $ESSARCH_DIR/data/essarch_search + mkdir -p $ESSARCH_DIR/config/essarch_search + mkdir -p $ESSARCH_DIR/log/essarch_search + essarch-search install -q + bash < "$ESSARCH_DIR/config/essarch_search/config.json" <<'JSON' +{ + "global": { + "base": { + "title": "ESSArch Search", + "search_multiple_indexes": false + } + }, + "indexes": [] +} +JSON +EOF + cp /code/docker/templates/config/httpd-essarch-search.conf $ESSARCH_DIR/config/httpd-essarch-search.conf +else + echo "Try to apply updates to database for ESSArch Search" + essarch-search upgrade --no-dry-run -y +fi + if [ ! -f $ESSARCH_DIR/config/certs/saml2_essarch.crt ]; then # SAML2 Certs mkdir -p $ESSARCH_DIR/config/certs diff --git a/docker/templates/config/httpd-essarch-datasette.conf b/docker/templates/config/httpd-essarch-datasette.conf index 5788a4d05..9ce2bbcdd 100644 --- a/docker/templates/config/httpd-essarch-datasette.conf +++ b/docker/templates/config/httpd-essarch-datasette.conf @@ -1,8 +1,9 @@ # Datasette #ProxyRequests off -#ProxyPass /datasette http://127.0.0.1:8001 -ProxyPass /datasette http://datasette:8001 +#ProxyPass /datasette http://127.0.0.1:8001 connectiontimeout=300 timeout=300 +ProxyPass /datasette http://datasette:8001 connectiontimeout=300 timeout=300 ProxyPreserveHost On +ProxyIOBufferSize 65536 #ProxyHTMLURLMap http://127.0.0.1:8001 /datasette ProxyPassReverse / diff --git a/docker/templates/config/httpd-essarch-search.conf b/docker/templates/config/httpd-essarch-search.conf new file mode 100644 index 000000000..b049b559e --- /dev/null +++ b/docker/templates/config/httpd-essarch-search.conf @@ -0,0 +1,41 @@ +############################ +# ESSArch Search +############################ + +# Static files +Alias /search/static_django/ ${ESSARCH_DIR}/config/essarch_search/static_django/ +Alias /search/static/ ${ESSARCH_DIR}/config/essarch_search/static_react/static/ +Alias /search/manifest.json ${ESSARCH_DIR}/config/essarch_search/static_react/manifest.json +Alias /search/favicon.ico ${ESSARCH_DIR}/config/essarch_search/static_react/favicon.ico +Alias /search/logo192.png ${ESSARCH_DIR}/config/essarch_search/static_react/logo192.png + + + Require all granted + + + + Require all granted + + +RewriteEngine On +SSLProxyEngine On +ProxyPreserveHost On + +# Disable cert validation +SSLProxyVerify none +SSLProxyCheckPeerName off +SSLProxyCheckPeerExpire off + +RewriteRule ^/runtime-config\.js$ https://%{HTTP_HOST}/search/runtime-config.js [P,L] + +WSGIDaemonProcess essarch_search processes=2 threads=10 + +RedirectMatch 301 ^/search$ /search/ + +WSGIScriptAlias /search ${ESSARCH_SEARCH}/config/wsgi.py process-group=essarch_search application-group=%{GLOBAL} + + + + Require all granted + + diff --git a/docker/templates/config/httpd-essarch.conf b/docker/templates/config/httpd-essarch.conf index 5c2000679..97cabe040 100644 --- a/docker/templates/config/httpd-essarch.conf +++ b/docker/templates/config/httpd-essarch.conf @@ -10,6 +10,9 @@ # WS (websocket) ProxyPass "/ws/" "${ESSARCH_DAPHNE_URL}/ws/" upgrade=websocket + # Include extra options (only for https) + # IncludeOptional ${ESSARCH_DIR}/config/httpd-essarch-*.conf + # Static files Alias /static/ /code/config/essarch/static_root/ @@ -18,19 +21,14 @@ # WSGI (Web Server Gateway Interface) WSGIPassAuthorization On - WSGIDaemonProcess essarch_http processes=2 threads=10 display-name=%{GROUP} - WSGIProcessGroup essarch_http - WSGIApplicationGroup %{GLOBAL} + WSGIDaemonProcess essarch_http processes=2 threads=10 WSGITrustedProxyHeaders X-Forwarded-For - WSGIScriptAlias / /code/config/essarch/wsgi.py + WSGIScriptAlias / /code/config/essarch/wsgi.py process-group=essarch_http application-group=%{GLOBAL} Require all granted - - # Include extra options - IncludeOptional ${ESSARCH_DIR}/config/httpd-essarch-*.conf @@ -52,6 +50,9 @@ # WS (websocket) ProxyPass "/ws/" "${ESSARCH_DAPHNE_URL}/ws/" upgrade=websocket + # Include extra options + IncludeOptional ${ESSARCH_DIR}/config/httpd-essarch-*.conf + # Static files Alias /static/ /code/config/essarch/static_root/ @@ -60,17 +61,12 @@ # WSGI (Web Server Gateway Interface) WSGIPassAuthorization On - WSGIDaemonProcess essarch processes=2 threads=10 display-name=%{GROUP} - WSGIProcessGroup essarch - WSGIApplicationGroup %{GLOBAL} + WSGIDaemonProcess essarch processes=2 threads=10 WSGITrustedProxyHeaders X-Forwarded-For - WSGIScriptAlias / /code/config/essarch/wsgi.py + WSGIScriptAlias / /code/config/essarch/wsgi.py process-group=essarch application-group=%{GLOBAL} Require all granted - - # Include extra options - IncludeOptional ${ESSARCH_DIR}/config/httpd-essarch-*.conf - + \ No newline at end of file