Skip to content

Instantly share code, notes, and snippets.

@benrolfe
Last active May 18, 2022 12:30
Show Gist options
  • Save benrolfe/9ee58c79659a6162ccda7cc50430445f to your computer and use it in GitHub Desktop.
Save benrolfe/9ee58c79659a6162ccda7cc50430445f to your computer and use it in GitHub Desktop.
Docker: PHP 7.1 with Apache and MSSQL
version: '3'
services:
php:
build:
context: ./
dockerfile: .docker/Dockerfile
container_name: hub_php
ports:
- 180:80
environment:
REDIS_HOST: docker.for.mac.localhost
FROM php:7.1-apache
# Get repository and install wget and vim
RUN apt-get update && apt-get install --no-install-recommends -y \
wget \
gnupg \
git \
unzip
# Install PHP extensions deps
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
zlib1g-dev \
libicu-dev \
g++ \
unixodbc-dev \
libxml2-dev \
libaio-dev \
libmemcached-dev \
freetds-dev \
libssl-dev \
openssl
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin \
--filename=composer
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu \
&& pecl install sqlsrv-4.1.6.1 \
&& pecl install pdo_sqlsrv-4.1.6.1 \
&& pecl install redis \
&& pecl install memcached \
&& pecl install xdebug \
&& docker-php-ext-install \
iconv \
mbstring \
intl \
mcrypt \
gd \
mysqli \
pdo_mysql \
pdo_dblib \
soap \
sockets \
zip \
pcntl \
ftp \
&& docker-php-ext-enable \
sqlsrv \
pdo_sqlsrv \
redis \
memcached \
opcache \
xdebug
# Install APCu and APC backward compatibility
RUN pecl install apcu \
&& pecl install apcu_bc-1.0.3 \
&& docker-php-ext-enable apcu --ini-name 10-docker-php-ext-apcu.ini \
&& docker-php-ext-enable apc --ini-name 20-docker-php-ext-apc.ini
# Clean repository
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# The path that will be used to make Apache run under that user
ENV VOLUME_PATH /var/www/html/public
# Move files
COPY src/ /var/www/html/
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html/
RUN chown -R www-data:www-data /var/www/html/ \
&& a2enmod rewrite
<VirtualHost *:80>
DocumentRoot /var/www/html/public
<Directory "/var/www/html/public">
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
@n2kdigital
Copy link

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
pecl/xdebug requires PHP (version >= 7.2.0, version <= 8.1.99), installed version is 7.1.33
No valid packages found
install failed
ERROR: Service 'php' failed to build: The command '/bin/sh -c docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu && pecl install sqlsrv-4.1.6.1 && pecl install pdo_sqlsrv-4.1.6.1 && pecl install redis && pecl install memcached && pecl install xdebug && docker-php-ext-install iconv mbstring intl mcrypt gd mysqli pdo_mysql pdo_dblib soap sockets zip pcntl ftp && docker-php-ext-enable sqlsrv pdo_sqlsrv redis memcached opcache' returned a non-zero code: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment