Last active
January 16, 2020 16:06
-
-
Save emulienfou/20c86bd0e1ab5c3f227a757d9688c7a4 to your computer and use it in GitHub Desktop.
Docker PHP-FPM 7.3.10, Nginx, MySQL
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
server { | |
listen 80 default_server; | |
server_name _; | |
root /var/www/admin; | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass php:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
error_log /var/log/nginx/api_error.log; | |
access_log /var/log/nginx/api_access.log; | |
} |
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.4' | |
services: | |
nginx: | |
build: | |
context: . | |
target: nginx | |
dockerfile: Dockerfile | |
depends_on: | |
- php | |
ports: | |
- target: 80 | |
published: 8080 | |
protocol: tcp | |
volumes: | |
- .:/var/www | |
working_dir: /var/www | |
php: | |
build: | |
context: . | |
target: php | |
dockerfile: Dockerfile | |
depends_on: | |
- db | |
volumes: | |
- .:/var/www | |
working_dir: /var/www | |
db: | |
image: mysql:5.7.21 | |
ports: | |
- target: 3306 | |
published: 3306 | |
protocol: tcp | |
volumes: | |
- db-data:/var/lib/mysql:rw | |
environment: | |
MYSQL_USER: demo | |
MYSQL_PASSWORD: demo | |
MYSQL_ROOT_PASSWORD: secret | |
MYSQL_DATABASE: demo | |
volumes: | |
db-data: {} |
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
FROM php:7.3.10-fpm-alpine AS PHP | |
# persistent / runtime deps | |
RUN apk add --no-cache \ | |
acl \ | |
fcgi \ | |
file \ | |
gettext \ | |
git \ | |
; | |
RUN apk add --no-cache --virtual .build-deps \ | |
libzip-dev \ | |
zlib-dev \ | |
; \ | |
\ | |
docker-php-ext-configure zip --with-libzip; \ | |
docker-php-ext-install -j$(nproc) \ | |
zip \ | |
; | |
# Install Composer | |
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | |
# prevent the reinstallation of vendors at every changes in the source code | |
COPY composer.json composer.lock symfony.lock ./ | |
RUN composer install | |
CMD ["php-fpm"] | |
FROM nginx:1.12.2 AS nginx | |
COPY default.conf /etc/nginx/conf.d/default.conf | |
WORKDIR /var/www |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment