BinaryONe commited on
Commit
22ecfe9
·
1 Parent(s): 2efa064

Nginx Changes-Over Alpine

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -12
Dockerfile CHANGED
@@ -5,36 +5,34 @@ 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
6
 
7
  # Create a group and user
8
- RUN addgroup -S nginx && adduser -S -G nginx appuser
9
-
10
- # Create necessary directories and set correct permissions (CRUCIAL FIX)
11
- RUN mkdir -p /var/www/html /var/log/nginx /run/nginx && \
12
- chown -R nginx:nginx /var/lib/nginx /var/log/nginx /run/nginx && \
13
- chown -R appuser:nginx /app /var/www/html
14
 
15
  # Set working directory
16
  WORKDIR /app
17
 
18
- # Copy requirements and install
19
  COPY requirements.txt /app/
20
  RUN python3 -m venv /app/venv && \
21
  /app/venv/bin/pip install --no-cache-dir --upgrade pip && \
22
  /app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
23
- /app/venv/bin/pip list
24
 
25
  # Copy the rest of the application code
26
  COPY . /app
27
 
28
- # Copy Nginx config (default.conf - WITHOUT the http block)
29
  COPY nginx.conf /etc/nginx/conf.d/default.conf
30
 
31
- # Remove the user directive from the main nginx.conf
32
- RUN sed -i '/^user /d' /etc/nginx/nginx.conf
 
 
 
33
 
34
  # Switch to non-root user
35
  USER appuser
36
 
37
  EXPOSE 7860
38
 
39
- # Start Nginx and your application
40
  CMD ["sh", "-c", "exec /app/venv/bin/python -u -m FileStream & nginx -g 'daemon off;'"]
 
5
  apk add --no-cache nginx python3 python3-dev py3-pip build-base libffi-dev openssl-dev shadow gcc musl-dev ca-certificates
6
 
7
  # Create a group and user
8
+ RUN addgroup -S appgroup && adduser -S appuser -G appgroup
 
 
 
 
 
9
 
10
  # Set working directory
11
  WORKDIR /app
12
 
13
+ # Copy requirements and install in ONE combined RUN command
14
  COPY requirements.txt /app/
15
  RUN python3 -m venv /app/venv && \
16
  /app/venv/bin/pip install --no-cache-dir --upgrade pip && \
17
  /app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
18
+ /app/venv/bin/pip list # Verify installation WITHIN THE SAME RUN COMMAND
19
 
20
  # Copy the rest of the application code
21
  COPY . /app
22
 
23
+ # Copy Nginx config
24
  COPY nginx.conf /etc/nginx/conf.d/default.conf
25
 
26
+ # Create necessary directories and set correct permissions
27
+ RUN mkdir -p /var/www/html /var/log/nginx /run/nginx && \
28
+ chown -R nginx:nginx /var/lib/nginx /var/log/nginx /run/nginx && \
29
+ # Note the /var/lib/nginx here
30
+ chown -R appuser:nginx /app /var/www/html /var/log/nginx
31
 
32
  # Switch to non-root user
33
  USER appuser
34
 
35
  EXPOSE 7860
36
 
37
+ # Start Nginx and your application (using exec and the correct Python path)
38
  CMD ["sh", "-c", "exec /app/venv/bin/python -u -m FileStream & nginx -g 'daemon off;'"]