azils3 commited on
Commit
278a829
·
verified ·
1 Parent(s): bc96bf6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -6
Dockerfile CHANGED
@@ -1,11 +1,30 @@
1
  FROM python:3.10
2
- RUN apt update && apt upgrade -y
3
- RUN apt install git -y
 
 
 
 
 
 
 
 
 
4
  COPY requirements.txt /requirements.txt
 
 
5
 
6
- RUN cd /
7
- RUN pip install -U pip && pip install -U -r requirements.txt
8
  WORKDIR /app
9
 
10
- COPY . .
11
- CMD ["python", "bot.py"]
 
 
 
 
 
 
 
 
 
1
  FROM python:3.10
2
+
3
+ # Create a non-root user and set up permissions
4
+ RUN adduser --disabled-password --gecos '' myuser && \
5
+ mkdir -p /app && \
6
+ chown -R myuser:myuser /app
7
+
8
+ # Install system dependencies
9
+ RUN apt update && apt upgrade -y && \
10
+ apt install git -y
11
+
12
+ # Copy requirements and install
13
  COPY requirements.txt /requirements.txt
14
+ RUN pip install -U pip && \
15
+ pip install -U -r requirements.txt
16
 
17
+ # Switch to non-root user
18
+ USER myuser
19
  WORKDIR /app
20
 
21
+ # Copy application files (preserve ownership)
22
+ COPY --chown=myuser:myuser . .
23
+
24
+ # Set environment variables for file paths
25
+ ENV LOG_PATH=/app/BotLog.txt
26
+
27
+ # Ensure the log file is writable
28
+ RUN touch $LOG_PATH && chmod 666 $LOG_PATH
29
+
30
+ CMD ["python", "bot.py"]