xdragxt commited on
Commit
edf25b0
·
verified ·
1 Parent(s): 0e82105

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -9
Dockerfile CHANGED
@@ -20,16 +20,28 @@ COPY . /app
20
  # Set permissions for non-root user
21
  RUN chown -R user:user /app
22
 
23
- # Create startup script (write log to user home to avoid permission issue)
24
- RUN echo '#!/bin/bash\n' \
25
- '# Start tmate session in background\n' \
26
- '(tmate -F > /home/user/tmate.log 2>&1 &)\n\n' \
27
- '# Start FastAPI app\n' \
28
- 'exec uvicorn main:app --host 0.0.0.0 --port 7860' \
29
- > /app/start.sh && chmod +x /app/start.sh
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  # Switch to non-root user
32
  USER user
33
 
34
- # Start the bot and tmate session
35
- CMD ["bash", "start.sh"]
 
20
  # Set permissions for non-root user
21
  RUN chown -R user:user /app
22
 
23
+ # Create startup script that logs tmate link
24
+ RUN cat << 'EOF' > /app/start.sh
25
+ #!/bin/bash
26
+
27
+ # Start tmate in the background and write output to log
28
+ tmate -F > /tmp/tmate.log 2>&1 &
29
+
30
+ # Wait for tmate to initialize
31
+ sleep 2
32
+
33
+ # Print the SSH/web link from the tmate log
34
+ grep -E "ssh|web|https" /tmp/tmate.log || tail -n 20 /tmp/tmate.log
35
+
36
+ # Start FastAPI app
37
+ exec uvicorn main:app --host 0.0.0.0 --port 7860
38
+ EOF
39
+
40
+ # Make the script executable
41
+ RUN chmod +x /app/start.sh
42
 
43
  # Switch to non-root user
44
  USER user
45
 
46
+ # Run the startup script
47
+ CMD ["bash", "/app/start.sh"]