triflix commited on
Commit
8be1d60
·
verified ·
1 Parent(s): 0a0e80c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -10
Dockerfile CHANGED
@@ -1,18 +1,47 @@
1
- FROM jlesage/firefox
2
 
3
- RUN apt-get update && apt-get install -y socat && apt-get clean
 
4
 
5
- RUN useradd -m -u 1000 hfuser
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  USER hfuser
8
 
9
- ENV DISPLAY_WIDTH=1280 \
10
- DISPLAY_HEIGHT=720 \
11
- ENABLE_CJK_FONT=1 \
12
- KEEP_APP_RUNNING=1 \
13
- TEMP=/tmp \
14
- TMPDIR=/tmp
15
 
 
16
  EXPOSE 7860
17
 
18
- CMD /startapp.sh & socat TCP-LISTEN:7860,fork TCP:localhost:5800
 
 
1
+ FROM jlesage/firefox:latest
2
 
3
+ # Switch to root to install packages and setup user
4
+ USER root
5
 
6
+ # Install socat for port redirection (Alpine Linux uses apk)
7
+ RUN apk add --no-cache socat
8
 
9
+ # Create user with UID 1000 as required by Hugging Face Spaces
10
+ RUN adduser -D -s /bin/sh -u 1000 hfuser
11
+
12
+ # Configure environment variables for optimal Firefox experience
13
+ ENV DISPLAY_WIDTH=1920
14
+ ENV DISPLAY_HEIGHT=1080
15
+ ENV KEEP_APP_RUNNING=1
16
+ ENV ENABLE_CJK_FONT=1
17
+ ENV TEMP=/tmp
18
+ ENV TMPDIR=/tmp
19
+
20
+ # Create startup script
21
+ RUN echo '#!/bin/sh' > /start.sh && \
22
+ echo 'set -e' >> /start.sh && \
23
+ echo '' >> /start.sh && \
24
+ echo '# Start Firefox container services in background' >> /start.sh && \
25
+ echo '/etc/services.d/firefox/run &' >> /start.sh && \
26
+ echo '/etc/services.d/xvfb/run &' >> /start.sh && \
27
+ echo '/etc/services.d/openbox/run &' >> /start.sh && \
28
+ echo '/etc/services.d/webui/run &' >> /start.sh && \
29
+ echo '' >> /start.sh && \
30
+ echo '# Wait for services to start' >> /start.sh && \
31
+ echo 'sleep 10' >> /start.sh && \
32
+ echo '' >> /start.sh && \
33
+ echo '# Redirect port 5800 to 7860 for Hugging Face Spaces' >> /start.sh && \
34
+ echo 'exec socat TCP-LISTEN:7860,fork,reuseaddr TCP:localhost:5800' >> /start.sh && \
35
+ chmod +x /start.sh
36
+
37
+ # Switch to hfuser as required by Hugging Face Spaces
38
  USER hfuser
39
 
40
+ # Set working directory
41
+ WORKDIR /tmp
 
 
 
 
42
 
43
+ # Expose port 7860 as required by Hugging Face Spaces
44
  EXPOSE 7860
45
 
46
+ # Start the application
47
+ CMD ["/start.sh"]