Spaces:
Running
Running
BinaryONe
commited on
Commit
·
6bf6112
1
Parent(s):
92edd0d
Nginx Changes-Over Alpine
Browse files- Dockerfile +23 -38
Dockerfile
CHANGED
@@ -1,49 +1,34 @@
|
|
1 |
-
FROM
|
2 |
|
3 |
-
#
|
4 |
-
RUN
|
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 |
-
#
|
8 |
-
#RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
9 |
-
RUN adduser -D -g 'user' user
|
10 |
-
|
11 |
-
# Set working directory
|
12 |
WORKDIR /app
|
13 |
|
14 |
-
# Copy
|
15 |
-
COPY requirements.txt /app/
|
16 |
-
RUN python3 -m venv /app/venv && \
|
17 |
-
/app/venv/bin/pip install --no-cache-dir --upgrade pip && \
|
18 |
-
/app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
|
19 |
-
/app/venv/bin/pip list
|
20 |
-
# Verify installation WITHIN THE SAME RUN COMMAND
|
21 |
-
|
22 |
-
# Copy the rest of the application code
|
23 |
-
COPY . /app
|
24 |
|
25 |
-
#
|
26 |
-
RUN
|
|
|
|
|
|
|
27 |
|
28 |
-
#
|
29 |
-
|
30 |
-
COPY nginx.conf /etc/nginx/nginx.conf
|
31 |
|
32 |
-
#
|
33 |
-
|
34 |
-
# && cat /etc/nginx/conf.d/default.conf
|
35 |
|
36 |
-
#
|
37 |
-
RUN
|
38 |
-
chown -R nginx:nginx /var/lib/nginx /var/log/nginx /run/nginx && \
|
39 |
-
chown -R user:user /app /var/www/html /var/lib/nginx && chmod -R 777 /app
|
40 |
|
41 |
-
#
|
42 |
-
|
43 |
|
44 |
-
#
|
45 |
-
|
46 |
|
47 |
-
#
|
48 |
-
CMD ["
|
49 |
-
#&& exec /app/venv/bin/python -u -m FileStream
|
|
|
1 |
+
FROM python:3.11
|
2 |
|
3 |
+
# Create and use a non-root user
|
4 |
+
RUN useradd -ms /bin/bash admin
|
|
|
5 |
|
6 |
+
# Set working directory for the application
|
|
|
|
|
|
|
|
|
7 |
WORKDIR /app
|
8 |
|
9 |
+
# Copy only the necessary files first for better cache utilization
|
10 |
+
COPY requirements.txt /app/requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
# Install system dependencies and clean up in a single RUN step to reduce layers
|
13 |
+
RUN apt-get update -y && apt-get upgrade -y \
|
14 |
+
&& apt-get install -y \
|
15 |
+
&& apt-get clean \
|
16 |
+
&& rm -rf /var/lib/apt/lists/*
|
17 |
|
18 |
+
# Install Python dependencies from the requirements file
|
19 |
+
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
|
|
20 |
|
21 |
+
# Copy the rest of the application code after installing dependencies for better cache
|
22 |
+
COPY . /app
|
|
|
23 |
|
24 |
+
# Set ownership and permissions for the app directory
|
25 |
+
RUN chown -R admin:admin /app && chmod -R 777 /app
|
|
|
|
|
26 |
|
27 |
+
# Switch to the non-root user for better security
|
28 |
+
USER admin
|
29 |
|
30 |
+
# Expose the port the application will run on
|
31 |
+
EXPOSE 7860
|
32 |
|
33 |
+
# Command to run the application
|
34 |
+
CMD ["python", "-u", "-m", "FileStream"]
|
|