我正在使用postgres和一些其他我项目的基本软件包在CentOS 7上为开发环境构建映像。但是最终大小约为900MB,我什至删除了一些在构建过程后将不再使用的软件包。
FROM centos:centos7
RUN yum -y update && yum clean all && yum -y install epel-release gnupg && \
yum -y install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm && \
# Setting global environment variables
ENV PG_VERSION 9.6
ENV PG_HBA /var/lib/pgsql/$PG_VERSION/data/pg_hba.conf
ENV PG_CONF /var/lib/pgsql/$PG_VERSION/data/postgresql.conf
ENV PGDATA /var/lib/pgsql/$PG_VERSION/data
RUN yum update && yum -y install acl gcc gcc-c++ \
postgresql96 postgresql96-contrib postgresql96-devel \
postgresql96-server postgresql96-plpython vim perl-CPAN \
cpanminus perl-DBD-Pg libdbi-dbd-pgsql git unzip pgxnclient python-setuptools && \
yum -y groupinstall "Development Tools" && \
cpanm --mirror http://mirrors.dotsrc.org/cpan/ --quiet --force --notest App::Sqitch && \
export PATH="${PATH}:/usr/pgsql-$PG_VERSION/bin" && pgxn install first_last_agg && \
pgxn install plpgsql_check && pgxn install pgtap && cpan TAP::Parser::SourceHandler::pgTAP && \
pgxn install geoip && rm -rf /var/cache/yum
USER postgres
RUN /usr/pgsql-$PG_VERSION/bin/initdb -D $PGDATA
USER root
RUN sed -i "s/^#listen_addresses = 'localhost'/listen_addresses = '*'/" $PG_CONF && \
sed -i "s/^#shared_preload_libraries = ''/shared_preload_libraries = 'plpgsql,pg_stat_statements'/" $PG_CONF && \
sed -i "s/^#listen_addresses = 'localhost'/listen_addresses = '*'/" $PG_CONF && \
sed -i '86s/.*/#&/' $PG_HBA && sed -i '88s/.*/#&/' $PG_HBA && \
echo "host all all all md5" >> $PG_HBA
# Here I copy some files and stuff related to the database from my host machine to the container, they all combined have 4MB (in my local machine)
EXPOSE 5432
VOLUME ["/etc/pgsql", "/var/log/pgsql", "/var/lib/pgsql"]
RUN yum -y remove acl gcc gcc-c++ vim unzip bison flex libtool gettext autoconf automake cpp kernel-headers \
gdb dyninst gcc-gfortran doxygen swig dyninst kernel-debug-devel && \
yum clean all && rm -rf /var/cache/yum && cat /var/lib/pgsql/echo.sh
USER postgres
CMD ["/usr/pgsql-9.6/bin/postgres", "-D", "/var/lib/pgsql/9.6/data"]
我看到了一些其他的postgres图片,其中大多数都小于100MB。我该怎么做才能减小此尺寸?