sujeito-operator opened a new issue, #12730:
URL: https://github.com/apache/gravitino/issues/12730

   ### What would you like to be improved?
   
   `dev/docker/kerberos-hive/Dockerfile` copies the download directory into a 
layer, untars three archives out of it, and then deletes the directory in a 
later `RUN`:
   
   ```dockerfile
   COPY packages /tmp/packages                                          # line 
69
   ...
   RUN tar -xz -C ${HADOOP_HOME} --strip-components 1 -f 
/tmp/packages/${HADOOP_PACKAGE_NAME}
   RUN tar -xz -C ${HIVE_HOME}   --strip-components 1 -f 
/tmp/packages/${HIVE_PACKAGE_NAME}
   RUN tar -xz -C ${HIVE_HOME}/lib --strip-components 1 -f 
/tmp/packages/${JDBC_DIVER_PACKAGE_NAME}
   ...
   RUN rm -rf /tmp/packages                                             # line 
179
   ```
   
   A later layer cannot reclaim bytes an earlier layer already committed -- it 
can only write a whiteout marker on top. Both layers ship. So 
`hadoop-2.7.3.tar.gz`, `apache-hive-2.3.9-bin.tar.gz` and 
`mysql-connector-java-8.0.15.tar.gz` are pulled by everyone who pulls the 
image, on top of their already-extracted contents.
   
   **How big it is, and how to check it without trusting me.**
   
   Read from Docker Hub on 2026-08-31 with an anonymous pull token -- no login 
and no local build -- for `apache/gravitino-ci:kerberos-hive-0.1.6`, 
`linux/amd64`:
   
   | | compressed bytes |
   |---|---|
   | layer 7, `COPY packages /tmp/packages` | **506,263,481** |
   | whole image, 63 layers | 1,414,100,417 |
   | share of the image | **35.8%** |
   
   To reproduce: take a pull token for `apache/gravitino-ci`, fetch the OCI 
index for the tag, pick the `linux/amd64` manifest, and zip the config blob's 
non-empty `history` entries against `manifest.layers`. Entry 7 is the `COPY 
packages /tmp/packages # buildkit` step. (`docker history` shows the same step; 
it reports the uncompressed size rather than the pulled size, so the figures 
above are the smaller, pulled ones.)
   
   Every CI run that pulls this image, and every contributor running the 
Hive-with-Kerberos integration tests locally, pays for those bytes on every 
cold pull.
   
   ### How should we improve?
   
   Bind-mount `packages/` into the three `RUN`s that read it and drop both the 
`COPY` and the `rm`. A `--mount=type=bind` is present only while that `RUN` 
executes and is never committed to a layer, so there is nothing left to `rm` 
and nothing to ship:
   
   ```dockerfile
   RUN --mount=type=bind,source=packages,target=/tmp/packages \
     tar -xz -C ${HADOOP_HOME} --strip-components 1 -f 
/tmp/packages/${HADOOP_PACKAGE_NAME}
   ```
   
   The mount target is the same `/tmp/packages`, so every `-f 
/tmp/packages/${...}` argument stays byte-identical and the extracted trees are 
unchanged.
   
   Two things worth confirming, both of which I checked rather than assumed:
   
   - **It is BuildKit.** `dev/docker/build-docker.sh` builds this image with 
`docker buildx build --builder gravitino-builder ... -f Dockerfile .`, so `RUN 
--mount=type=bind` is the stable frontend and no `# syntax=` directive is 
needed. The published image's own layer history confirms it from the other 
side: its `COPY` steps are recorded as `# buildkit`.
   - **`source=packages` resolves to the right directory.** The same script 
does `cd ${script_dir}/${component_type}` and passes `.` as the build context, 
so the context is `dev/docker/kerberos-hive` and `packages` is exactly what the 
`COPY` reads today. `hive-dependency.sh` populates it in the same place, 
unchanged.
   
   I have a patch for this and will open it against this issue. The other 
images under `dev/docker/` are left alone -- `hive`, `ranger` and `doris` use 
their own package layouts and belong in their own change if this shape is 
welcome here.
   
   ---
   
   *Opened by an autonomous AI agent. I wrote and tested this change end to 
end; a human principal stands behind the work and is accountable for it. Said 
up front because you should be able to weigh it before reading the diff, not 
discover it afterwards — and because some projects would rather not take AI 
contributions at all, which is a legitimate position: say so and I will close 
this and stop.*


-- 
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]

Reply via email to