feat: add Docker entrypoint script for MAGIC_MAX_WIDTH/HEIGHT (#10)

This generates an ImageMagick policy.xml. This isn't done at the application level as system policies override ones passed in with `MAGICK_CONFIGURE_PATH` which would result in confusing behavior.
This commit is contained in:
strawberry-raccoon
2026-02-24 19:47:37 +00:00
committed by GitHub
parent 01fda227b9
commit 8c05944ec5
3 changed files with 24 additions and 1 deletions
+2 -1
View File
@@ -101,6 +101,7 @@ RUN ARCH=$(uname -m) && \
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /app/public/ /app/public/
COPY --from=prerelease /app/dist /app/dist
COPY entrypoint.sh /app/entrypoint.sh
# COPY . .
RUN mkdir data
@@ -109,4 +110,4 @@ EXPOSE 3000/tcp
# used for calibre
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
ENV NODE_ENV=production
ENTRYPOINT [ "bun", "run", "dist/src/index.js" ]
ENTRYPOINT [ "/app/entrypoint.sh" ]
+2
View File
@@ -101,6 +101,8 @@ All are optional, JWT_SECRET is recommended to be set.
| LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) |
| UNAUTHENTICATED_USER_SHARING | false | Shares conversion history between all unauthenticated users |
| MAX_CONVERT_PROCESS | 0 | Maximum number of concurrent conversion processes allowed. Set to 0 for unlimited. |
| MAGICK_MAX_WIDTH | 8000 | (Docker only) ImageMagick maximum image width in pixels |
| MAGICK_MAX_HEIGHT | 8000 | (Docker only) ImageMagick maximum image height in pixels |
### Docker images
Executable
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
set -e
if [ -n "$MAGICK_MAX_WIDTH" ] || [ -n "$MAGICK_MAX_HEIGHT" ]; then
POLICY_DIR="/etc/ImageMagick-7"
POLICY_FILE="$POLICY_DIR/policy.xml"
mkdir -p "$POLICY_DIR"
echo "<policymap>" > "$POLICY_FILE"
if [ -n "$MAGICK_MAX_WIDTH" ]; then
echo " <policy domain=\"resource\" name=\"width\" value=\"$MAGICK_MAX_WIDTH\"/>" >> "$POLICY_FILE"
fi
if [ -n "$MAGICK_MAX_HEIGHT" ]; then
echo " <policy domain=\"resource\" name=\"height\" value=\"$MAGICK_MAX_HEIGHT\"/>" >> "$POLICY_FILE"
fi
echo "</policymap>" >> "$POLICY_FILE"
fi
exec bun run dist/src/index.js