Azeez98 commited on
Commit
70115d2
·
verified ·
1 Parent(s): ab0534e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -17
Dockerfile CHANGED
@@ -1,19 +1,17 @@
1
  # Base image
2
  FROM python:3.12
3
 
4
- # Avoid cache for git clone by using build args (change the value to bust cache)
5
- ARG CACHEBUST=1
6
-
7
- # Install Nginx
8
- RUN apt-get update && apt-get install -y nginx
9
 
10
  # Create non-root user
11
- RUN useradd -m -u 1000 user
 
12
 
13
  # Set working directory
14
  WORKDIR /app
15
 
16
- # Clone GitHub repo into /app
17
  RUN git clone https://github.com/Mekhlafi98/solverai.git -b develop2 /app
18
 
19
  # Install Python dependencies
@@ -29,25 +27,24 @@ ENV PATH="/home/user/.local/bin:$PATH" \
29
  ALLOWED_HOSTS=localhost,127.0.0.1,azeez98-solveai.hf.space
30
 
31
  # Collect static files
32
- USER root
33
  RUN python manage.py collectstatic --noinput
34
 
35
- # Copy NGINX config
36
  COPY nginx/default.conf /etc/nginx/conf.d/default.conf
37
 
38
- # Create necessary directories for Nginx (with proper permissions)
39
  RUN mkdir -p /var/lib/nginx/body /var/log/nginx /app/static /app/media && \
40
  chown -R user:user /var/lib/nginx /var/log/nginx /app
41
 
42
- # Copy the start script
43
  COPY start.sh /start.sh
 
44
 
45
- # Ensure proper line endings and permissions
46
- RUN sed -i 's/\r$//' /start.sh && \
47
- chmod +x /start.sh
48
 
49
- # Expose ports (Nginx on 80, Gunicorn on 7860)
50
- EXPOSE 80 7860
51
 
52
- # Run the start script using shell form
53
  CMD ["/bin/bash", "/start.sh"]
 
1
  # Base image
2
  FROM python:3.12
3
 
4
+ # Install Nginx and sudo (needed for Hugging Face Spaces)
5
+ RUN apt-get update && apt-get install -y nginx sudo
 
 
 
6
 
7
  # Create non-root user
8
+ RUN useradd -m -u 1000 user && \
9
+ echo "user ALL=(root) NOPASSWD: /usr/sbin/nginx" >> /etc/sudoers
10
 
11
  # Set working directory
12
  WORKDIR /app
13
 
14
+ # Clone GitHub repo
15
  RUN git clone https://github.com/Mekhlafi98/solverai.git -b develop2 /app
16
 
17
  # Install Python dependencies
 
27
  ALLOWED_HOSTS=localhost,127.0.0.1,azeez98-solveai.hf.space
28
 
29
  # Collect static files
 
30
  RUN python manage.py collectstatic --noinput
31
 
32
+ # Copy NGINX config (modified for Hugging Face)
33
  COPY nginx/default.conf /etc/nginx/conf.d/default.conf
34
 
35
+ # Create necessary directories
36
  RUN mkdir -p /var/lib/nginx/body /var/log/nginx /app/static /app/media && \
37
  chown -R user:user /var/lib/nginx /var/log/nginx /app
38
 
39
+ # Copy start script
40
  COPY start.sh /start.sh
41
+ RUN chmod +x /start.sh
42
 
43
+ # Use port 8080 instead of 80 for Hugging Face
44
+ EXPOSE 8080
 
45
 
46
+ # Run as non-root user by default
47
+ USER user
48
 
49
+ # Start command for Hugging Face
50
  CMD ["/bin/bash", "/start.sh"]