KunalThakare279 commited on
Commit
6ff8367
·
verified ·
1 Parent(s): 084d0a1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -10
Dockerfile CHANGED
@@ -1,28 +1,26 @@
1
- ARG PYTHON_VERSION=3.10
2
- FROM python:${PYTHON_VERSION}-slim as base
3
 
4
- # Prevents Python from writing pyc files.
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 source code into the container
15
  COPY . .
16
 
17
  # Change ownership of the application files
18
  RUN chown -R appuser:appgroup /app
19
 
20
- # Switch to the non-privileged user to run the application
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