Spaces:
Running
Running
BinaryONe
commited on
Commit
·
bff3c88
1
Parent(s):
36ed694
Nginx Changes-Over Alpine
Browse files- Dockerfile +8 -31
Dockerfile
CHANGED
@@ -1,16 +1,11 @@
|
|
1 |
FROM alpine:latest
|
2 |
|
3 |
-
# Install system dependencies
|
4 |
RUN apk update && apk upgrade && \
|
5 |
-
apk add --no-cache nginx python3 py3-pip build-base libffi-dev openssl-dev
|
6 |
-
|
7 |
-
|
8 |
-
# Create and use a non-root user
|
9 |
-
RUN useradd -ms /bin/bash appuser
|
10 |
-
|
11 |
-
# Create a non-root user and group
|
12 |
-
RUN addgroup appgroup && adduser -G appgroup appuser
|
13 |
|
|
|
|
|
14 |
|
15 |
# Set working directory for the application
|
16 |
WORKDIR /app
|
@@ -18,12 +13,6 @@ WORKDIR /app
|
|
18 |
# Copy only the necessary files first for better cache utilization
|
19 |
COPY requirements.txt /app/requirements.txt
|
20 |
|
21 |
-
# Install system dependencies and clean up in a single RUN step to reduce layers
|
22 |
-
#RUN apt-get update -y && apt-get upgrade -y \
|
23 |
-
# && apt-get install -y \
|
24 |
-
# && apt-get clean \
|
25 |
-
# && rm -rf /var/lib/apt/lists/*
|
26 |
-
|
27 |
# Install Python dependencies from the requirements file
|
28 |
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
29 |
|
@@ -32,25 +21,13 @@ COPY . /app
|
|
32 |
|
33 |
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
34 |
|
35 |
-
|
36 |
-
|
37 |
RUN chown -R appuser:appgroup /app
|
38 |
|
|
|
39 |
USER appuser
|
40 |
|
41 |
EXPOSE 7860
|
42 |
|
43 |
-
# Start Nginx and the AIOHTTP app
|
44 |
-
CMD ["sh", "-c", "python -u -m FileStream & nginx -g 'daemon off;'"]
|
45 |
-
|
46 |
-
# Set ownership and permissions for the app directory
|
47 |
-
#RUN chown -R admin:admin /app && chmod -R 777 /app
|
48 |
-
|
49 |
-
# Switch to the non-root user for better security
|
50 |
-
#USER admin
|
51 |
-
|
52 |
-
# Expose the port the application will run on
|
53 |
-
#EXPOSE 7860
|
54 |
-
|
55 |
-
# Command to run the application
|
56 |
-
#CMD ["python", "-u", "-m", "FileStream"]
|
|
|
1 |
FROM alpine:latest
|
2 |
|
3 |
+
# Install system dependencies, including shadow-utils for adduser
|
4 |
RUN apk update && apk upgrade && \
|
5 |
+
apk add --no-cache nginx python3 py3-pip build-base libffi-dev openssl-dev shadow-utils
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
# Create a non-root user and group (Corrected and Simplified)
|
8 |
+
RUN addgroup appgroup && adduser -G appgroup -s /bin/sh appuser
|
9 |
|
10 |
# Set working directory for the application
|
11 |
WORKDIR /app
|
|
|
13 |
# Copy only the necessary files first for better cache utilization
|
14 |
COPY requirements.txt /app/requirements.txt
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Install Python dependencies from the requirements file
|
17 |
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
18 |
|
|
|
21 |
|
22 |
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
23 |
|
24 |
+
# Set ownership of the app directory
|
|
|
25 |
RUN chown -R appuser:appgroup /app
|
26 |
|
27 |
+
# Switch to the non-root user
|
28 |
USER appuser
|
29 |
|
30 |
EXPOSE 7860
|
31 |
|
32 |
+
# Start Nginx and the AIOHTTP app (using exec for proper signal handling)
|
33 |
+
CMD ["sh", "-c", "exec python -u -m FileStream & nginx -g 'daemon off;'"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|