HDDS-14230. Create slim ozone image#47
Conversation
|
@rich7420 can you please share image size before/after this change? (Like I mentioned in apache/ozone#9538, deleting files in a separate |
|
@adoroszlai , my mistake , I've added a slim dockerfile. |
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @rich7420 for the patch.
We'll need changes in both docker-ozone-runner and docker-ozone, so I've created subtasks for HDDS-13426. This change would then belong to HDDS-14230, and can be done after HDDS-14229.
It should target the slim branch, editing Dockerfile, so that workflows for CI check and publishing the image to container registries automatically pick it up.
Also, please enable GitHub Actions workflows in your forks of both repos.
Dockerfile.slim
Outdated
| ARG OZONE_VERSION=2.0.0 | ||
| ARG OZONE_URL="https://www.apache.org/dyn/closer.lua?action=download&filename=ozone/${OZONE_VERSION}/ozone-${OZONE_VERSION}.tar.gz" | ||
|
|
||
| FROM alpine:latest AS extractor |
There was a problem hiding this comment.
We don't need the extractor stage, deletion can be added to the existing RUN curl, tar command.
Dockerfile.slim
Outdated
| curl -LSs -o ozone.tar.gz "$OZONE_URL" && \ | ||
| tar zxf ozone.tar.gz && \ | ||
| cd ozone-${OZONE_VERSION} && \ | ||
| rm -rf docs examples share/doc share/man licenses LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md compose kubernetes share/ozone/byteman && \ |
There was a problem hiding this comment.
Please list dirs/files to be deleted one per line, in alphabetical order. This makes it easier to understand and reduces diff when making changes later.
I think we should keep licenses LICENSE.txt NOTICE.txt.
Dockerfile.slim
Outdated
| tar zxf ozone.tar.gz && \ | ||
| cd ozone-${OZONE_VERSION} && \ | ||
| rm -rf docs examples share/doc share/man licenses LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md compose kubernetes share/ozone/byteman && \ | ||
| find . -type f \( -name "ozone-filesystem-hadoop2-*.jar" -o -name "ozone-filesystem-hadoop3-*.jar" -o -name "ozone-filesystem-hadoop3-client-*.jar" -o -name "*-tests.jar" -o -name "*-test.jar" -o -name "*test*.jar" -o -name "*-docs-*.jar" -o -name "*-shaded.jar" -o -name "*-all.jar" -o -name "*-fat.jar" \) -delete && \ |
There was a problem hiding this comment.
List of ozone-filesystem-hadoop2 etc. can be simplified to ozone-filesystem-hadoop*.jar.
"*test*.jar" covers the other two tests conditions.
There was a problem hiding this comment.
Also, "*-shaded.jar", "*-all.jar" and "*-fat.jar" are unnecessary.
Dockerfile.slim
Outdated
| cd ozone-${OZONE_VERSION} && \ | ||
| rm -rf docs examples share/doc share/man licenses LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md compose kubernetes share/ozone/byteman && \ | ||
| find . -type f \( -name "ozone-filesystem-hadoop2-*.jar" -o -name "ozone-filesystem-hadoop3-*.jar" -o -name "ozone-filesystem-hadoop3-client-*.jar" -o -name "*-tests.jar" -o -name "*-test.jar" -o -name "*test*.jar" -o -name "*-docs-*.jar" -o -name "*-shaded.jar" -o -name "*-all.jar" -o -name "*-fat.jar" \) -delete && \ | ||
| find . -type d \( -name "test*" -o -name "tests" -o -name "*test" -o -name "__pycache__" \) -exec rm -rf {} + 2>/dev/null || true && \ |
There was a problem hiding this comment.
Delete tests and smoketest in the first rm -rf command above. __pycache__ does not need to be deleted.
Dockerfile.slim
Outdated
| rm -rf docs examples share/doc share/man licenses LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md compose kubernetes share/ozone/byteman && \ | ||
| find . -type f \( -name "ozone-filesystem-hadoop2-*.jar" -o -name "ozone-filesystem-hadoop3-*.jar" -o -name "ozone-filesystem-hadoop3-client-*.jar" -o -name "*-tests.jar" -o -name "*-test.jar" -o -name "*test*.jar" -o -name "*-docs-*.jar" -o -name "*-shaded.jar" -o -name "*-all.jar" -o -name "*-fat.jar" \) -delete && \ | ||
| find . -type d \( -name "test*" -o -name "tests" -o -name "*test" -o -name "__pycache__" \) -exec rm -rf {} + 2>/dev/null || true && \ | ||
| find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.pyc" \) ! -path "*/etc/*" ! -path "*/bin/*" ! -path "*/sbin/*" ! -path "*/libexec/*" -delete 2>/dev/null || true |
There was a problem hiding this comment.
This command is not needed.
|
@adoroszlai thanks for the support! |
|
Here's the latest result. |
Dockerfile.slim
Outdated
| # limitations under the License. | ||
|
|
||
| ARG OZONE_RUNNER_IMAGE=apache/ozone-runner | ||
| ARG OZONE_RUNNER_VERSION=20250410-1-jdk21 |
There was a problem hiding this comment.
Now this can be set to 20251225-1-jdk21-slim to use the smaller base image.
Dockerfile.slim
Outdated
| sudo find . -type f \( \ | ||
| -name "*-all.jar" -o \ | ||
| -name "*-docs-*.jar" -o \ | ||
| -name "*-fat.jar" -o \ | ||
| -name "*-shaded.jar" -o \ | ||
| -name "*test*.jar" -o \ | ||
| -name "ozone-filesystem-hadoop*.jar" \ | ||
| \) -delete |
There was a problem hiding this comment.
all, fat, shaded and test are unnecessary.
We can replace find with plain delete, because jars are in a single directory.
share/ozone/lib/*-docs-*.jar \
share/ozone/lib/ozone-filesystem-hadoop*.jar \
Dockerfile.slim
Outdated
| share/doc \ | ||
| share/man \ |
There was a problem hiding this comment.
I don't see these in the tarball, are they necessary?
To trim Ozone docker image size
jira:
HDDS-14230
ci test:
https://github.com/apache/ozone-docker/actions/runs/20455995904/job/58778071961