-
-
Save meadsteve/47beb2a46179f44fa6b8f7ab4be36b15 to your computer and use it in GitHub Desktop.
docker example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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", "/install-composer.sh"] | |
RUN ./install-composer.sh | |
COPY ./composer.* / | |
RUN php composer.phar install | |
COPY ./code:/var/www/html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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