Skip to content

Instantly share code, notes, and snippets.

@benrolfe benrolfe/Dockerfile
Last active Mar 1, 2019

Embed
What would you like to do?
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.