azils3 commited on
Commit
6bca3b3
·
verified ·
1 Parent(s): ac2618c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -13
Dockerfile CHANGED
@@ -1,32 +1,37 @@
1
  FROM python:3.10
2
 
3
- # Create a non-root user and set up permissions
4
- RUN adduser --disabled-password --gecos '' Professor && \
5
  mkdir -p /app && \
6
- chown -R Professor:Professor /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 Professor
19
  WORKDIR /app
20
 
21
- # Copy application files (preserve ownership)
22
- COPY --chown=Professor:Professor . .
23
 
24
- # Set environment variables for file paths
25
  ENV LOG_PATH=/app/BotLog.txt
 
26
  ENV FLASK_DEBUG=0
 
 
27
 
28
  # Ensure the log file is writable
29
  RUN touch $LOG_PATH && chmod 666 $LOG_PATH
30
 
31
- # Run bot and dashboard
32
- CMD ["bash", "-c", "python bot.py & flask run --host=0.0.0.0 --port=7860"]
 
 
 
 
1
  FROM python:3.10
2
 
3
+ # Create a non-root user with valid username format
4
+ RUN adduser --disabled-password --gecos '' professor && \
5
  mkdir -p /app && \
6
+ chown -R professor:professor /app
7
 
8
  # Install system dependencies
9
+ RUN apt-get update && apt-get upgrade -y
 
10
 
11
  # Copy requirements and install
12
  COPY requirements.txt /requirements.txt
13
+ RUN pip install --upgrade pip && \
14
+ pip install -r /requirements.txt
15
 
16
  # Switch to non-root user
17
+ USER professor
18
  WORKDIR /app
19
 
20
+ # Copy application files
21
+ COPY --chown=professor:professor . .
22
 
23
+ # Set environment variables
24
  ENV LOG_PATH=/app/BotLog.txt
25
+ ENV FLASK_APP=app.py
26
  ENV FLASK_DEBUG=0
27
+ ENV FLASK_RUN_HOST=0.0.0.0
28
+ ENV FLASK_RUN_PORT=7860
29
 
30
  # Ensure the log file is writable
31
  RUN touch $LOG_PATH && chmod 666 $LOG_PATH
32
 
33
+ # Expose port
34
+ EXPOSE 7860
35
+
36
+ # Run both services
37
+ CMD ["sh", "-c", "python bot.py & flask run"]