From 2126808cee54a2fa938d0cd029eb49beedba3c1e Mon Sep 17 00:00:00 2001 From: Maxim Shulga Date: Sun, 2 Aug 2026 16:23:04 -0700 Subject: [PATCH] Trim the build context and drop unused imports Add a .dockerignore that whitelists only requirements.txt, start.py and dsc/. The build context previously included .git, .idea, __pycache__ and any local .env, which slowed builds and put a secrets file within reach of any future COPY of the whole tree. Remove the unused urlparse import from dsc/client.py and the redundant import os.path from start.py; importing os already binds os.path. Record both in IMPROVEMENTS.md, including the part still outstanding: binutils and squashfs-tools remain in the runtime image because the AppImage is unpacked in the same stage. Co-Authored-By: Claude Opus 5 --- .dockerignore | 9 +++++++++ IMPROVEMENTS.md | 8 ++++++-- dsc/client.py | 1 - start.py | 1 - 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8a028b9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +# Only requirements.txt, dsc/ and start.py belong in the build context. +* +!requirements.txt +!start.py +!dsc/ + +# Keep local artifacts out even though dsc/ is re-included above. +dsc/**/__pycache__/ +dsc/**/*.py[cod] diff --git a/IMPROVEMENTS.md b/IMPROVEMENTS.md index 7143150..a2602c5 100644 --- a/IMPROVEMENTS.md +++ b/IMPROVEMENTS.md @@ -171,10 +171,14 @@ Acceptance criteria: - [ ] Separate configuration, subprocess execution, library resolution, and status monitoring so each can be tested independently. -- [ ] Remove unused imports and unnecessary dependencies. +- [x] Remove unused imports and unnecessary dependencies. Both pinned + requirements are used; `urllib3` is imported directly but only pinned + transitively through `requests`. - [ ] Add type annotations and static checks at external-input boundaries. - [ ] Make logging configurable and avoid forced dependency debug logs. -- [ ] Add `.dockerignore` and reduce unnecessary image packages. +- [ ] Add `.dockerignore` and reduce unnecessary image packages. `.dockerignore` + is in place; `binutils` and `squashfs-tools` are still shipped in the final + image because the AppImage is unpacked in the same stage. ### Establish a visible maintenance process diff --git a/dsc/client.py b/dsc/client.py index 6de560a..f91117b 100644 --- a/dsc/client.py +++ b/dsc/client.py @@ -4,7 +4,6 @@ import os import subprocess import time from typing import Optional -from urllib.parse import urlparse from cached_property import cached_property_with_ttl import requests diff --git a/start.py b/start.py index 8990974..9406c93 100755 --- a/start.py +++ b/start.py @@ -3,7 +3,6 @@ import argparse import logging import os -import os.path import sys from dsc import SeafileClient, const