mirror of
https://github.com/mashirozx/docker-php-nginx.git
synced 2024-11-25 00:08:14 +08:00
Rewrote the example setup to have only one Docker container
This commit is contained in:
parent
fd5b5c096e
commit
16aaa4f31f
12
.travis.yml
Normal file
12
.travis.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
env:
|
||||||
|
global:
|
||||||
|
- COMMIT=${TRAVIS_COMMIT::8}
|
||||||
|
- REPO=trafex/php-nginx
|
||||||
|
|
||||||
|
script:
|
||||||
|
- docker --version
|
||||||
|
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
|
||||||
|
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
|
||||||
|
- docker build -t $REPO:$COMMIT .
|
||||||
|
- docker tag $REPO:$COMMIT $REPO:$TAG
|
||||||
|
- docker push $REPO
|
30
Dockerfile
30
Dockerfile
@ -1,5 +1,31 @@
|
|||||||
FROM debian:jessie
|
FROM php:7.0-fpm
|
||||||
|
|
||||||
|
# Install Nginx
|
||||||
|
ENV NGINX_VERSION 1.9.11-1~jessie
|
||||||
|
|
||||||
|
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
|
||||||
|
&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y ca-certificates nginx=${NGINX_VERSION} gettext-base \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install supervisor
|
||||||
|
RUN apt-get update && apt-get install -y supervisor
|
||||||
|
|
||||||
|
# Configure nginx
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY config/nginx.conf /etc/nginx/conf.d/nginx.conf
|
||||||
|
|
||||||
|
# Configure supervisor
|
||||||
|
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
|
# Configure PHP-FPM
|
||||||
|
COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini
|
||||||
|
|
||||||
|
# Add application
|
||||||
|
RUN mkdir -p /var/www/html
|
||||||
|
WORKDIR /var/www/html
|
||||||
COPY src/ /var/www/html/
|
COPY src/ /var/www/html/
|
||||||
|
|
||||||
VOLUME /var/www/html/
|
EXPOSE 80 443
|
||||||
|
CMD ["/usr/bin/supervisord"]
|
||||||
|
19
README.md
19
README.md
@ -1,27 +1,14 @@
|
|||||||
Docker PHP-FPM & Nginx setup
|
Docker PHP-FPM & Nginx setup
|
||||||
============================
|
============================
|
||||||
Example PHP-FPM & Nginx setup for Docker using docker-compose.
|
Example PHP-FPM 7 & Nginx 1.9 setup for Docker
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
Add this to your hosts file:
|
|
||||||
|
|
||||||
127.0.0.1 docker-app.dev
|
|
||||||
|
|
||||||
Start the Docker containers:
|
Start the Docker containers:
|
||||||
|
|
||||||
docker-compose up
|
sudo docker run -p 80:80 trafex/php-nginx
|
||||||
|
|
||||||
See the PHP info on http://docker-app.dev
|
|
||||||
|
|
||||||
Docker Hub
|
|
||||||
----------
|
|
||||||
The containers can be found on the Docker hub:
|
|
||||||
|
|
||||||
- [trafex/example-appdata](https://hub.docker.com/r/trafex/example-appdata)
|
|
||||||
- [trafex/example-nginx](https://hub.docker.com/r/trafex/example-nginx)
|
|
||||||
- [trafex/example-phpfpm](https://hub.docker.com/r/trafex/example-phpfpm)
|
|
||||||
|
|
||||||
|
See the PHP info on http://localhost, or the static html page on http://localhost/test.html
|
||||||
|
|
||||||
Resources & inspiration
|
Resources & inspiration
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@ -1,31 +1,24 @@
|
|||||||
server {
|
server {
|
||||||
listen 80; ## listen for ipv4; this line is default and implied
|
listen [::]:80 default_server;
|
||||||
listen [::]:80 default ipv6only=on; ## listen for ipv6
|
listen 80 default_server;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
root /var/www/html;
|
|
||||||
index index.php index.html index.htm;
|
|
||||||
|
|
||||||
# Make site accessible from http://localhost/
|
|
||||||
server_name docker-app.dev;
|
|
||||||
|
|
||||||
# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
|
|
||||||
sendfile off;
|
sendfile off;
|
||||||
|
|
||||||
# Add stdout logging
|
root /var/www/html;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
error_log /dev/stderr info;
|
error_log /dev/stderr info;
|
||||||
access_log /dev/stdout;
|
access_log /dev/stdout;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
# First attempt to serve request as file, then
|
# First attempt to serve request as file, then
|
||||||
# as directory, then fall back to index.html
|
# as directory, then fall back to index.php
|
||||||
try_files $uri $uri/ /index.php?q=$uri&$args;
|
try_files $uri $uri/ /index.php?q=$uri&$args;
|
||||||
}
|
}
|
||||||
|
|
||||||
#error_page 404 /404.html;
|
|
||||||
|
|
||||||
# redirect server error pages to the static page /50x.html
|
# redirect server error pages to the static page /50x.html
|
||||||
#
|
#
|
||||||
error_page 500 502 503 504 /50x.html;
|
error_page 500 502 503 504 /50x.html;
|
||||||
location = /50x.html {
|
location = /50x.html {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
@ -36,7 +29,7 @@ server {
|
|||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
fastcgi_pass UPSTREAM_HOST:UPSTREAM_PORT;
|
fastcgi_pass localhost:9000;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
16
config/supervisord.conf
Normal file
16
config/supervisord.conf
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
|
||||||
|
[program:php-fpm]
|
||||||
|
command=php-fpm
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
command=nginx -g 'daemon off;'
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
@ -1,19 +0,0 @@
|
|||||||
appdata:
|
|
||||||
build: .
|
|
||||||
|
|
||||||
fpm:
|
|
||||||
build: ./fpm
|
|
||||||
volumes_from:
|
|
||||||
- appdata
|
|
||||||
|
|
||||||
nginx:
|
|
||||||
build: ./nginx
|
|
||||||
links:
|
|
||||||
- fpm
|
|
||||||
volumes_from:
|
|
||||||
- appdata
|
|
||||||
ports:
|
|
||||||
- 80:80
|
|
||||||
environment:
|
|
||||||
- UPSTREAM_HOST=fpm
|
|
||||||
- UPSTREAM_PORT=9000
|
|
@ -1,3 +0,0 @@
|
|||||||
FROM php:7.0-fpm
|
|
||||||
|
|
||||||
COPY php.ini /usr/local/etc/php/conf.d/custom.ini
|
|
@ -1,9 +0,0 @@
|
|||||||
FROM nginx:1.9
|
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/app.conf
|
|
||||||
|
|
||||||
CMD /bin/bash -c envsubst < /etc/nginx/conf.d/app.conf.template > /etc/nginx/conf.d/app.conf && nginx -g 'daemon off;'
|
|
||||||
|
|
||||||
CMD sed -i 's/UPSTREAM_HOST/'"$UPSTREAM_HOST"'/g' /etc/nginx/conf.d/app.conf \
|
|
||||||
&& sed -i 's/UPSTREAM_PORT/'"$UPSTREAM_PORT"'/g' /etc/nginx/conf.d/app.conf \
|
|
||||||
&& nginx -g 'daemon off;'
|
|
1
src/test.html
Normal file
1
src/test.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
This should also work and be served by Nginx
|
Loading…
Reference in New Issue
Block a user