Skip to content

Commit

Permalink
Update code and structure
Browse files Browse the repository at this point in the history
  • Loading branch information
narendravaghela committed Jul 29, 2017
1 parent 7ff5ef4 commit 9dc1d07
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 55 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -32,9 +32,9 @@ _**DOCUMENT_ROOT**_

It is a document root for Apache server. The default value for this is `./www`. All your sites will go here and will be synced automatically.

_**DATABASE_DIR**_
_**MYSQL_DATA_DIR**_

This is MySQL data directory. The default value for this is `./data`. All your MySQL data files will be stored here.
This is MySQL data directory. The default value for this is `./data/mysql`. All your MySQL data files will be stored here.

_**VHOSTS_DIR**_

Expand Down
48 changes: 13 additions & 35 deletions bin/webserver/Dockerfile
@@ -1,42 +1,20 @@
FROM php:7.1-apache
FROM php:7.0-apache

RUN apt-get update
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN apt-get install -y g++
RUN apt-get install -y --no-install-recommends apt-utils
RUN apt-get update && apt-get install -y g++ \
libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev \
libpng12-dev zlib1g-dev libpng-dev libicu-dev libcurl4-openssl-dev libxml2-dev

# install extensions
RUN docker-php-ext-install mysqli mbstring zip intl mcrypt curl json
RUN docker-php-ext-install iconv xml xmlrpc

RUN apt-get install -y libcurl4-openssl-dev
RUN docker-php-ext-install curl
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd

RUN apt-get install -y libicu-dev
RUN docker-php-ext-install intl

RUN docker-php-ext-install mbstring

RUN apt-get install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt

RUN apt-get install -y libxml2-dev
RUN docker-php-ext-install dom xml

RUN docker-php-ext-install pdo_mysql mysqli

RUN apt-get install -y libgd-dev libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr
RUN docker-php-ext-install gd exif

# xdebug
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.default_enable=1\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=1\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_connect_back=1\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=1\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_handler=dbgp\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_port=9000\n" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN pecl install redis-3.1.0 \
&& pecl install xdebug-2.5.0 \
&& docker-php-ext-enable redis xdebug

# Enable apache modules
RUN a2enmod rewrite
RUN a2enmod rewrite headers
37 changes: 22 additions & 15 deletions docker-compose.yml
Expand Up @@ -4,39 +4,46 @@ services:
webserver:
build:
context: ./bin/webserver
container_name: webserver
container_name: 'tnb-webserver'
restart: 'always'
ports:
- "80:80"
- "443:443"
links:
- db
- mysql
volumes:
- ${DOCUMENT_ROOT-./www}:/var/www/html
- ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
- ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
- ${LOG_DIR-./logs/apache2}:/var/log/apache2
db:
mysql:
build: ./bin/mysql
container_name: db
container_name: 'tnb-mysql'
restart: 'always'
ports:
- "3306:3306"
volumes:
- ${DATABASE_DIR-./data}:/var/lib/mysql
- ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql
- ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql
environment:
MYSQL_ROOT_PASSWORD: tiger
MYSQL_DATABASE: docker
MYSQL_USER: docker
MYSQL_PASSWORD: docker
MYSQL_DATABASE: tnb
MYSQL_USER: tnb
MYSQL_PASSWORD: tnb
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
container_name: 'tnb-phpmyadmin'
links:
- db
ports:
- 8080:80
- mysql
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: password
PMA_HOST: mysql
PMA_PORT: 3306
ports:
- '8080:80'
volumes:
- /sessions
- /sessions
redis:
container_name: 'tnb-redis'
image: redis:latest
ports:
- "6379:6379"
4 changes: 2 additions & 2 deletions sample.env
@@ -1,6 +1,6 @@
DOCUMENT_ROOT=./www
DATABASE_DIR=./data
PHP_INI=./config/php/php.ini
VHOSTS_DIR=./config/vhosts
APACHE_LOG_DIR=./logs/apache2
PHP_INI=./config/php/php.ini
MYSQL_DATA_DIR=./data/mysql
MYSQL_LOG_DIR=./logs/mysql
2 changes: 1 addition & 1 deletion www/test_db.php
@@ -1,5 +1,5 @@
<?php
$link = mysqli_connect("db", "docker", "docker", "docker");
$link = mysqli_connect("mysql", "tnb", "tnb", "tnb");

if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
Expand Down

0 comments on commit 9dc1d07

Please sign in to comment.