KunalThakare279 commited on
Commit
4af3521
·
verified ·
1 Parent(s): fd36cb3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -21
Dockerfile CHANGED
@@ -3,36 +3,30 @@ FROM python:${PYTHON_VERSION}-slim as base
3
 
4
  # Prevents Python from writing pyc files.
5
  ENV PYTHONDONTWRITEBYTECODE=1
6
-
7
  ENV PYTHONUNBUFFERED=1
8
 
 
 
 
 
9
  WORKDIR /app
10
 
11
- # ARG UID=10001
12
- # RUN adduser \
13
- # --disabled-password \
14
- # --gecos "" \
15
- # --home "/nonexistent" \
16
- # --shell "/sbin/nologin" \
17
- # --no-create-home \
18
- # --uid "${UID}" \
19
- # appuser
20
 
 
 
21
 
22
- # Switch to the non-privileged user to run the application.
23
- # USER appuser
24
 
25
- # Copy the source code into the container.
26
- COPY . .
27
- COPY . .env
28
 
29
- RUN python -m pip install -r requirements.txt
30
- # --mount=type=bind,source=requirements.txt,target=requirements.txt \
31
-
32
- # Expose the port that the application listens on.
33
  EXPOSE 8000
34
 
35
-
36
- # Run the application.
37
  ENTRYPOINT ["gunicorn", "app:app"]
38
  CMD ["-b", "0.0.0.0:7860"]
 
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
+ COPY .env .
 
 
 
 
 
 
17
 
18
+ # Change ownership of the application files
19
+ RUN chown -R appuser:appgroup /app
20
 
21
+ # Switch to the non-privileged user to run the application
22
+ USER appuser
23
 
24
+ # Install dependencies
25
+ RUN python -m pip install --no-cache-dir -r requirements.txt
 
26
 
27
+ # Expose the port that the application listens on
 
 
 
28
  EXPOSE 8000
29
 
30
+ # Run the application
 
31
  ENTRYPOINT ["gunicorn", "app:app"]
32
  CMD ["-b", "0.0.0.0:7860"]