Reduce size

This commit is contained in:
fredbcode 2021-10-28 09:44:08 +02:00
parent 5755c5e269
commit 944546fceb

View File

@ -1,4 +1,4 @@
FROM debian:bullseye-slim
FROM debian:bullseye-slim as buildamd
ARG SQUID_VERSION
ENV ENV_SQUID_VERSION=$SQUID_VERSION
@ -6,7 +6,7 @@ ENV ENV_SQUID_VERSION=$SQUID_VERSION
WORKDIR /tmp
RUN echo "deb-src http://deb.debian.org/debian bullseye main contrib" >> /etc/apt/sources.list && apt-get update && apt-get --no-upgrade --no-install-recommends -y build-dep squid && apt-get --no-install-recommends -y install wget tar xz-utils libssl-dev libssl1.1 winbind \
&& wget --progress=dot:giga http://www.squid-cache.org/Versions/v5/$SQUID_VERSION \
&& mkdir squid && tar -C squid --strip-components=1 -xzf $SQUID_VERSION \
&& tar -C /tmp --strip-components=1 -xzf $SQUID_VERSION \
&& cd squid \
&& ./configure \
--prefix=/usr \
@ -58,40 +58,41 @@ RUN echo "deb-src http://deb.debian.org/debian bullseye main contrib" >> /etc/ap
--with-large-files \
--enable-removal-policies="lru,heap" \
&& make \
# Instal
&& cd /tmp/squid && apt-get install --no-install-recommends -y libxml2 ca-certificates \
&& adduser --no-create-home --uid 1161 --group --system squid \
FROM debian:bullseye-slim
COPY --from=buildamd --chown=1161 /tmp/src/auth/basic/LDAP/basic_ldap_auth /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/digest_ldap_auth /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/negotiate_kerberos_auth /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/log/DB/log_db_daemon /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/log/file/log_file_daemon /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/unlinkd /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/http/url_rewriters/LFS/url_lfs_rewrite /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/http/url_rewriters/fake/url_fake_rewrite /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/http/url_rewriters/fake/url_fake_rewrite.sh /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/mime.conf.default /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/security/cert_validators/fake/security_fake_certverify /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/security/cert_generators/file/security_file_certgen /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/acl/external/delayer/ext_delayer_acl /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/acl/external/SQL_session/ext_sql_session_acl /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/acl/external/wbinfo_group/ext_wbinfo_group_acl /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/acl/external/LDAP_group/ext_ldap_group_acl /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/acl/external/unix_group/ext_unix_group_acl /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/store/id_rewriters/file/storeid_file_rewrite /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/src/DiskIO/DiskDaemon/diskd /usr/lib/squid/
COPY --from=buildamd --chown=1161 /tmp/errors /usr/share/squid/
COPY --from=buildamd --chown=1161 /tmp/icons /usr/share/squid/
COPY --from=buildamd --chown=1161 /tmp/src/squid /usr/sbin/
COPY --from=buildamd --chown=1161 /tmp/tools/squidclient/squidclient /usr/sbin/
COPY --from=buildamd --chown=1161 /tmp/src/mime.conf.default /etc/squid/mime.conf
COPY --from=buildamd --chown=1161 /tmp/src/squid.conf.default /etc/squid/squid.conf
RUN adduser --no-create-home --uid 1161 --group --system squid \
&& mkdir -p /usr/share/squid \
&& mkdir -p /usr/lib/squid \
&& mkdir /etc/squid/ \
&& mkdir -p /var/log/squid \
&& mkdir -p /var/cache/squid \
&& cp src/auth/basic/LDAP/basic_ldap_auth /usr/lib/squid/ \
&& cp src/auth/digest/LDAP/digest_ldap_auth /usr/lib/squid/ \
&& cp src/auth/negotiate/kerberos/negotiate_kerberos_auth /usr/lib/squid/ \
&& cp src/log/DB/log_db_daemon /usr/lib/squid/ \
&& cp src/log/file/log_file_daemon /usr/lib/squid/ \
&& cp src/unlinkd /usr/lib/squid/ \
&& cp src/http/url_rewriters/LFS/url_lfs_rewrite /usr/lib/squid/ \
&& cp src/http/url_rewriters/fake/url_fake_rewrite /usr/lib/squid/ \
&& cp src/http/url_rewriters/fake/url_fake_rewrite.sh /usr/lib/squid/ \
&& cp src/mime.conf.default /usr/lib/squid/ \
&& cp src/security/cert_validators/fake/security_fake_certverify /usr/lib/squid/ \
&& cp src/security/cert_generators/file/security_file_certgen /usr/lib/squid/ \
&& cp src/acl/external/delayer/ext_delayer_acl /usr/lib/squid/ \
&& cp src/acl/external/SQL_session/ext_sql_session_acl /usr/lib/squid/ \
&& cp src/acl/external/wbinfo_group/ext_wbinfo_group_acl /usr/lib/squid/ \
&& cp src/acl/external/LDAP_group/ext_ldap_group_acl /usr/lib/squid/ \
&& cp src/acl/external/eDirectory_userip/ext_edirectory_userip_acl /usr/lib/squid/ \
&& cp src/acl/external/unix_group/ext_unix_group_acl /usr/lib/squid/ \
&& cp src/store/id_rewriters/file/storeid_file_rewrite /usr/lib/squid/ \
&& cp src/DiskIO/DiskDaemon/diskd /usr/lib/squid/ \
&& cp -r errors /usr/share/squid/ \
&& cp -r icons /usr/share/squid/ \
&& cp src/squid /usr/sbin/ \
&& cp tools/squidclient/squidclient /usr/sbin/ \
&& cp src/mime.conf.default /etc/squid/mime.conf \
&& cp src/squid.conf.default /etc/squid/squid.conf \
&& chown -Rf squid /etc/squid \
&& chown -Rf squid /usr/lib/squid \
&& chown -Rf squid /var/log/squid \
@ -100,13 +101,9 @@ RUN echo "deb-src http://deb.debian.org/debian bullseye main contrib" >> /etc/ap
&& echo "access_log stdio:/var/log/squid/access.log" >> /etc/squid/squid.conf \
&& echo "cache_log /var/log/squid/cache.log" >> /etc/squid/squid.conf \
&& echo "cache_effective_user squid" >> /etc/squid/squid.conf \
# Clean
&& apt-get remove -y --purge libssl-dev wget make gcc g++ xz-utils libldap2-dev libpam0g-dev libdb-dev cdbs libsasl2-dev debhelper libcppunit-dev libkrb5-dev comerr-dev libcap2-dev libecap3-dev libexpat1-dev libxml2-dev autotools-dev libltdl-dev dpkg-dev pkg-config libnetfilter-conntrack-dev nettle-dev libgnutls28-dev lsb-release libldap2-dev libpam0g-dev libdb-dev cdbs libsasl2-dev debhelper libcppunit-dev libkrb5-dev comerr-dev libcap2-dev libecap3-dev libexpat1-dev libxml2-dev autotools-dev libltdl-dev dpkg-dev pkg-config libnetfilter-conntrack-dev nettle-dev libgnutls28-dev lsb-release \
&& apt-get auto-remove -y && apt-get clean autoclean \
# Remove for first layer
&& rm -rf /var/lib/apt/lists/* && rm -Rf /tmp/*
# Packages dependencies installation for running and clean again
RUN apt-get update && apt-get install -y --no-install-recommends net-tools rsync libexpat1 libltdl7 libxml2 openssl ca-certificates libldap-2.4-2 libecap3 libdb5.3 libatomic1 \
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates net-tools rsync libexpat1 libltdl7 libxml2 openssl ca-certificates libldap-2.4-2 libecap3 libdb5.3 libatomic1 \
&& apt-get auto-remove -y && apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/* && rm -Rf /tmp/*
COPY run.sh /