xdragxt commited on
Commit
32bb9d8
·
verified ·
1 Parent(s): 991c038

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -0
Dockerfile ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ # Create a non-root user
4
+ RUN useradd -m -u 1000 user
5
+ ENV PATH="/home/user/.local/bin:$PATH"
6
+
7
+ # Set working directory
8
+ WORKDIR /app
9
+
10
+ # Install dependencies
11
+ COPY requirements.txt requirements.txt
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
+
14
+ # Install tmate and required tools
15
+ RUN apt-get update && apt-get install -y curl git tmate && apt-get clean
16
+
17
+ # Copy app code
18
+ COPY . /app
19
+
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 app: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"]