benispeti commented on issue #43002:
URL: https://github.com/apache/superset/issues/43002#issuecomment-5240639098

   > Hi [@benispeti](https://github.com/benispeti)! I'm 
[Dosu](https://go.dosu.dev/dosubot) and I'm helping the Apache Superset team.
   > 
   > Good catch. The Linux `-dev` packages you identified are indeed not 
strictly required for runtime in the production (`lean`) image. Here's what's 
happening:
   > 
   > **Root cause:** The `python-common` stage (shared by all final images) 
explicitly installs `libsasl2-dev`, `libpq-dev`, `libecpg-dev`, and 
`libldap2-dev` 
[[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/Dockerfile#L191-L197).
 These `-dev` packages pull in the other development packages you found 
(`libc6-dev`, `libpython3.11-dev`, `python3.11-dev`, `zlib1g-dev`, 
`linux-libc-dev`, etc.) as transitive APT dependencies. They are never cleaned 
up.
   > 
   > **Why `pip-install.sh` doesn't help:** The `--requires-build-essential` 
flag in 
[`pip-install.sh`](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/docker/pip-install.sh#L56-L62)
 correctly installs and removes `build-essential` around pip installs, but it 
doesn't touch these other `-dev` packages since they were explicitly installed 
in a prior stage.
   > 
   > **Are they needed at runtime?** No — none of the packages in 
`requirements/base.txt` (the lean image's dependency set) actually link against 
these libraries at runtime. `psycopg2-binary` (PostgreSQL) is only in the 
optional `postgres` extra, `python-ldap` is in the `development` extra, and 
`thrift_sasl` is in optional `hive`/`spark` extras. These `-dev` packages could 
be replaced with their runtime-only equivalents (e.g., `libpq5` instead of 
`libpq-dev`, `libsasl2-2` instead of `libsasl2-dev`) or removed entirely from 
the base image and added only where needed.
   > 
   > **Frontend packages (`devlop`, `preact-devtools`):** The `devlop` npm 
package is a transitive dependency in `package-lock.json` but should not end up 
in the compiled production bundle — the frontend build runs with 
`NODE_ENV=production` 
[[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/Dockerfile#L41)
 and webpack tree-shaking should exclude dev-only code from the final assets in 
`/app/superset/static/assets`. `preact-devtools` does not appear in the 
codebase source, so it may be a transitive dev dependency similarly excluded 
from the production bundle. These would show up in an SBOM scan of the full 
image filesystem (since `node_modules` from the build stage might be copied), 
but shouldn't be in the actual served JavaScript.
   > 
   > In summary, this looks like an optimization opportunity — the `-dev` 
packages in `python-common` appear to be there for convenience (supporting 
optional database driver compilation) rather than by strict necessity for the 
lean image.
   > 
   > _To reply, just mention 
[@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset)._
   > 
   > Docs are dead. Just use 
[Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset).
   > 
   > [![Leave 
Feedback](https://camo.githubusercontent.com/36dab98b8d4c28691f39c02dac135dc55eafb15d1194cd4c3280d181fde2f178/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c65617665253230466565646261636b2d3535353535353f7374796c653d666c6174)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=730abf11-4515-40e9-8f98-e9ad049dcde9)
 [![Ask Dosu about 
superset](https://camo.githubusercontent.com/477f2c05e0485aa6735d180e8d54c8f0a856dab2a644048e7a26228bd46f860f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f41736b253230446f737525323061626f757425323073757065727365742d3266376233663f7374796c653d666c6174266c6f676f3d64617461253341696d616765253246737667253242786d6c25334262617365363425324350484e325a79423361575230614430694f4459694947686c6157646f644430694f446b6949485a705a58644362336739496a41674d4341344e6941344f5349675a6d6c7362443069626d
 
39755a53496765473173626e4d39496d6830644841364c79393364336375647a4d7562334a6e4c7a49774d44417663335a6e496a3438634746306143426b50534a4e4e5334794f54497a4e6941784d6934334f544934544445334c6a63314f544d674e6934324f4445344f4659334d6934314e6a5933544455754d6a6b794d7a59674f4451754d4459784f4659784d6934334f544934576949675a6d6c736244306949304930516b49354d534976506a78775958526f49475139496b30784f4334794e5463314944637a4c6a45784f545a4d4e546b754d544d794f5341334d6934334e44684d4e5445754e7a41784d5341344d6934304d446b31544449354c6a417a4d7a67674f4459754d6a6b78544459754d6a4d354e6a49674f4455754d5455314e4577784f4334794e5463314944637a4c6a45784f545a614969426d615778735053496a4e7a63344e54597849693825324250484268644767675a443069545445334c6a51354d5459674d7934334d7a597a4d30777a4c6a55344e545533494445794c6a63774f546c574f444d754e5463354d6b4d7a4c6a55344e545533494467304c6a63314e4449674e4334354f4455324d7941344e53347a4e6a5579494455754f4451334d4455674f4451754e545932544445354c6a59794f5459674e7a45754e7a67774d5349676333527962327
 
46c50534a696247466a61794967633352796232746c4c5864705a48526f505349324c6a51794f4451304969427a64484a766132557462476c755a574e6863443069636d3931626d51694c7a34386257467a617942705a4430695a47397a6453316b4c574e3164473931644349675a6d6c73624430696432687064475569506a78775958526f49475a7062477774636e56735a5430695a585a6c626d396b5a43496759327870634331796457786c50534a6c646d56756232526b4969426b50534a4e4e4441754e7a4130494441754e5445344d445932534445334c6a41304d7a6c574e7a59754d6a49794d5567304d4334334d4452494e4449754e5467774e5567304e7934344d44457a517a59344c6a63774e6a51674e7a59754d6a49794d5341344e5334324e544d7a494455354c6a49334e5449674f4455754e6a557a4d79417a4f43347a4e7a4178517a67314c6a59314d7a4d674d5463754e445931494459344c6a63774e6a4d674d4334314d5467774e6a59674e4463754f4441784d7941774c6a55784f4441324e6b67304d6934314f444131534451774c6a63774e466f694c7a34384c32316863327325324250484268644767675a6d6c73624331796457786c50534a6c646d56756232526b4969426a62476c774c584a3162475539496d56325a5735765a47516949475139496b30
 
304d4334334d4451674d4334314d5467774e6a5a494d5463754d44517a4f5659334e6934794d6a4978534451774c6a63774e4567304d6934314f444131534451334c6a67774d544e444e6a67754e7a41324e4341334e6934794d6a4978494467314c6a59314d7a4d674e546b754d6a63314d6941344e5334324e544d7a49444d344c6a4d334d4446444f4455754e6a557a4d7941784e7934304e6a55674e6a67754e7a41324d7941774c6a55784f4441324e6941304e7934344d44457a494441754e5445344d445932534451794c6a55344d4456494e4441754e7a4130576949675a6d6c73624430694930597a526a5a474d534976506a78775958526f49475139496b30784e7934774e444d35494441754e5445344d445932566930324c6a55334f54453553446b754f5451324e6a6c574d4334314d5467774e6a5a494d5463754d44517a4f56704e4d5463754d44517a4f5341334e6934794d6a497853446b754f5451324e6a6c574f444d754d7a45354e4567784e7934774e444d35566a63324c6a49794d6a4661545445334c6a41304d7a6b674e7934324d54557a4d6b67304d4334334d4452574c5459754e5463354d546c494d5463754d44517a4f5659334c6a59784e544d79576b30794e4334784e444579494463324c6a49794d6a46574d4334314d5467774e6a5a494f5334354e4
 
459324f5659334e6934794d6a4978534449304c6a45304d544a61545451774c6a63774e4341324f5334784d6a5135534445334c6a41304d7a6c574f444d754d7a45354e4567304d4334334d4452574e6a6b754d5449304f56704e4e4449754e5467774e5341324f5334784d6a5135534451774c6a63774e4659344d79347a4d546b30534451794c6a55344d4456574e6a6b754d5449304f56704e4e4463754f4441784d7941324f5334784d6a5135534451794c6a55344d4456574f444d754d7a45354e4567304e7934344d44457a566a59354c6a45794e446c61545463344c6a55314e69417a4f43347a4e7a4178517a63344c6a55314e6941314e53347a4e545531494459304c6a63344e6a63674e6a6b754d5449304f5341304e7934344d44457a494459354c6a45794e446c574f444d754d7a45354e454d334d6934324d6a59784944677a4c6a4d784f5451674f5449754e7a55774e5341324d7934784f54513549446b794c6a63314d4455674d7a67754d7a63774d5567334f4334314e545a61545451334c6a67774d544d674e7934324d54557a4d6b4d324e4334334f445932494463754e6a45314d7a49674e7a67754e545532494449784c6a4d344e4463674e7a67754e54553249444d344c6a4d334d4446494f5449754e7a55774e554d354d6934334e5441314944457a4c6a5530
 
4e544d674e7a49754e6a4932494330324c6a55334f544535494451334c6a67774d544d674c5459754e5463354d546c574e7934324d54557a4d6c704e4e4449754e5467774e5341334c6a59784e544d79534451334c6a67774d544e574c5459754e5463354d546c494e4449754e5467774e5659334c6a59784e544d79576b30304d4334334d4451674e7934324d54557a4d6b67304d6934314f444131566930324c6a55334f544535534451774c6a63774e4659334c6a59784e544d79576949675a6d6c7362443069596d7868593273694947316863327339496e56796243676a5a47397a6453316b4c574e316447393164436b694c7a3438634746306143426b50534a4e4e6a67754f5449784e53417a4e6934774d544d31517a59344c6a6b794d5455674d7a59754d44457a4e5341324e5334334d7a5935494451354c6a51334d7a67674e5445754e44497a4d5341304f5334304e7a4d34517a4d334c6a45774f544d674e446b754e44637a4f43417a4d6934314e7a673349444d334c6a4d314f5459674d7a49754e5463344e79417a4e6934774d544d314969427a64484a7661325539496d4a7359574e724969427a64484a766132557464326c6b64476739496a63754e6a6b784e6a456949484e30636d39725a5331736157356c5932467750534a79623356755a4349676333527962327
 
46c4c577870626d567162326c7550534a79623356755a434976506a78775958526f49475139496b30774c6a4d304f44597a4d7941344e5334304f545132517a41754d7a51344e6a4d7a494467314c6a51354e4459674d6a6b754e4467314e6941344e5334344d7a413549444d304c6a67774f5341344e5334324f5468444e4451754f444d7a4e7941344e5334304e446333494455784c6a49344e7a49674f4451754e444179494455334c6a55794e6a6b674e7a67754f5463794e454d324d6934344d544935494463304c6a4d334d6a63674e7a55754d544d304d6941314f5334324f444d32494463314c6a457a4e4449674e546b754e6a677a4e694967633352796232746c50534a696247466a61794967633352796232746c4c5864705a48526f505349324c6a45324e4467794969382532425043397a646d63253242)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset)
 [![Share Dosu with your 
team](https://camo.githubusercontent.com/75e6a5670cb470de110632344578950590e98c31e05e4b76b7c0a8caca2f1be5/68747470733a2f2f696d672e736869656c64732e696
 
f2f62616467652f5368617265253230446f737525323077697468253230796f75722532307465616d2d3166366665623f7374796c653d666c6174)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset)
   
   
   **The Problem with linux dev packages: Build Tools Leaking into the Final 
Image**
   
   The lean stage calls pip-install.sh --requires-build-essential, which 
installs build-essential (GCC, G++, make, binutils, etc.) into that layer to 
compile native Python extensions from source. Once compilation finishes, those 
tools have no runtime purpose — but because the install happens inside the lean 
stage itself, they are baked permanently into the final image.
   
   The multi-stage build already has a python-base and python-common lineage, 
but no dedicated "build" stage for Python dependencies. The correct pattern 
would be:
   
   * Build stage — inherits python-common, installs build-essential, runs 
pip-install.sh, compiles all native wheels, populates /app/.venv
   * Lean stage — starts fresh from python-common (no build tools), and COPY 
--from=build /app/.venv /app/.venv


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to