Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +8 -10
Dockerfile
CHANGED
@@ -1,28 +1,26 @@
|
|
1 |
-
|
2 |
-
FROM python:${PYTHON_VERSION}-slim as base
|
3 |
|
4 |
-
#
|
5 |
-
ENV PYTHONDONTWRITEBYTECODE=1
|
6 |
-
ENV PYTHONUNBUFFERED=1
|
7 |
-
|
8 |
-
# Create a non-privileged user and group
|
9 |
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser
|
10 |
|
11 |
# Set the working directory
|
12 |
WORKDIR /app
|
13 |
|
14 |
-
# Copy the
|
15 |
COPY . .
|
16 |
|
17 |
# Change ownership of the application files
|
18 |
RUN chown -R appuser:appgroup /app
|
19 |
|
20 |
-
# Switch to the non-
|
21 |
USER appuser
|
22 |
|
23 |
-
# Install dependencies
|
24 |
RUN python -m pip install --no-cache-dir -r requirements.txt
|
25 |
|
|
|
|
|
|
|
26 |
# Expose the port that the application listens on
|
27 |
EXPOSE 8000
|
28 |
|
|
|
1 |
+
FROM docker.io/library/python:3.10-slim@sha256:80619a5316afae7045a3c13371b0ee670f39bac46ea1ed35081d2bf91d6c3dbd
|
|
|
2 |
|
3 |
+
# Create a group and user
|
|
|
|
|
|
|
|
|
4 |
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser
|
5 |
|
6 |
# Set the working directory
|
7 |
WORKDIR /app
|
8 |
|
9 |
+
# Copy the application files
|
10 |
COPY . .
|
11 |
|
12 |
# Change ownership of the application files
|
13 |
RUN chown -R appuser:appgroup /app
|
14 |
|
15 |
+
# Switch to the non-root user
|
16 |
USER appuser
|
17 |
|
18 |
+
# Install Python dependencies
|
19 |
RUN python -m pip install --no-cache-dir -r requirements.txt
|
20 |
|
21 |
+
# Switch back to root to add commands that need root access
|
22 |
+
USER root
|
23 |
+
|
24 |
# Expose the port that the application listens on
|
25 |
EXPOSE 8000
|
26 |
|