codeant-ai-for-open-source[bot] commented on code in PR #42586: URL: https://github.com/apache/superset/pull/42586#discussion_r3678598994
########## docs/admin_docs/installation/docker-builds.mdx: ########## @@ -112,12 +112,54 @@ USER superset CMD ["/app/docker/entrypoints/run-server.sh"] ``` +### Adding translations to a custom image + +The pattern above, a small Dockerfile that just extends `FROM apache/superset:...`, can't add +translations after the fact. By the time an official tag is published, its frontend and backend +layers have already had non-English translation files stripped out unless `BUILD_TRANSLATIONS` +was set at build time (see below), and there's no `superset/translations` source tree left in the +final image to compile from. + +To get translations into your own image, you need to build from the full Superset source (a +clone or fork of this repo) rather than extend a published tag. The most efficient way to do this +is to append your customizations as one more stage at the end of the repo's own `Dockerfile`, so +Docker can reuse the cached upstream layers and only rebuild what your stage adds: + +```Dockerfile +# Append this to the end of the repo's Dockerfile +FROM apache/superset:5.0.0 AS my-custom-image Review Comment: **Suggestion:** The example hardcodes the runtime base to `apache/superset:5.0.0` while instructing users to append it to an arbitrary source checkout. If the checkout is a different release, the copied frontend and backend translation artifacts come from that checkout but are installed into a 5.0.0 runtime, which can produce incompatible or missing translation keys. Pin the source checkout to 5.0.0 or parameterize the image tag and explicitly require it to match the checkout. [api mismatch] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ⚠️ Custom builds can mix release-incompatible translation assets. - ⚠️ Changed translation keys may be missing or stale. - ⚠️ Users following the source-build instructions receive ambiguous version guidance. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ed0d2b1dea094bae9da59d99ae5354e6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ed0d2b1dea094bae9da59d99ae5354e6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** docs/admin_docs/installation/docker-builds.mdx **Line:** 130:130 **Comment:** *Api Mismatch: The example hardcodes the runtime base to `apache/superset:5.0.0` while instructing users to append it to an arbitrary source checkout. If the checkout is a different release, the copied frontend and backend translation artifacts come from that checkout but are installed into a 5.0.0 runtime, which can produce incompatible or missing translation keys. Pin the source checkout to 5.0.0 or parameterize the image tag and explicitly require it to match the checkout. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42586&comment_hash=1402ea2d0c0d4475d33921bbc1693264129bc351ac4be59ffe31c942e4e49f31&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42586&comment_hash=1402ea2d0c0d4475d33921bbc1693264129bc351ac4be59ffe31c942e4e49f31&reaction=dislike'>👎</a> ########## docs/admin_docs/installation/docker-builds.mdx: ########## @@ -112,12 +112,54 @@ USER superset CMD ["/app/docker/entrypoints/run-server.sh"] ``` +### Adding translations to a custom image + +The pattern above, a small Dockerfile that just extends `FROM apache/superset:...`, can't add +translations after the fact. By the time an official tag is published, its frontend and backend +layers have already had non-English translation files stripped out unless `BUILD_TRANSLATIONS` +was set at build time (see below), and there's no `superset/translations` source tree left in the +final image to compile from. + +To get translations into your own image, you need to build from the full Superset source (a +clone or fork of this repo) rather than extend a published tag. The most efficient way to do this +is to append your customizations as one more stage at the end of the repo's own `Dockerfile`, so +Docker can reuse the cached upstream layers and only rebuild what your stage adds: + +```Dockerfile +# Append this to the end of the repo's Dockerfile +FROM apache/superset:5.0.0 AS my-custom-image +USER root + +# Pull the compiled translation files out of the earlier build stages. These +# only exist mid-build (frontend .json in `superset-node`, backend .mo in +# `python-translation-compiler`) and get stripped from the final `lean`/`dev` +# stages unless BUILD_TRANSLATIONS=true. +COPY --from=superset-node /app/superset/translations superset/translations +COPY --from=python-translation-compiler /app/translations_mo superset/translations + +USER superset +``` + +Then build with: + +```bash +docker build --target=my-custom-image --build-arg=BUILD_TRANSLATIONS=true -t mysuperset:5.0.0 . +``` + +You can combine this with the database-driver/dependency pattern above by adding your own +`RUN uv pip install ...` step before switching back to `USER superset`. See +[issue #35959](https://github.com/apache/superset/issues/35959) for the discussion this pattern +came out of, credit to the community for working it out. + ## Key ARGs in Dockerfile - `BUILD_TRANSLATIONS`: whether to build the translations into the image. For the frontend build this tells webpack to strip out all locales other than `en` from - the `moment-timezone` library. For the backendthis skips compiling the - `*.po` translation files + the `moment-timezone` library. For the backend this skips compiling the + `*.po` translation files. This only takes effect when building the image from source Review Comment: **Suggestion:** This describes the backend behavior backwards. In the Dockerfile, `pybabel compile` runs when `BUILD_TRANSLATIONS` is `true`; the cleanup then removes the source `.po` files. Users following this documentation may disable the flag when they intend to include backend translations, causing the compiled `.mo` files to be absent. [api mismatch] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ❌ Backend non-English translations are omitted when compilation is disabled. - ⚠️ `BUILD_TRANSLATIONS` documentation contradicts Dockerfile behavior. - ⚠️ Custom image builders may choose the wrong build argument. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=18771786f0ae4b74b88e20416a231fb0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=18771786f0ae4b74b88e20416a231fb0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** docs/admin_docs/installation/docker-builds.mdx **Line:** 158:159 **Comment:** *Api Mismatch: This describes the backend behavior backwards. In the Dockerfile, `pybabel compile` runs when `BUILD_TRANSLATIONS` is `true`; the cleanup then removes the source `.po` files. Users following this documentation may disable the flag when they intend to include backend translations, causing the compiled `.mo` files to be absent. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42586&comment_hash=6605001b816e2b04e6cb0b26970539fd1e8c52207d829955d99931e44d19edc6&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42586&comment_hash=6605001b816e2b04e6cb0b26970539fd1e8c52207d829955d99931e44d19edc6&reaction=dislike'>👎</a> -- 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]
