|
| 1 | +# |
| 2 | +# The contents of this file are subject to the license and copyright |
| 3 | +# detailed in the LICENSE and NOTICE files at the root of the source |
| 4 | +# tree and available online at |
| 5 | +# |
| 6 | +# http://www.dspace.org/license/ |
| 7 | +# |
| 8 | + |
| 9 | +# Overlay that runs the Handle server as a SEPARATE service instead of the one |
| 10 | +# embedded in the backend. The backend stops starting its own Handle server and |
| 11 | +# the standalone service resolves via the backend's remote-resolver REST API: |
| 12 | +# |
| 13 | +# client -> dspace-handle-server(:8000) --HTTP /server/resolve--> dspace (backend) -> dspacedb |
| 14 | +# |
| 15 | +# The Handle server never connects to the database itself. |
| 16 | +# |
| 17 | +# This overlay MUST be listed LAST so its backend `entrypoint` override wins over |
| 18 | +# docker-compose-rest.yml (entrypoint is replaced, not merged). The network ipam |
| 19 | +# from docker-compose-rest.yml is preserved (this file only references dspacenet): |
| 20 | +# |
| 21 | +# docker compose -p d7 \ |
| 22 | +# -f docker/docker-compose.yml \ |
| 23 | +# -f docker/docker-compose-rest.yml \ |
| 24 | +# -f docker/docker-compose-handle.yml up -d |
| 25 | +# |
| 26 | +networks: |
| 27 | + dspacenet: |
| 28 | + |
| 29 | +services: |
| 30 | + # Backend: enable the remote-resolver endpoints and STOP starting the embedded |
| 31 | + # Handle server. This entrypoint is identical to docker-compose-rest.yml with |
| 32 | + # the `/dspace/bin/start-handle-server` line removed. |
| 33 | + dspace: |
| 34 | + environment: |
| 35 | + handle__P__remote__D__resolver__P__enabled: 'true' |
| 36 | + entrypoint: |
| 37 | + - /bin/bash |
| 38 | + - '-c' |
| 39 | + - | |
| 40 | + while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done; |
| 41 | + pushd /usr/local/tomcat/webapps && (unlink server || true) && (ln -s /dspace/webapps/server/ `echo -n "${DSPACE_REST_NAMESPACE}" | sed -e 's#^/##' -e 'sx/x#x'` || true) && popd |
| 42 | + /dspace/bin/dspace database migrate force |
| 43 | + ./custom_run.sh |
| 44 | +
|
| 45 | + # Standalone CNRI Handle server (image built from dataquest-dev/docker-handle-server). |
| 46 | + dspace-handle-server: |
| 47 | + image: ${DSPACE_HANDLE_IMAGE:-ghcr.io/dataquest-dev/docker-handle-server:latest} |
| 48 | + container_name: dspace-handle-server${INSTANCE} |
| 49 | + restart: unless-stopped |
| 50 | + depends_on: |
| 51 | + - dspace |
| 52 | + networks: |
| 53 | + - dspacenet |
| 54 | + environment: |
| 55 | + # Backend REST base the resolver plugin talks to. |
| 56 | + DSPACE_HANDLE_ENDPOINT: ${DSPACE_HANDLE_ENDPOINT:-http://dspace:8080/server} |
| 57 | + ports: |
| 58 | + - published: ${HANDLE_HTTP_PORT:-8000} |
| 59 | + target: 8000 |
| 60 | + host_ip: ${HOST_IP:-127.0.0.1} |
| 61 | + - published: ${HANDLE_NATIVE_PORT:-2641} |
| 62 | + target: 2641 |
| 63 | + protocol: tcp |
| 64 | + host_ip: ${HOST_IP:-127.0.0.1} |
| 65 | + - published: ${HANDLE_NATIVE_PORT:-2641} |
| 66 | + target: 2641 |
| 67 | + protocol: udp |
| 68 | + host_ip: ${HOST_IP:-127.0.0.1} |
| 69 | + # Configure the plugin at runtime (works with the current published image): |
| 70 | + # 1) switch config.dct to the remote-resolver storage plugin (if not already), |
| 71 | + # 2) point the plugin at the backend, |
| 72 | + # 3) wait for the backend (the plugin loads the prefix list on startup and |
| 73 | + # aborts if the backend is unreachable), then start the Handle server. |
| 74 | + entrypoint: |
| 75 | + - /bin/sh |
| 76 | + - -c |
| 77 | + - | |
| 78 | + grep -q MultiRemoteDSpaceRepositoryHandlePlugin /app/config/config.dct || \ |
| 79 | + sed -i 's#"server_config" = {#"server_config" = {\n "storage_type" = "CUSTOM"\n "storage_class" = "org.dspace.handle.MultiRemoteDSpaceRepositoryHandlePlugin"#' /app/config/config.dct |
| 80 | + echo "dspace.handle.endpoint1 = $$DSPACE_HANDLE_ENDPOINT" > /app/config/handle-dspace-plugin.cfg |
| 81 | + echo "Backend endpoint: $$DSPACE_HANDLE_ENDPOINT" |
| 82 | + until wget -q -O- "$$DSPACE_HANDLE_ENDPOINT/listprefixes" >/dev/null 2>&1; do |
| 83 | + echo " waiting for backend $$DSPACE_HANDLE_ENDPOINT ..."; |
| 84 | + sleep 5; |
| 85 | + done |
| 86 | + echo "Backend is up. Starting Handle server." |
| 87 | + exec /app/hs/bin/hdl-server /app/config/ |
0 commit comments