File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11FROM python:3.13-slim
22
3+ # Create a non-root user and group
4+ RUN groupadd -r appgroup && useradd -r -m -g appgroup appuser
5+
36# Set working dir as /app inside the container
47WORKDIR /app
58
69# Copy the rates/requirements.txt.lock to the container
710COPY ./rates/requirements.txt.lock /app
811
12+ # Install dependencies as root
913RUN pip install --no-cache-dir gunicorn==21.2.0 && \
1014 pip install --no-cache-dir -r requirements.txt.lock
1115
1216# Copy the application code
1317COPY ./rates /app
1418
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+
1525# Make port 3000 available to the world outside this container
1626EXPOSE 3000
1727
1828# Define environment variables
1929ENV PYTHONUNBUFFERED 1
2030
21- # Run Gunicorn with your application
31+ # Run Gunicorn with your application as appuser
2232CMD gunicorn -b :3000 wsgi
You can’t perform that action at this time.
0 commit comments