Azeez98 commited on
Commit
0bba6a6
·
verified ·
1 Parent(s): 0feb08a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -19
Dockerfile CHANGED
@@ -6,9 +6,6 @@ ARG CACHEBUST=1
6
 
7
  # Create non-root user
8
  RUN useradd -m -u 1000 user
9
- USER user
10
-
11
- ENV PATH="/home/user/.local/bin:$PATH"
12
 
13
  # Set working directory
14
  WORKDIR /app
@@ -16,35 +13,42 @@ WORKDIR /app
16
  # Clone GitHub repo into /app
17
  RUN git clone https://github.com/Mekhlafi98/solverai.git -b develop2 /app
18
 
19
- # Install Python dependencies
20
- RUN pip install --no-cache-dir --upgrade pip gunicorn && \
21
- pip install --no-cache-dir -r requirements.txt
22
-
23
- # Set environment variables
24
- ENV OCR_API_TOKEN=${OCR_API_TOKEN} \
25
  GOOGLE_API_KEY=${GOOGLE_API_KEY} \
26
  TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} \
27
  MODEL_NAME=gemini-1.5-flash \
28
- # STATIC_ROOT=/app/staticfiles \
29
  ALLOWED_HOSTS=localhost,127.0.0.1,azeez98-solveai.hf.space
30
 
31
- # Collect static files
 
 
 
 
 
32
  RUN python manage.py collectstatic --noinput
33
 
34
  # Copy NGINX config
35
  COPY nginx/default.conf /etc/nginx/conf.d/default.conf
36
 
37
- # Collect static files (optional)
38
  RUN mkdir -p /app/static /app/media
39
 
40
- # Run script
 
 
 
 
 
 
41
  COPY start.sh /start.sh
42
- # RUN chmod +x /start.sh
43
 
44
- CMD ["/start.sh"]
 
45
 
46
- # # Expose Django port
47
- # EXPOSE 7860
48
 
49
- # # Run with Gunicorn (edit project name below)
50
- # CMD ["gunicorn", "django_project.wsgi:application", "--bind", "0.0.0.0:7860"]
 
6
 
7
  # Create non-root user
8
  RUN useradd -m -u 1000 user
 
 
 
9
 
10
  # Set working directory
11
  WORKDIR /app
 
13
  # Clone GitHub repo into /app
14
  RUN git clone https://github.com/Mekhlafi98/solverai.git -b develop2 /app
15
 
16
+ # Set environment variables for runtime
17
+ ENV PATH="/home/user/.local/bin:$PATH" \
18
+ OCR_API_TOKEN=${OCR_API_TOKEN} \
 
 
 
19
  GOOGLE_API_KEY=${GOOGLE_API_KEY} \
20
  TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} \
21
  MODEL_NAME=gemini-1.5-flash \
 
22
  ALLOWED_HOSTS=localhost,127.0.0.1,azeez98-solveai.hf.space
23
 
24
+ # Install Python dependencies
25
+ RUN pip install --no-cache-dir --upgrade pip gunicorn && \
26
+ pip install --no-cache-dir -r requirements.txt
27
+
28
+ # Collect static files (run this as root, since you may need write access to the files)
29
+ USER root
30
  RUN python manage.py collectstatic --noinput
31
 
32
  # Copy NGINX config
33
  COPY nginx/default.conf /etc/nginx/conf.d/default.conf
34
 
35
+ # Create static and media directories
36
  RUN mkdir -p /app/static /app/media
37
 
38
+ # Change ownership of the app files to the 'user' user
39
+ RUN chown -R user:user /app
40
+
41
+ # Switch back to the non-root user
42
+ USER user
43
+
44
+ # Copy the start script
45
  COPY start.sh /start.sh
 
46
 
47
+ # Ensure the script is executable
48
+ RUN chmod +x /start.sh # Ensure it has execute permissions
49
 
50
+ # Run the start script
51
+ CMD ["/start.sh"]
52
 
53
+ # Expose port for the app
54
+ EXPOSE 7860