Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions advanced/flask/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.12-slim-bookworm
WORKDIR /app
COPY . .
RUN apt-get update && apt-get install -y gcc python3-dev && rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN useradd -m appuser
RUN chown appuser /app
USER appuser
Comment on lines +7 to +9
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Make ownership change recursive.
Line 8 only changes /app itself, not its contents. Replace with:

RUN useradd -m appuser \
 && chown -R appuser:appuser /app

Ensures appuser can read/write everything under /app.

🤖 Prompt for AI Agents
In advanced/flask/Dockerfile lines 7 to 9, the chown command changes ownership
of /app directory only, not its contents. Modify the chown command to be
recursive by adding the -R flag and specify the group as well, changing it to
"chown -R appuser:appuser /app". Also combine the useradd and chown commands
into a single RUN instruction joined by && for efficiency.

CMD ["python3","app.py"]