Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +29 -18
Dockerfile
CHANGED
|
@@ -1,48 +1,59 @@
|
|
| 1 |
FROM mintplexlabs/anythingllm:latest
|
| 2 |
|
| 3 |
-
# Switch to root to
|
| 4 |
USER root
|
| 5 |
|
| 6 |
-
# Setup the
|
| 7 |
-
# We
|
| 8 |
RUN mkdir -p /collector/hotdir && \
|
| 9 |
chmod -R 777 /collector && \
|
| 10 |
chown -R 1000:1000 /collector
|
| 11 |
|
| 12 |
-
# Create
|
| 13 |
-
# This script
|
|
|
|
| 14 |
RUN echo '#!/bin/bash\n\
|
| 15 |
\n\
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
if [ ! -d "/data/storage" ]; then\n\
|
| 18 |
-
echo "Creating
|
| 19 |
mkdir -p /data/storage\n\
|
| 20 |
fi\n\
|
| 21 |
\n\
|
| 22 |
-
# 2.
|
| 23 |
-
|
|
|
|
| 24 |
chown -R 1000:1000 /data\n\
|
| 25 |
chmod -R 777 /data\n\
|
| 26 |
\n\
|
| 27 |
-
# 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
export STORAGE_DIR="/data/storage"\n\
|
| 29 |
export DATABASE_URL="file:/data/storage/anythingllm.db"\n\
|
| 30 |
\n\
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
' > /start.sh && chmod +x /start.sh
|
| 35 |
|
| 36 |
-
# Set environment variables
|
| 37 |
ENV SERVER_PORT=7860
|
| 38 |
ENV STORAGE_DIR="/data/storage"
|
| 39 |
ENV DATABASE_URL="file:/data/storage/anythingllm.db"
|
| 40 |
|
| 41 |
-
# Expose
|
| 42 |
EXPOSE 7860
|
| 43 |
|
| 44 |
-
#
|
| 45 |
-
|
|
|
|
| 46 |
|
| 47 |
-
#
|
| 48 |
CMD ["/start.sh"]
|
|
|
|
| 1 |
FROM mintplexlabs/anythingllm:latest
|
| 2 |
|
| 3 |
+
# Switch to root to ensure we can create scripts and directories
|
| 4 |
USER root
|
| 5 |
|
| 6 |
+
# 1. Setup the ephemeral "hotdir" for the collector
|
| 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 "--- Starting System Setup ---"\n\
|
| 18 |
+
\n\
|
| 19 |
+
# 1. Ensure Persistent Storage exists\n\
|
| 20 |
if [ ! -d "/data/storage" ]; then\n\
|
| 21 |
+
echo "Creating /data/storage..."\n\
|
| 22 |
mkdir -p /data/storage\n\
|
| 23 |
fi\n\
|
| 24 |
\n\
|
| 25 |
+
# 2. Force Permissions on Persistent Storage (As Root)\n\
|
| 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 |
+
# 4. Define Environment Variables for the App\n\
|
| 37 |
export STORAGE_DIR="/data/storage"\n\
|
| 38 |
export DATABASE_URL="file:/data/storage/anythingllm.db"\n\
|
| 39 |
\n\
|
| 40 |
+
# 5. Start the App as User 1000 (app user)\n\
|
| 41 |
+
# We use "su" to switch from root to user 1000 while preserving the environment\n\
|
| 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 |
+
# Set environment variables
|
| 47 |
ENV SERVER_PORT=7860
|
| 48 |
ENV STORAGE_DIR="/data/storage"
|
| 49 |
ENV DATABASE_URL="file:/data/storage/anythingllm.db"
|
| 50 |
|
| 51 |
+
# Expose port
|
| 52 |
EXPOSE 7860
|
| 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"]
|