Skip to content

Instantly share code, notes, and snippets.

@philcross
Created April 2, 2019 07:54
Show Gist options
  • Save philcross/75de382d9c2dfe3041b0021d453bb355 to your computer and use it in GitHub Desktop.
Save philcross/75de382d9c2dfe3041b0021d453bb355 to your computer and use it in GitHub Desktop.
version: "3.1"
services:
webserver-nginx:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./code:/var/www/html
- ./conf/nginx.conf:/etc/nginx/conf.d/default.conf
links:
- webserver-php
webserver-php:
build: ./services/php/
image: webserver-php
volumes:
- ./code:/var/www/html
ports:
- 9000
#!/bin/sh
#services/php/docker-entrypoint
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
php composer.phar install
#services/php/Dockerfile
FROM php:7.3-fpm
WORKDIR /var/www/html
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_NO_INTERACTION=1
ENV COMPOSER_HOME=/usr/local/share/composer
RUN apt-get update && \
apt-get install -y --no-install-recommends wget git zip unzip
COPY ./docker-entrypoint /
RUN ["chmod", "+x", "/docker-entrypoint"]
ENTRYPOINT [ "/docker-entrypoint" ]
CMD ["sh", "-c", "/docker-entrypoint"]
#conf/nginx.conf
server {
index index.php index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass webserver-php:9000;
fastcgi_index public/index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment