Skip to content

Instantly share code, notes, and snippets.

@emulienfou
Last active January 16, 2020 16:06
Show Gist options
  • Save emulienfou/20c86bd0e1ab5c3f227a757d9688c7a4 to your computer and use it in GitHub Desktop.
Save emulienfou/20c86bd0e1ab5c3f227a757d9688c7a4 to your computer and use it in GitHub Desktop.
Docker PHP-FPM 7.3.10, Nginx, MySQL
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;
}
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: {}
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