Skip to content

Instantly share code, notes, and snippets.

@thearyanahmed
Created March 24, 2020 13:07
Show Gist options
  • Save thearyanahmed/b1f99234632650776148d917fa8ba503 to your computer and use it in GitHub Desktop.
Save thearyanahmed/b1f99234632650776148d917fa8ba503 to your computer and use it in GitHub Desktop.
PHP-FPM container for laravel app
FROM php:7.4-fpm
# Starting from scratch
RUN apt-get clean
RUN apt-get -y autoremove
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Update dependencies
RUN apt-get update
# Zip
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-install zip
# Curl
RUN apt-get install -y libcurl3-dev curl && docker-php-ext-install curl
# BC Math
RUN docker-php-ext-install bcmath
# mysql
RUN docker-php-ext-install mysqli pdo pdo_mysql
# RUN apt-get install -y libpq-dev && docker-php-ext-install pdo pdo_pgsql
# Human Language and Character Encoding Support
RUN apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl
## Crontab
RUN apt-get update && apt-get install -y cron
ADD schedules/cron /etc/cron.d/cron
COPY php-fpm/cron.d/schedule /etc/cron.d
RUN chmod -R 644 /etc/cron.d/cron
RUN touch /var/log/cron.log
RUN crontab /etc/cron.d/cron
# Custom php.ini config
COPY php.ini /usr/local/etc/php/php.ini
RUN curl -sS https://getcomposer.org/installer | \
php -- --install-dir=/usr/bin/ --filename=composer
# Clean up
RUN apt-get clean
RUN apt-get -y autoremove
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set up default directory
WORKDIR /var/www/core
CMD printenv > /etc/environment && echo "cron starting..." && (cron) && : > /var/log/cron.log && tail -f /var/log/cron.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment