trinitytf commited on
Commit
c39163c
·
verified ·
1 Parent(s): 264a3ab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -25
Dockerfile CHANGED
@@ -1,36 +1,32 @@
1
- # Use the official image as base
2
  FROM ghcr.io/flaresolverr/flaresolverr:latest
3
 
4
- # 1. Set the Port to 7860 (Required by Hugging Face)
5
  ENV PORT=7860
6
- # 2. Host must be 0.0.0.0 to be accessible outside the container
7
  ENV HOST=0.0.0.0
8
- # 3. Disable the "Test" URL to prevent boot crashes if it fails
9
- ENV TEST_URL=http://localhost:7860
10
 
11
- # --- PERMISSION FIX ---
12
- # Hugging Face runs as User 1000. We must ensure that user
13
- # has permissions to write to the app directory and the home folder.
14
- USER root
15
-
16
- # Create the standard Hugging Face user home directory
17
- RUN mkdir -p /home/user/app
18
 
19
- # Copy the current application files to the new home (if any) and fix permissions
20
- # We make the entire /app directory writable by User 1000
21
- RUN chown -R 1000:1000 /app && \
22
- chmod -R 777 /app && \
23
- chown -R 1000:1000 /home/user && \
24
- chmod -R 777 /home/user
 
25
 
26
- # Set the Home directory explicitly
27
- ENV HOME=/home/user
 
 
 
 
 
28
 
29
- # Switch to User 1000 (The Hugging Face default)
30
  USER 1000
31
 
32
  # Expose the port
33
- EXPOSE 7860
34
-
35
- # The base image already has the correct command to start,
36
- # so we don't need to overwrite CMD.
 
 
1
  FROM ghcr.io/flaresolverr/flaresolverr:latest
2
 
3
+ # 1. Set Hugging Face Port
4
  ENV PORT=7860
 
5
  ENV HOST=0.0.0.0
 
 
6
 
7
+ # 2. Critical: Set HOME to /tmp
8
+ # Chrome crashes if it can't write lockfiles to the user directory.
9
+ # /tmp is always writable in Docker.
10
+ ENV HOME=/tmp
 
 
 
11
 
12
+ # 3. Optimize for Hugging Face
13
+ # Disable the internal startup test to prevent timeouts (we know it works)
14
+ ENV TEST_URL=127.0.0.1
15
+ # Reduce logging noise unless there is an error
16
+ ENV LOG_LEVEL=info
17
+ # Force Chrome to use /tmp for its user data to avoid permission crashes
18
+ ENV CHROMIUM_ARGS="--user-data-dir=/tmp/chrome-data --no-sandbox --disable-dev-shm-usage"
19
 
20
+ # 4. Fix Permissions for User 1000 (Hugging Face Default)
21
+ USER root
22
+ RUN mkdir -p /tmp/chrome-data && \
23
+ chown -R 1000:1000 /tmp && \
24
+ chmod -R 777 /tmp && \
25
+ chown -R 1000:1000 /app && \
26
+ chmod -R 777 /app
27
 
28
+ # Switch back to the required Hugging Face user
29
  USER 1000
30
 
31
  # Expose the port
32
+ EXPOSE 7860