Skip to content

Instantly share code, notes, and snippets.

@h4ck4life
Created January 8, 2024 07:47
Show Gist options
  • Save h4ck4life/db7699e8042ac462aca26135f27773ee to your computer and use it in GitHub Desktop.
Save h4ck4life/db7699e8042ac462aca26135f27773ee to your computer and use it in GitHub Desktop.
PHP-FPM dockerfile with sendmail enabled
FROM php:7.4-fpm
# Install dependencies
RUN apt-get update && \
apt-get install -y telnet curl unixodbc unixodbc-dev gnupg2 libgssapi-krb5-2 wget iputils-ping openssl zlib1g-dev libzip-dev sendmail
# Add Microsoft repo for SQL Server ODBC Driver
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
# Install SQL Server ODBC Driver
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17
# Install specific versions of PHP extensions for SQL Server compatible with PHP 7.4
RUN pecl install sqlsrv-5.9.0 pdo_sqlsrv-5.9.0 && \
docker-php-ext-enable sqlsrv pdo_sqlsrv
# Install other PHP extensions
RUN docker-php-ext-install mysqli pdo pdo_mysql
RUN chmod +rwx /etc/ssl/openssl.cnf
RUN sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/SECLEVEL=2/SECLEVEL=1/g' /etc/ssl/openssl.cnf
# Use the default production configuration
# RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Sendmail
RUN echo "sendmail_path=/usr/sbin/sendmail -t -i" >> /usr/local/etc/php/conf.d/sendmail.ini
RUN sed -i '/#!\/bin\/sh/aservice sendmail restart' /usr/local/bin/docker-php-entrypoint
RUN sed -i '/#!\/bin\/sh/aecho "$(hostname -i)\t$(hostname) $(hostname).localhost" >> /etc/hosts' /usr/local/bin/docker-php-entrypoint
# Copy application source
COPY . /var/www/html/
# Set working directory
WORKDIR /var/www/html
# Expose port 9000
EXPOSE 9000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment