Skip to content

Commit

Permalink
Do not require setting CANTALOUPE_ENDPOINT_API_SECRET
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Jan 16, 2025
1 parent 7444282 commit b3b0f0c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cantaloupe/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM islandora/cantaloupe:3.4

ENV CANTALOUPE_ENDPOINT_API_ENABLED="true" \
CANTALOUPE_ENDPOINT_API_USERNAME=islandora

RUN apk add --no-cache \
gcc \
g++ \
Expand All @@ -14,11 +17,20 @@ RUN apk add --no-cache \
jpeg-dev \
zlib-dev \
libwebp-dev \
&& git clone https://github.com/CLIUtils/CLI11.git \
&& cd CLI11 \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make \
&& make install \
&& cd ../.. && rm -rf grok \
&& git clone https://github.com/GrokImageCompression/grok \
&& cd grok \
&& git checkout v14.2.0 \
&& cmake . \
&& make install \
&& cd ../ && rm -rf grok \
&& apk del \
gcc \
g++ \
Expand All @@ -33,4 +45,8 @@ RUN apk add --no-cache \
zlib-dev \
libwebp-dev

HEALTHCHECK CMD curl -s http://localhost:8182/health | jq .color | grep -q GREEN
COPY --link rootfs /

HEALTHCHECK CMD curl -s \
-u "${CANTALOUPE_ENDPOINT_API_USERNAME}:$(cat /var/run/s6/container_environment/CANTALOUPE_ENDPOINT_API_SECRET)" \
http://localhost:8182/health | jq .color | grep -q GREEN
8 changes: 8 additions & 0 deletions cantaloupe/rootfs/etc/cont-init.d/01-set-api-secret.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/with-contenv bash
set -e

ENV_FILE="/var/run/s6/container_environment/CANTALOUPE_ENDPOINT_API_SECRET"
if [ ! -s "$ENV_FILE" ]; then
openssl rand -hex 16 > "$ENV_FILE"
echo "CANTALOUPE_ENDPOINT_API_SECRET was empty. Set to a new random value."
fi

0 comments on commit b3b0f0c

Please sign in to comment.