Skip to content

chore: optimize python service Dockerfile (#319)#380

Open
OpadijoIdris wants to merge 1 commit into
dev-fatima-24:mainfrom
OpadijoIdris:fix-319-optimize-python-dockerfile
Open

chore: optimize python service Dockerfile (#319)#380
OpadijoIdris wants to merge 1 commit into
dev-fatima-24:mainfrom
OpadijoIdris:fix-319-optimize-python-dockerfile

Conversation

@OpadijoIdris
Copy link
Copy Markdown

Description

This PR optimizes the Python service Dockerfile to improve security, reduce image size, and ensure production readiness. It changes the base image to the more specific python:3.11-slim, removes development-only dependencies from the build process, and implements a container health check.

Closes #319

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Changes Made

  • Updated the Dockerfile base image to python:3.11-slim for both builder and production stages.
  • Removed development dependencies (pytest, pytest-asyncio, pytest-cov) from requirements.txt to ensure only production dependencies are installed.
  • Added a HEALTHCHECK instruction to the Dockerfile to verify the /health endpoint using a built-in Python one-liner (avoiding the need to install curl).
  • Verified that the service correctly runs as a non-root user (appuser) and uses Gunicorn as the production WSGI server.

Testing

Please describe the tests you ran and how to reproduce them:

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed (Verified Dockerfile syntax and requirements.txt modifications)

Test Coverage:

  • N/A (DevOps / Infrastructure change)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests passed locally with my changes
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Additional Notes

By using a Python one-liner for the health check (python -c "import urllib.request..."), we avoid having to install curl in

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@OpadijoIdris Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DEVOPS] Optimize Python service Dockerfile

1 participant