BinaryONe commited on
Commit
ddcc562
·
1 Parent(s): c428c38

Nginx Changes-Over Alpine

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -28
Dockerfile CHANGED
@@ -2,16 +2,14 @@ FROM alpine:latest
2
 
3
  # Install system dependencies
4
  RUN apk update && apk upgrade && \
5
- apk add --no-cache nginx python3 python3-dev py3-pip build-base libffi-dev openssl-dev shadow gcc musl-dev ca-certificates sudo openrc
6
 
7
  # Create a group and user
8
  RUN addgroup -S appgroup && adduser -S appuser -G appgroup
9
 
10
- # Add appuser to the sudoers file (allowing all commands without password)
11
- RUN echo "appuser ALL=(ALL:ALL) ALL" >> /etc/sudoers
12
-
13
- # Add appuser to the sudoers file (allowing all commands without password)
14
- RUN echo "nginx ALL=(ALL:ALL) ALL" >> /etc/sudoers
15
 
16
  # Set working directory
17
  WORKDIR /app
@@ -21,42 +19,29 @@ COPY requirements.txt /app/
21
  RUN python3 -m venv /app/venv && \
22
  /app/venv/bin/pip install --no-cache-dir --upgrade pip && \
23
  /app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
24
- /app/venv/bin/pip list # Verify installation WITHIN THE SAME RUN COMMAND
 
25
 
26
  # Copy the rest of the application code
27
  COPY . /app
28
 
29
  # Copy Nginx config
30
  COPY www.privateone-teleapi.hf.space.conf /etc/nginx/conf.d/www.privateone-teleapi.hf.space.conf
31
- #COPY nginx.conf /etc/nginx/nginx.conf
32
-
33
 
34
- #RUN service nginx start
35
- #RUN touch /var/lib/nginx/logs/error.log && \
36
- # chmod 777 /var/lib/nginx/logs/error.log
37
-
38
- # Create necessary directories and set correct permissions
39
  RUN mkdir -p /var/www/html /var/log/nginx /run/nginx && \
40
- chown -R nginx:nginx /var/lib/nginx /var/log/nginx /run/nginx && \
41
- # Note the /var/lib/nginx here
42
- chown -R appuser:nginx /app /var/www/html /var/log/nginx
43
 
44
- # Remove the user directive from the main nginx.conf
45
  #RUN sed -i '/^user /d' /etc/nginx/nginx.conf
46
 
47
- # Print the configuration files to the console (NEW)
48
  RUN cat /etc/nginx/nginx.conf && echo "--------------------"
49
- # && cat /etc/nginx/conf.d/default.conf
50
-
51
 
52
  # Switch to non-root user
53
  USER appuser
54
 
55
- #RUN /etc/init.d/nginx status
56
-
57
-
58
- EXPOSE 7860
59
-
60
  # Start Nginx and your application (using exec and the correct Python path)
61
- #CMD ["sh", "-c", "exec /app/venv/bin/python -u -m FileStream & nginx -g 'daemon off;'"]
62
- CMD ["sh", "-c", "rc-service nginx start && exec /app/venv/bin/python -u -m FileStream"]
 
2
 
3
  # Install system dependencies
4
  RUN apk update && apk upgrade && \
5
+ apk add --no-cache nginx python3 python3-dev py3-pip build-base libffi-dev openssl-dev shadow gcc musl-dev ca-certificates openrc
6
 
7
  # Create a group and user
8
  RUN addgroup -S appgroup && adduser -S appuser -G appgroup
9
 
10
+ # Remove sudoers entries (highly recommended)
11
+ #RUN echo "appuser ALL=(ALL:ALL) ALL" >> /etc/sudoers
12
+ #RUN echo "nginx ALL=(ALL:ALL) ALL" >> /etc/sudoers
 
 
13
 
14
  # Set working directory
15
  WORKDIR /app
 
19
  RUN python3 -m venv /app/venv && \
20
  /app/venv/bin/pip install --no-cache-dir --upgrade pip && \
21
  /app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
22
+ /app/venv/bin/pip list
23
+ # Verify installation WITHIN THE SAME RUN COMMAND
24
 
25
  # Copy the rest of the application code
26
  COPY . /app
27
 
28
  # Copy Nginx config
29
  COPY www.privateone-teleapi.hf.space.conf /etc/nginx/conf.d/www.privateone-teleapi.hf.space.conf
 
 
30
 
31
+ # Create necessary directories and set correct permissions (fix ownership)
 
 
 
 
32
  RUN mkdir -p /var/www/html /var/log/nginx /run/nginx && \
33
+ chown -R nginx:nginx /var/lib/nginx /var/log/nginx /run/nginx && \
34
+ chown -R appuser:appgroup /app /var/www/html # Fix ownership here
 
35
 
36
+ # Remove the user directive from the main nginx.conf (not needed)
37
  #RUN sed -i '/^user /d' /etc/nginx/nginx.conf
38
 
39
+ # Print the configuration files to the console (good addition)
40
  RUN cat /etc/nginx/nginx.conf && echo "--------------------"
41
+ # && cat /etc/nginx/conf.d/default.conf
 
42
 
43
  # Switch to non-root user
44
  USER appuser
45
 
 
 
 
 
 
46
  # Start Nginx and your application (using exec and the correct Python path)
47
+ CMD ["sh", "-c", "rc-service nginx -s reload && exec /app/venv/bin/python -u -m FileStream"]