Skip to content

Commit 07efd87

Browse files
committed
Nginx, PHP, Pinba, Composer and Git
1 parent eccd86b commit 07efd87

File tree

7 files changed

+237
-2
lines changed

7 files changed

+237
-2
lines changed

Dockerfile

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
FROM vendelev/supervisor
2+
3+
LABEL maintainer="Vendelev Artiom"
4+
LABEL version="1.0"
5+
LABEL image="vendelev/php"
6+
LABEL tag="7.1"
7+
LABEL description="Image for php-application"
8+
9+
# Install php 7.1 and pinba
10+
RUN apk add --no-cache \
11+
nginx \
12+
git \
13+
g++ \
14+
gcc \
15+
make \
16+
re2c \
17+
php7 \
18+
php7-fpm \
19+
php7-mbstring \
20+
php7-iconv \
21+
php7-mysqli \
22+
php7-pdo_mysql \
23+
php7-gd \
24+
php7-json \
25+
php7-memcached \
26+
php7-mcrypt \
27+
php7-amqp \
28+
php7-xdebug \
29+
php7-zip \
30+
php7-xml \
31+
php7-bcmath \
32+
php7-curl \
33+
php7-phar \
34+
php7-zlib \
35+
php7-pear \
36+
php7-soap \
37+
php7-pcntl \
38+
php7-ctype \
39+
php7-posix \
40+
php7-fileinfo \
41+
php7-session \
42+
php7-imagick \
43+
php7-opcache \
44+
php7-zip \
45+
php7-dev \
46+
php7-openssl \
47+
php7-redis \
48+
php7-pgsql\
49+
php7-intl \
50+
php7-gmp \
51+
php7-dom \
52+
php7-tokenizer \
53+
php7-xmlwriter \
54+
&& ln -s /etc/php7 /etc/php \
55+
&& ln -s /usr/sbin/php-fpm7 /usr/bin/php-fpm \
56+
&& ln -s /usr/lib/php7 /usr/lib/php \
57+
&& sed -i 's/127.0.0.1:9000/9000/g' /etc/php/php-fpm.d/www.conf \
58+
&& sed -i 's/user = nobody/user = nginx/g' /etc/php/php-fpm.d/www.conf \
59+
&& sed -i 's/group = nobody/group = nginx/g' /etc/php/php-fpm.d/www.conf \
60+
# Install pinba
61+
&& git clone https://github.com/tony2001/pinba_extension /tmp/pinba_extension \
62+
&& cd /tmp/pinba_extension \
63+
&& phpize \
64+
&& ./configure --enable-pinba \
65+
&& make install \
66+
# Clean
67+
&& apk del \
68+
g++ \
69+
gcc \
70+
make \
71+
re2c \
72+
autoconf \
73+
&& rm -frv /var/cache/apk/* \
74+
&& rm -frv /tmp/pinba_extension
75+
76+
WORKDIR /tmp
77+
78+
# Install composer global bin
79+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
80+
&& php composer-setup.php --install-dir=/bin --filename=composer \
81+
&& rm -fv composer-setup.php
82+
83+
RUN composer global require --prefer-dist --optimize-autoloader hirak/prestissimo
84+
85+
RUN mkdir /run/nginx \
86+
mkdir /var/www/logs
87+
88+
ARG GIT_USER_EMAIL=docker@php
89+
ARG GIT_USER_NAME=Docker-PHP
90+
91+
RUN git config --global user.email ${GIT_USER_EMAIL} \
92+
&& git config --global user.name ${GIT_USER_NAME}
93+
94+
ADD ./supervisor.d /etc/supervisor.d
95+
ADD ./pinba.ini /etc/php7/conf.d/20-pinba.ini
96+
ADD ./xdebug.ini /etc/php7/conf.d/xdebug.ini
97+
ADD ./default.conf /etc/nginx/conf.d/default.conf
98+
99+
WORKDIR /var/www/web
100+
101+
EXPOSE 80 9000

README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,57 @@
1-
# docker-alpine-nginx-php
2-
Docker container based on alpine 3.7 with Nginx 1.12, PHP 7.1 and PHP extantion Pinba
1+
# Docker image of Nginx and PHP
2+
Docker image based on Alpine Linux 3.7 with Nginx, PHP, PHP extension Pinba, Composer and Git
3+
4+
Run the image:
5+
`docker run -d --name php -p 80:80 vendelev/php:7.1`
6+
7+
Document root for your project: /var/www/web
8+
9+
Versions of apps:
10+
Nginx: 1.12.2
11+
PHP: 7.1.14
12+
Composer: 1.6.3
13+
14+
Image contains the following extensions:
15+
- mbstring
16+
- iconv
17+
- mysqli
18+
- pdo_mysql
19+
- gd
20+
- json
21+
- memcached
22+
- mcrypt
23+
- amqp
24+
- xdebug
25+
- zip
26+
- xml
27+
- bcmath
28+
- curl
29+
- phar
30+
- zlib
31+
- pear
32+
- soap
33+
- pcntl
34+
- ctype
35+
- posix
36+
- fileinfo
37+
- session
38+
- imagick
39+
- opcache
40+
- zip
41+
- dev
42+
- openssl
43+
- redis
44+
- pgsql
45+
- intl
46+
- gmp
47+
- dom
48+
- tokenizer
49+
- xmlwriter
50+
- pinba
51+
52+
The extensions Pinba and Xdebug are disabled (see pinba.ini, xdebug.ini), you can enable them in your child images. Expample: `RUN sed -i 's/pinba.enabled=0/pinba.enabled=1/g' /etc/php7/conf.d/20-pinba.ini`
53+
54+
By default, the image exposes the the following ports:
55+
- 80 Nginx
56+
- 9000 PHP
57+
- 9999 Supervisor

default.conf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
server {
2+
listen 80 default_server;
3+
listen [::]:80 default_server;
4+
5+
# Everything is a 404
6+
#location / {
7+
# return 500;
8+
#}
9+
10+
# You may need this to prevent return 404 recursion.
11+
location = /500.html {
12+
internal;
13+
}
14+
15+
charset utf-8;
16+
client_max_body_size 128M;
17+
18+
root /var/www/web/web;
19+
index index.php;
20+
21+
access_log /var/www/logs/site-access.log;
22+
error_log /var/www/logs/site-error.log;
23+
24+
location / {
25+
# Redirect everything that isn't a real file to index.php
26+
try_files $uri $uri/ /index.php?$args;
27+
}
28+
29+
location ~* \.(JPG|jpg1|jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpeg|avi|zip|gz|bz2|rar|swf|flv|exe|bmp|tiff|tif|ico|doc|docx|xls|xlsx|ppt|pptx|pdf|html|htm|txt|file|ttf|eot|woff|woff2|otf|mp4|ogv|webm|json)$ {
30+
try_files $uri =404;
31+
expires 24h;
32+
add_header X-Proxy static;
33+
add_header Access-Control-Allow-Origin *;
34+
}
35+
36+
error_page 404 /404.html;
37+
38+
location ~ \.php$ {
39+
fastcgi_pass localhost:9000;
40+
include fastcgi_params;
41+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
42+
fastcgi_param HTTPS $https if_not_empty;
43+
try_files $uri =404;
44+
45+
fastcgi_read_timeout 300;
46+
}
47+
48+
location ~* /\. {
49+
deny all;
50+
}
51+
}

pinba.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extension=pinba.so
2+
pinba.enabled=0
3+
pinba.server=pinba:30002

supervisor.d/nginx.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[program:nginx]
2+
directory=/var/www/web
3+
command=nginx -g 'daemon off;'
4+
autostart=true
5+
autorestart=true
6+
stderr_logfile=/var/log/supervisor/nginx.err.log
7+
stdout_logfile=/var/log/supervisor/nginx.out.log

supervisor.d/php.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[program:php7]
2+
directory=/var/www/web
3+
command=/usr/sbin/php-fpm7 --nodaemonize
4+
autostart=true
5+
autorestart=true
6+
stderr_logfile=/var/log/supervisor/php7.err.log
7+
stdout_logfile=/var/log/supervisor/php7.out.log

xdebug.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
xdebug.remote_enable=off
2+
xdebug.var_display_max_depth=16
3+
xdebug.var_display_max_data=1024
4+
xdebug.overload_var_dump=0
5+
xdebug.remote_autostart=true
6+
xdebug.remote_handler=dbgp
7+
xdebug.remote_mode=req
8+
xdebug.remote_port=10000
9+
xdebug.remote_log=/var/log/xdebug_remote.log
10+
xdebug.idekey=xdebug
11+
xdebug.remote_connect_back=Off

0 commit comments

Comments
 (0)