File size: 1,992 Bytes
cc4f142
 
42d9b14
ee5b6f2
ddcc562
7bdea2a
151fb06
7601e69
 
151fb06
ddcc562
 
 
8e35bdc
42d9b14
e566133
4d957e1
22ecfe9
42d9b14
491fb27
 
42d9b14
ddcc562
 
8ba973d
42d9b14
 
8ba973d
5b3b248
 
 
 
 
 
 
22ecfe9
1b09b20
c8fbd81
8e35bdc
ddcc562
22ecfe9
ddcc562
1b09b20
b9dcb4f
ddcc562
f2d4829
 
42d9b14
5b3b248
b9dcb4f
22ecfe9
5b3b248
 
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
49
50
51
52
53
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

#You may want to make backup of original nginx.conf file before writting your own
RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig

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

# Copy Nginx config
#COPY www.privateone-teleapi.hf.space.conf /etc/nginx/conf.d/www.privateone-teleapi.hf.space.conf
COPY /app/nginx-new.conf /etc/nginx/nginx.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

# Switch to non-root user
USER user

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