I have the following need: when creating a new container I would like to automatically run the /usr/local/bin/start
script that is inside the image, this script basically verifies that the variable ENVIRONMENTAL TYPE is equal to prod , if yes change 2 file parameters.
Obs : I would like to run this script only when creating the container, however, it does not have a problem if the only alternative is to run it whenever the container is started.
FROM php:7.2-apache
MAINTAINER Fabio J L Ferreira <[email protected]>
# Instala e configura componentes essenciais
RUN apt-get update && \
a2enmod rewrite && \
apt-get install -y --no-install-recommends unzip git && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer; \
echo "America/Sao_Paulo" > /etc/timezone; \
\
# Configura componentes do Apache e PHP
{ \
echo '<VirtualHost *:80>'; \
echo '\tServerAdmin webmaster@localhost'; \
echo '\tDocumentRoot /var/www'; \
echo; \
echo '\tErrorLog ${APACHE_LOG_DIR}/error.log'; \
echo '\tCustomLog ${APACHE_LOG_DIR}/access.log combined'; \
echo; \
echo '\t<Directory /var/www>'; \
echo '\t\tOptions Indexes FollowSymLinks'; \
echo '\t\tAllowOverride None'; \
echo '\t\tRequire all granted'; \
echo '\t</Directory>'; \
echo '</VirtualHost>'; \
} | tee /etc/apache2/sites-enabled/000-default.conf; \
docker-php-source extract; \
cp /usr/src/php/php.ini-development /usr/local/etc/php/php.ini; \
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/' /usr/local/etc/php/php.ini; \
docker-php-source delete
# Aqui instalamos algumas extensões comumente utilizadas
RUN apt-get install -y --no-install-recommends libjpeg-dev libpng-dev && \
docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd; \
\
# Instala a extensão PHP "exif" => http://php.net/manual/pt_BR/intro.exif.php
apt-get install -y --no-install-recommends libexif-dev && \
docker-php-ext-install exif; \
\
# Instala as extensões PHP "mysqli pdo_mysql pgsql pdo_pgsql"
apt-get install -y --no-install-recommends libpq-dev && \
docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \
docker-php-ext-install mysqli pdo_mysql pgsql pdo_pgsql
# Limpa repositório local
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /var/www
EXPOSE 80
COPY start /usr/local/bin/
How could you do this? After solving this problem, I need to check if passing this variable in the container creation will have the expected effect.