Usually when I build docker images for php I use this approach:
FROM php:7.2-apache RUN apt-get update && \ apt-get install -y libghc-postgresql-simple-dev &&\ docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql &&\ docker-php-ext-install pdo pgsql pdo_pgsql &&\ // Install some other extentions there apt-get autoremove -y &&\ apt-get autoclean &&\ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* cache/* /var/lib/log/*
But this can result an image of 1.2GB and I need to shave some space. AFAIK header files such as the
libghc-postgresql-simple-dev take a lot of space in my image so after building and installing the module I though of removing it and use the non-dev variant
libghc-postgresql-simple or removing it completely.
So I want to ask:
1. Instead of dynamically linking it how I can statically link it on my build once i run
docker-php-ext-install in order to remove the
2. Would once I build the php module removing the
libghc-postgresql-simple-dev and using the
libghc-postgresql-simple would make the php psql extention to work as supposed to?
The idea behind it is to optimize the build in order to make my image as small as possible.