File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
FROM python:3.13-slim
2
2
3
+ # Create a non-root user and group
4
+ RUN groupadd -r appgroup && useradd -r -m -g appgroup appuser
5
+
3
6
# Set working dir as /app inside the container
4
7
WORKDIR /app
5
8
6
9
# Copy the rates/requirements.txt.lock to the container
7
10
COPY ./rates/requirements.txt.lock /app
8
11
12
+ # Install dependencies as root
9
13
RUN pip install --no-cache-dir gunicorn==21.2.0 && \
10
14
pip install --no-cache-dir -r requirements.txt.lock
11
15
12
16
# Copy the application code
13
17
COPY ./rates /app
14
18
19
+ # Set the correct ownership of the /app folder to the appuser
20
+ RUN chown -R appuser:appgroup /app
21
+
22
+ # Switch to the non-root user for security
23
+ USER appuser
24
+
15
25
# Make port 3000 available to the world outside this container
16
26
EXPOSE 3000
17
27
18
28
# Define environment variables
19
29
ENV PYTHONUNBUFFERED 1
20
30
21
- # Run Gunicorn with your application
31
+ # Run Gunicorn with your application as appuser
22
32
CMD gunicorn -b :3000 wsgi
You can’t perform that action at this time.
0 commit comments