Skip to content

feat: enhance Dockerfile security and add .dockerignore (#843)#844

Open
Aryanbansal-05 wants to merge 1 commit into
komalharshita:mainfrom
Aryanbansal-05:Aryan-05-3
Open

feat: enhance Dockerfile security and add .dockerignore (#843)#844
Aryanbansal-05 wants to merge 1 commit into
komalharshita:mainfrom
Aryanbansal-05:Aryan-05-3

Conversation

@Aryanbansal-05

Copy link
Copy Markdown
Contributor
  • Add PYTHONDONTWRITEBYTECODE and PYTHONUNBUFFERED env vars
  • Create non-root appuser for least-privilege execution
  • Add .dockerignore to exclude venv, cache, git, IDE files

Summary [required]

This PR enhances the existing Dockerfile with security and optimization best practices, and adds a .dockerignore file to reduce the Docker build context. The container now runs as a non-root user, Python runtime is configured for cleaner container behavior, and unnecessary files like venv, pycache, and .git are excluded from builds. No application logic is affected.

Related Issue [required]

Closes #843

Type of Change [required]

  • Feature — adds new functionality

What Was Changed [required]

| File | Change made |
Dockerfile | Added PYTHONDONTWRITEBYTECODE and PYTHONUNBUFFERED env vars; added non-root appuser for least-privilege execution
.dockerignore | Created new file to exclude git metadata, Python cache, venv, IDE files, and OS artifacts from build context

How to Test This PR [required]

  1. Clone this branch: git checkout your-branch-name
  2. Install dependencies: pip install -r requirements.txt
  3. Run the app: python app.py
  4. Open http://127.0.0.1:5000 and...
  5. Run the tests: python tests/test_basic.py

Expected test output:

27 passed, 0 failed out of 27 tests

Test Results [required]

56 passed in 0.37s
Note: 16 pre-existing failures are unrelated to this PR (tracked in #834 ).
This PR only modifies Dockerfile and .dockerignore — no Python code changed.

Self-Review Checklist [required]

  • I have read CONTRIBUTING.md and followed all guidelines
  • My branch name follows the convention: feat/, fix/, docs/, data/, style/, test/
  • I have run python tests/test_basic.py and all 27 tests pass
  • I have run flake8 . locally and there are no errors
  • I have not introduced any print() or console.log() debug statements
  • Every new function I wrote has a docstring
  • I have not modified files outside the scope of the linked issue
  • If I changed the UI, I tested it at 375px (mobile) and 1280px (desktop)
  • If I added a project to the dataset, it has all required JSON fields

Notes for Reviewer

The 16 test failures visible in the test output are pre-existing issues unrelated to this PR and are being addressed separately in PR #834. This PR touches only Dockerfile and .dockerignore and has zero impact on application behavior.

…a#843)

- Add PYTHONDONTWRITEBYTECODE and PYTHONUNBUFFERED env vars
- Create non-root appuser for least-privilege execution
- Add .dockerignore to exclude venv, cache, git, IDE files
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

@Aryanbansal-05 is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Aryanbansal-05

Copy link
Copy Markdown
Contributor Author

The CI test failures are pre-existing issues caused by a broken import in test_basic.py (WEIGHT_LEVEL not found in utils.recommender). These are unrelated to this PR and are already fixed in PR #834. This PR only modifies Dockerfile and .dockerignore with no impact on application code or tests.

@Aryanbansal-05

Copy link
Copy Markdown
Contributor Author

Hi @komalharshita,
Just a friendly nudge — this PR has been open for a few days and just needs a review and merge whenever you have a moment. The failing CI checks are due to the pre-existing test import issue covered in PR #834, not related to these Docker changes. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]:Enhance Dockerfile security and add .dockerignore for optimized container builds

1 participant