Summary
web/Dockerfile runs pip install --user, which installs packages into /root/.local instead of the system site-packages. When Python is invoked as python app.py (the CMD), packages installed to --user may not be on sys.path depending on the base image configuration, leading to ModuleNotFoundError at container startup.
Background
The --user flag is intended for non-root installs on shared machines where the user cannot write to system site-packages. Inside a Docker container running as root (the default), it adds unnecessary complexity and can cause import failures. The correct pattern is a plain pip install --no-cache-dir -r requirements.txt.
Affected Areas
Recommended Fix
# Before
RUN python3 -m pip install --user --no-cache-dir -r requirements.txt
# After
RUN pip install --no-cache-dir -r requirements.txt
Acceptance Criteria
Complexity Estimate
XS — single-line Dockerfile change.
Priority
Medium — may silently work on some base images but is incorrect practice and a latent failure risk.
Auto-identified by workspace issue-logger
Category: coding standards / style / linting
Complexity: XS
Repository: DewaldOosthuizen/python_rest_tutorial
Summary
web/Dockerfilerunspip install --user, which installs packages into/root/.localinstead of the system site-packages. When Python is invoked aspython app.py(the CMD), packages installed to--usermay not be onsys.pathdepending on the base image configuration, leading toModuleNotFoundErrorat container startup.Background
The
--userflag is intended for non-root installs on shared machines where the user cannot write to system site-packages. Inside a Docker container running as root (the default), it adds unnecessary complexity and can cause import failures. The correct pattern is a plainpip install --no-cache-dir -r requirements.txt.Affected Areas
web/Dockerfileline 8Recommended Fix
Acceptance Criteria
--userflag removed from Dockerfiledocker-compose build && docker-compose upsucceedscurl http://localhost:5000/helloreturnsHello World!Complexity Estimate
XS — single-line Dockerfile change.
Priority
Medium — may silently work on some base images but is incorrect practice and a latent failure risk.
Auto-identified by workspace issue-logger
Category: coding standards / style / linting
Complexity: XS
Repository: DewaldOosthuizen/python_rest_tutorial