Update Dockerfile
Browse files- Dockerfile +14 -17
Dockerfile
CHANGED
@@ -1,19 +1,17 @@
|
|
1 |
# Base image
|
2 |
FROM python:3.12
|
3 |
|
4 |
-
#
|
5 |
-
|
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
|
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
|
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
|
43 |
COPY start.sh /start.sh
|
|
|
44 |
|
45 |
-
#
|
46 |
-
|
47 |
-
chmod +x /start.sh
|
48 |
|
49 |
-
#
|
50 |
-
|
51 |
|
52 |
-
#
|
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"]
|