mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
perf(docker): trim the compat image's CLI extras and Python build leftovers (#3108)
The AWS CLI v2 install ships 26 MB of `aws <command> help` example pages that were never viewable in this image: help rendering needs groff or mandoc and ubi9-minimal has neither, so `aws sqs help` already failed before this change. Tab completion has no user inside a container either, so aws_completer (9 MB), its ac.index database (21 MB) and the /usr/bin symlink the installer creates go with it. The command reference the CLI reads at run time (dist/awscli/data) stays. pip and setuptools stay: the image documents pip and init hooks use it to install packages. The system Python loses only build-time extras nothing imports at run time: the optimised .pyc variants, lib2to3 and ensurepip (removed with a python3 one-liner, ubi9-minimal has no find). awslocal's mode is set in the COPY instead of a chmod layer. Measured on arm64 on top of #3085: compat image 924 to 839 MB on disk, 214.0 to 197.7 MB gzip; /usr/local/aws-cli 264 to 209 MB. Verified: aws 2.36.24, `aws sqs list-queues` still resolves its model, pip3 installs a package, boto3 1.42.97 import with json, ssl and sqlite3, awslocal, init hooks calling all three, the container healthy in 5 s, and the four endpoint-resolution checks compatibility.yml runs against this image.
This commit is contained in:
1 parent
b199894e19
commit
a6bd0554a7
1 file changed
+11
-2
@@ -64,12 +64,21 @@ RUN useradd -r -u 1001 -g root -d /app -s /sbin/nologin floci \
|
||||
&& unzip -q /tmp/awscliv2.zip -d /tmp \
|
||||
&& /tmp/aws/install --bin-dir /usr/bin --install-dir /usr/local/aws-cli \
|
||||
&& rm -rf /tmp/awscliv2.zip /tmp/aws \
|
||||
# The CLI's `aws <cmd> help` example pages are 26 MB of text nobody reads inside a container;
|
||||
# the command reference itself (dist/awscli/data) stays. unzip exists only to unpack the CLI.
|
||||
# pip stays: the image documents it and init hooks use it to install packages.
|
||||
&& rm -rf /usr/local/aws-cli/v2/*/dist/awscli/examples \
|
||||
# Tab completion has no user inside a container: aws_completer and its 21 MB ac.index go.
|
||||
# The system Python keeps pip, setuptools and what boto3 imports; the optimised .pyc
|
||||
# variants, lib2to3 and ensurepip (pip is already installed) are build-time extras.
|
||||
&& rm -rf /usr/local/aws-cli/v2/*/dist/awscli/data/ac.index /usr/local/aws-cli/v2/*/dist/aws_completer /usr/bin/aws_completer \
|
||||
&& rm -rf /usr/lib64/python3.9/lib2to3 /usr/lib64/python3.9/ensurepip \
|
||||
&& python3 -c 'import pathlib; [p.unlink() for d in ("/usr/lib64/python3.9","/usr/lib/python3.9") for p in pathlib.Path(d).rglob("*.opt-[12].pyc")]' \
|
||||
&& microdnf remove -y unzip \
|
||||
&& microdnf clean all \
|
||||
&& rm -rf /root/.cache/pip
|
||||
|
||||
COPY bin/awslocal /usr/local/bin/awslocal
|
||||
RUN chmod +x /usr/local/bin/awslocal
|
||||
COPY --chmod=755 bin/awslocal /usr/local/bin/awslocal
|
||||
|
||||
# Pre-create the init-hook directories so archive-based copies (Testcontainers
|
||||
# withCopyFileToContainer / `docker cp`) can drop hooks straight into them.
|
||||
|
||||
Reference in new issue
Block a user