Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +25 -38
Dockerfile
CHANGED
|
@@ -1,59 +1,46 @@
|
|
| 1 |
FROM mintplexlabs/anythingllm:latest
|
| 2 |
|
| 3 |
-
# Switch to root
|
|
|
|
| 4 |
USER root
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
# We create it now to ensure it exists.
|
| 8 |
-
RUN mkdir -p /collector/hotdir && \
|
| 9 |
-
chmod -R 777 /collector && \
|
| 10 |
-
chown -R 1000:1000 /collector
|
| 11 |
-
|
| 12 |
-
# 2. Create the startup script
|
| 13 |
-
# IMPORTANT: This script will run as ROOT to fix permissions,
|
| 14 |
-
# then step down to user 1000 to run the app.
|
| 15 |
RUN echo '#!/bin/bash\n\
|
| 16 |
\n\
|
| 17 |
-
echo "---
|
|
|
|
|
|
|
|
|
|
| 18 |
\n\
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
fi\n\
|
| 24 |
\n\
|
| 25 |
-
#
|
| 26 |
-
# This ensures User 1000 can write to the mounted drive\n\
|
| 27 |
-
echo "Fixing permissions on /data..."\n\
|
| 28 |
-
chown -R 1000:1000 /data\n\
|
| 29 |
chmod -R 777 /data\n\
|
| 30 |
-
\n\
|
| 31 |
-
# 3. Ensure Collector Hotdir is writable\n\
|
| 32 |
-
echo "Fixing permissions on /collector..."\n\
|
| 33 |
-
chown -R 1000:1000 /collector\n\
|
| 34 |
chmod -R 777 /collector\n\
|
| 35 |
\n\
|
| 36 |
-
#
|
|
|
|
| 37 |
export STORAGE_DIR="/data/storage"\n\
|
| 38 |
export DATABASE_URL="file:/data/storage/anythingllm.db"\n\
|
| 39 |
\n\
|
| 40 |
-
#
|
| 41 |
-
|
| 42 |
-
echo "Starting AnythingLLM as user 1000..."\n\
|
| 43 |
-
exec su -p -s /bin/bash 1000 -c "/usr/local/bin/docker-entrypoint.sh composer start"\n\
|
| 44 |
' > /start.sh && chmod +x /start.sh
|
| 45 |
|
| 46 |
-
#
|
| 47 |
ENV SERVER_PORT=7860
|
| 48 |
ENV STORAGE_DIR="/data/storage"
|
| 49 |
ENV DATABASE_URL="file:/data/storage/anythingllm.db"
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
# CRITICAL CHANGE: We stay as ROOT here so the CMD can run with permissions.
|
| 55 |
-
# The script itself handles switching down to user 1000.
|
| 56 |
-
USER root
|
| 57 |
-
|
| 58 |
-
# Start via our script
|
| 59 |
-
CMD ["/start.sh"]
|
|
|
|
| 1 |
FROM mintplexlabs/anythingllm:latest
|
| 2 |
|
| 3 |
+
# 1. Switch to root and STAY root.
|
| 4 |
+
# We will not switch back to user 1000. This bypasses all permission errors.
|
| 5 |
USER root
|
| 6 |
|
| 7 |
+
# 2. Create a startup script to handle the storage setup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
RUN echo '#!/bin/bash\n\
|
| 9 |
\n\
|
| 10 |
+
echo "--- GLOBAL PERMISSION FIX ---"\n\
|
| 11 |
+
\n\
|
| 12 |
+
# A. Create the Persistent Storage Directory\n\
|
| 13 |
+
mkdir -p /data/storage\n\
|
| 14 |
\n\
|
| 15 |
+
# B. Create the "Hot Directory" for uploads\n\
|
| 16 |
+
mkdir -p /collector/hotdir\n\
|
| 17 |
+
\n\
|
| 18 |
+
# C. SYMLINK FIX (The ultimate fallback)\n\
|
| 19 |
+
# We delete the internal storage folder and link it to the persistent drive.\n\
|
| 20 |
+
# This ensures that ANY part of the app trying to write locally actually writes to /data.\n\
|
| 21 |
+
if [ ! -L "/app/server/storage" ]; then\n\
|
| 22 |
+
echo "Linking internal storage to persistent drive..."\n\
|
| 23 |
+
rm -rf /app/server/storage\n\
|
| 24 |
+
ln -s /data/storage /app/server/storage\n\
|
| 25 |
fi\n\
|
| 26 |
\n\
|
| 27 |
+
# D. Grant 777 permissions to everything (Just in case)\n\
|
|
|
|
|
|
|
|
|
|
| 28 |
chmod -R 777 /data\n\
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
chmod -R 777 /collector\n\
|
| 30 |
\n\
|
| 31 |
+
# E. Start the Application as ROOT\n\
|
| 32 |
+
echo "Starting AnythingLLM as ROOT..."\n\
|
| 33 |
export STORAGE_DIR="/data/storage"\n\
|
| 34 |
export DATABASE_URL="file:/data/storage/anythingllm.db"\n\
|
| 35 |
\n\
|
| 36 |
+
# Execute the original entrypoint command\n\
|
| 37 |
+
exec /usr/local/bin/docker-entrypoint.sh composer start\n\
|
|
|
|
|
|
|
| 38 |
' > /start.sh && chmod +x /start.sh
|
| 39 |
|
| 40 |
+
# 3. Define Environment Variables
|
| 41 |
ENV SERVER_PORT=7860
|
| 42 |
ENV STORAGE_DIR="/data/storage"
|
| 43 |
ENV DATABASE_URL="file:/data/storage/anythingllm.db"
|
| 44 |
|
| 45 |
+
# 4. Override the entrypoint to force our script to run first
|
| 46 |
+
ENTRYPOINT ["/start.sh"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|