Skip to content

Instantly share code, notes, and snippets.

@MayMeow
Last active February 11, 2021 11:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MayMeow/970734c6d1bb4e809fb12be8d0719d96 to your computer and use it in GitHub Desktop.
Save MayMeow/970734c6d1bb4e809fb12be8d0719d96 to your computer and use it in GitHub Desktop.
CakePHP PHP-FPM docker image with pgsql and redis
#!/bin/bash
echo -ne "Update folder and files rights..."
# here i store all users uploads
chmod 777 /var/www/html/webroot/user-data
chmod +x /var/www/html/bin/cake
if [ ! -f /var/www/html/vendor/autoload.php ]; then
echo "Autoload file not found! Installing dependencies..."
composer selfupdate
composer install
fi
echo "Wait until database $MYSQL_HOST:5432 is ready..."
until nc -z $MYSQL_HOST 5432
do
sleep 1
done
# Wait to avoid "panic: Failed to open sql connection pq: the database system is starting up"
sleep 1
echo "Running migrations..."
cd /var/www/html
bin/cake mcloud_setup
echo "Starting server..."
php-fpm
FROM php:fpm
MAINTAINER CakeHub <cakehub@cakehub.sk>
RUN requirements="libmcrypt-dev g++ libicu-dev libpq-dev libmcrypt4 libicu52 netcat" \
&& apt-get update && apt-get install -y $requirements \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql \
&& docker-php-ext-install mcrypt \
&& docker-php-ext-install mbstring \
&& docker-php-ext-install intl \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& requirementsToRemove="libmcrypt-dev g++ libicu-dev" \
# && apt-get purge --auto-remove -y $requirementsToRemove \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& apt-get update \
&& apt-get install -y zlib1g-dev git wget \
&& docker-php-ext-install zip \
&& wget https://phar.phpunit.de/phpunit.phar \
&& chmod +x phpunit.phar \
&& mv phpunit.phar /usr/local/bin/phpunit \
# && apt-get purge -y --auto-remove zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Redis extension installation and configure
RUN git clone https://github.com/phpredis/phpredis.git \
&& cd phpredis \
&& git checkout php7 \
&& phpize \
&& ./configure \
&& make && make install \
&& cd .. \
&& rm -rf phpredis
RUN docker-php-ext-enable redis
EXPOSE 8765
COPY docker-entry.sh /usr/local/bin/docker-entry
RUN chmod +x /usr/local/bin/docker-entry
CMD ["docker-entry"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment