nbugs commited on
Commit
c89ac8b
·
verified ·
1 Parent(s): b781b3f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -30
Dockerfile CHANGED
@@ -15,40 +15,27 @@ COPY editor.js /app/build/assets/
15
  # Copy backup script
16
  COPY sync_data.sh /app/sync_data.sh
17
 
18
- # Get the ENTRYPOINT and CMD from the base image
19
- RUN echo '#!/bin/bash\n\
20
- # Start backup process in background\n\
21
- if [ -f "/app/sync_data.sh" ]; then\n\
22
- (nohup bash /app/sync_data.sh > /tmp/sync.log 2>&1 &)\n\
23
- fi\n\
24
- \n\
25
- # Find and execute the original entrypoint\n\
26
- ORIGINAL_START=$(find / -name "start.sh" -type f | head -n 1)\n\
27
- if [ -n "$ORIGINAL_START" ]; then\n\
28
- echo "Found original start script at $ORIGINAL_START"\n\
29
- exec $ORIGINAL_START "$@"\n\
30
- else\n\
31
- echo "Original start script not found, trying default locations..."\n\
32
- if [ -f "/start.sh" ]; then\n\
33
- exec /start.sh "$@"\n\
34
- elif [ -f "/usr/local/bin/start.sh" ]; then\n\
35
- exec /usr/local/bin/start.sh "$@"\n\
36
- else\n\
37
- echo "Cannot find start script. Container cannot start properly."\n\
38
- exit 1\n\
39
- fi\n\
40
- fi\n\
41
- ' > /app/custom_start.sh && \
42
- chmod +x /app/custom_start.sh
43
-
44
  # Modify HTML references
45
  RUN sed -i 's|</head>|<link rel="stylesheet" href="assets/editor.css"></link><link rel="stylesheet" href="assets/custom.css"></link></head>|' /app/build/index.html && \
46
  sed -i 's|</body>|<script src="assets/editor.js"></script><script src="assets/custom.js"></script></body>|' /app/build/index.html
47
 
48
  # Set permissions
49
- RUN chmod -R 777 ./data && \
50
- chmod -R 777 /app/backend/open_webui/static && \
51
  chmod +x /app/sync_data.sh
52
 
53
- # Use the new start script
54
- ENTRYPOINT ["/app/custom_start.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Copy backup script
16
  COPY sync_data.sh /app/sync_data.sh
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  # Modify HTML references
19
  RUN sed -i 's|</head>|<link rel="stylesheet" href="assets/editor.css"></link><link rel="stylesheet" href="assets/custom.css"></link></head>|' /app/build/index.html && \
20
  sed -i 's|</body>|<script src="assets/editor.js"></script><script src="assets/custom.js"></script></body>|' /app/build/index.html
21
 
22
  # Set permissions
23
+ RUN chmod -R 777 ./data 2>/dev/null || true && \
24
+ chmod -R 777 /app/backend/open_webui/static 2>/dev/null || true && \
25
  chmod +x /app/sync_data.sh
26
 
27
+ # Important: Don't override the ENTRYPOINT
28
+ # Instead, modify the original entrypoint to run our script first
29
+ COPY --from=busybox:1.36 /bin/sh /bin/sh
30
+ RUN ORIGINAL_ENTRYPOINT=$(cat /proc/1/cmdline | tr '\0' ' ' | awk '{print $1}') && \
31
+ if [ -f "$ORIGINAL_ENTRYPOINT" ]; then \
32
+ mv "$ORIGINAL_ENTRYPOINT" "$ORIGINAL_ENTRYPOINT.original" && \
33
+ echo '#!/bin/sh' > "$ORIGINAL_ENTRYPOINT" && \
34
+ echo '# Run backup script in background' >> "$ORIGINAL_ENTRYPOINT" && \
35
+ echo 'if [ -f "/app/sync_data.sh" ]; then' >> "$ORIGINAL_ENTRYPOINT" && \
36
+ echo ' (nohup bash /app/sync_data.sh > /tmp/sync.log 2>&1 &)' >> "$ORIGINAL_ENTRYPOINT" && \
37
+ echo 'fi' >> "$ORIGINAL_ENTRYPOINT" && \
38
+ echo '# Run original entrypoint' >> "$ORIGINAL_ENTRYPOINT" && \
39
+ echo "exec $ORIGINAL_ENTRYPOINT.original \"\$@\"" >> "$ORIGINAL_ENTRYPOINT" && \
40
+ chmod +x "$ORIGINAL_ENTRYPOINT"; \
41
+ fi