File size: 1,811 Bytes
cc4f142
 
42d9b14
ee5b6f2
ddcc562
7bdea2a
151fb06
7601e69
 
151fb06
ddcc562
 
 
8e35bdc
42d9b14
e566133
4d957e1
22ecfe9
42d9b14
491fb27
 
42d9b14
ddcc562
 
8ba973d
42d9b14
 
8ba973d
22ecfe9
8e35bdc
 
ddcc562
22ecfe9
ddcc562
7601e69
b9dcb4f
ddcc562
f2d4829
 
ddcc562
c428c38
ddcc562
f2d4829
42d9b14
b9dcb4f
 
22ecfe9
ddcc562
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
FROM alpine:latest

# Install system dependencies
RUN apk update && apk upgrade && \
    apk add --no-cache nginx python3 python3-dev py3-pip build-base libffi-dev openssl-dev shadow gcc musl-dev ca-certificates openrc

# Create a group and user
#RUN addgroup -S appgroup && adduser -S appuser -G appgroup
RUN adduser -D -g 'user' user

# Remove sudoers entries (highly recommended)
#RUN echo "appuser ALL=(ALL:ALL) ALL" >> /etc/sudoers
#RUN echo "nginx ALL=(ALL:ALL) ALL" >> /etc/sudoers

# Set working directory
WORKDIR /app

# Copy requirements and install in ONE combined RUN command
COPY requirements.txt /app/
RUN python3 -m venv /app/venv && \
    /app/venv/bin/pip install --no-cache-dir --upgrade pip && \
    /app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
    /app/venv/bin/pip list 
    # Verify installation WITHIN THE SAME RUN COMMAND

# Copy the rest of the application code
COPY . /app

# Copy Nginx config
COPY www.privateone-teleapi.hf.space.conf /etc/nginx/conf.d/www.privateone-teleapi.hf.space.conf

# Create necessary directories and set correct permissions (fix ownership)
RUN mkdir -p /var/www/html /var/log/nginx /run/nginx && \
    chown -R nginx:nginx /var/lib/nginx /var/log/nginx /run/nginx && \
    chown -R user:user /app /var/www/html /var/lib/nginx  && chmod -R 777 /app

# Remove the user directive from the main nginx.conf (not needed)
#RUN sed -i '/^user /d' /etc/nginx/nginx.conf

# Print the configuration files to the console (good addition)
RUN cat /etc/nginx/nginx.conf && echo "--------------------" 
# && cat /etc/nginx/conf.d/default.conf 

# Switch to non-root user
USER appuser

# Start Nginx and your application (using exec and the correct Python path)
CMD ["sh", "-c", "rc-service nginx -s reload && exec /app/venv/bin/python -u -m FileStream"]