Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ FROM php:8.3-fpm-alpine AS production

RUN apk add --no-cache \
libzip-dev \
bash
bash \
jq \
curl

COPY --from=jsmin /usr/bin/jsmin /usr/bin/jsmin
COPY --from=prod-builder /composer/vendor /opt/findingaid/vendor
Expand All @@ -92,6 +94,13 @@ RUN chmod +x /usr/local/bin/entrypoint.sh

RUN ./exe/build.sh

RUN chmod +x /opt/findingaid/exe/findingaid-cache-regen/fa-regen \
/opt/findingaid/exe/findingaid-cache-regen/fa-full-regen \
/opt/findingaid/exe/findingaid-cache-regen/fetch-ead-arks && \
ln -s /opt/findingaid/exe/findingaid-cache-regen/fa-regen /usr/local/bin/fa-regen && \
ln -s /opt/findingaid/exe/findingaid-cache-regen/fa-full-regen /usr/local/bin/fa-full-regen && \
ln -s /opt/findingaid/exe/findingaid-cache-regen/fetch-ead-arks /usr/local/bin/fetch-ead-arks

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
EXPOSE 9000
CMD ["php-fpm", "-F"]
17 changes: 17 additions & 0 deletions exe/findingaid-cache-regen/fa-full-regen
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail

# The environment should provide these variables
# SOLR_URL: e.g. https://solrhost.example.com/solr/select

ARKS_FILE="$(mktemp)"
export ARKS_FILE

trap 'rm -f "$ARKS_FILE"' EXIT

echo "Attempting generation of a list of finding aids to reprocess"
fetch-ead-arks
echo "List generated"
echo "Reprocessing finding aids"
xargs -n 1 -P 4 fa-regen < "$ARKS_FILE"
echo "Finding aids reprocessed"
9 changes: 9 additions & 0 deletions exe/findingaid-cache-regen/fa-regen
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# use docker's dns to target the web service
TARGET_URL=http://web

ID=$1
BASE="$TARGET_URL/fa/findingaid/?id=$ID&invalidate_cache=1"
echo "$BASE"
curl "$BASE" >/dev/null
16 changes: 16 additions & 0 deletions exe/findingaid-cache-regen/fetch-ead-arks
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail

# The environment should provide these variables
# SOLR_URL: e.g. https://solrhost.example.com/solr/select
# ARKS_FILE: where ARKs should be written

COUNT_URL="${SOLR_URL}?wt=json&fl=id&fq=format:collections"
numFound=$(curl -s "$COUNT_URL" | jq -r .response.numFound)
echo "Found $numFound collections"

echo "Fetching ids"
EADS_URL="${SOLR_URL}?wt=json&fl=id&fq=format:collections&rows=${numFound}"
curl -s "$EADS_URL" | jq -r '.response.docs[] | .id' > "$ARKS_FILE"

echo "IDs written to $ARKS_FILE"
Loading