mgbam commited on
Commit
dbff676
·
verified ·
1 Parent(s): d976baa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -18
Dockerfile CHANGED
@@ -10,29 +10,28 @@ RUN apt-get update && \
10
  libxext6 \
11
  fontconfig \
12
  imagemagick \
13
- ghostscript && \ # Often needed by ImageMagick for text/vector handling
14
  # Modify ImageMagick policy to be less restrictive for TextClip
15
- # This comments out common restrictive policies. Be aware of security implications if image content is user-supplied.
16
- # For a more targeted approach, identify the exact policy causing the block.
17
- # Common paths for policy.xml: /etc/ImageMagick-6/policy.xml or /etc/ImageMagick/policy.xml
18
- # The path might vary based on ImageMagick version (e.g., ImageMagick-6 or ImageMagick-7)
19
- # First, find the policy file path
20
  ( \
21
- POLICY_FILE=$(find /etc/ImageMagick* -name policy.xml | head -n 1) && \
22
- if [ -f "$POLICY_FILE" ]; then \
23
  echo "INFO: Modifying ImageMagick policy file: $POLICY_FILE"; \
24
- sed -i 's/<policy domain="coder" rights="none" pattern="PS" \/>/<!-- <policy domain="coder" rights="none" pattern="PS" \/> -->/' "$POLICY_FILE"; \
25
- sed -i 's/<policy domain="coder" rights="none" pattern="PS2" \/>/<!-- <policy domain="coder" rights="none" pattern="PS2" \/> -->/' "$POLICY_FILE"; \
26
- sed -i 's/<policy domain="coder" rights="none" pattern="PS3" \/>/<!-- <policy domain="coder" rights="none" pattern="PS3" \/> -->/' "$POLICY_FILE"; \
27
- sed -i 's/<policy domain="coder" rights="none" pattern="EPS" \/>/<!-- <policy domain="coder" rights="none" pattern="EPS" \/> -->/' "$POLICY_FILE"; \
28
- sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<!-- <policy domain="coder" rights="none" pattern="PDF" \/> -->/' "$POLICY_FILE"; \
29
- sed -i 's/<policy domain="coder" rights="none" pattern="XPS" \/>/<!-- <policy domain="coder" rights="none" pattern="XPS" \/> -->/' "$POLICY_FILE"; \
30
- sed -i 's/<policy domain="coder" rights="none" pattern="LABEL" \/>/<!-- <policy domain="coder" rights="none" pattern="LABEL" \/> -->/' "$POLICY_FILE"; \
31
- sed -i 's/<policy domain="coder" rights="none" pattern="TEXT" \/>/<!-- <policy domain="coder" rights="none" pattern="TEXT" \/> -->/' "$POLICY_FILE"; \
32
- sed -i 's/<policy domain="path" rights="none" pattern="@*" \/>/<!-- <policy domain="path" rights="none" pattern="@*" \/> -->/' "$POLICY_FILE"; \
33
  echo "INFO: ImageMagick policy potentially updated."; \
34
  else \
35
- echo "WARNING: ImageMagick policy.xml not found. TextClip might fail."; \
36
  fi \
37
  ) && \
38
  apt-get clean && \
 
10
  libxext6 \
11
  fontconfig \
12
  imagemagick \
13
+ ghostscript && \
14
  # Modify ImageMagick policy to be less restrictive for TextClip
15
+ # This entire block is a single shell command executed by RUN
16
+ # The semicolon after the fi is important for shell syntax if followed by &&
17
+ # We ensure the subshell commands are properly chained with && inside the subshell
18
+ # and the whole subshell is one command in the RUN sequence.
 
19
  ( \
20
+ POLICY_FILE=$(find /etc/ImageMagick* -name policy.xml -print -quit 2>/dev/null) && \
21
+ if [ -n "$POLICY_FILE" ] && [ -f "$POLICY_FILE" ]; then \
22
  echo "INFO: Modifying ImageMagick policy file: $POLICY_FILE"; \
23
+ sed -i 's/<policy domain="coder" rights="none" pattern="PS" \/>/<!-- & -->/' "$POLICY_FILE" && \
24
+ sed -i 's/<policy domain="coder" rights="none" pattern="PS2" \/>/<!-- & -->/' "$POLICY_FILE" && \
25
+ sed -i 's/<policy domain="coder" rights="none" pattern="PS3" \/>/<!-- & -->/' "$POLICY_FILE" && \
26
+ sed -i 's/<policy domain="coder" rights="none" pattern="EPS" \/>/<!-- & -->/' "$POLICY_FILE" && \
27
+ sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<!-- & -->/' "$POLICY_FILE" && \
28
+ sed -i 's/<policy domain="coder" rights="none" pattern="XPS" \/>/<!-- & -->/' "$POLICY_FILE" && \
29
+ sed -i 's/<policy domain="coder" rights="none" pattern="LABEL" \/>/<!-- & -->/' "$POLICY_FILE" && \
30
+ sed -i 's/<policy domain="coder" rights="none" pattern="TEXT" \/>/<!-- & -->/' "$POLICY_FILE" && \
31
+ sed -i 's/<policy domain="path" rights="none" pattern="@*" \/>/<!-- & -->/' "$POLICY_FILE" && \
32
  echo "INFO: ImageMagick policy potentially updated."; \
33
  else \
34
+ echo "WARNING: ImageMagick policy.xml not found or find command failed. TextClip might fail."; \
35
  fi \
36
  ) && \
37
  apt-get clean && \