Docker production ready php-fpm and nginx configuration
At this time I use smth like:
Dockerfile:
FROM php:fpm
COPY . /var/www/app/
WORKDIR /var/www/app/
RUN composer install
EXPOSE 9000
VOLUME /var/www/app/web
Dockerfile.nginx
FROM nginx
COPY default /etc/nginx/default
docker-compose.yml
app:
build:
context: .
web:
build:
context: .
dockerfile: Dockerfile.nginx
volumes_from: app
But in few days on 17.05 release we can do in one Dockerfile smth like:
FROM php:cli AS builder
COPY . /var/www/app/
WORKDIR /var/www/app/
RUN composer install && bin/console assets:dump
FROM php:fpm AS app
COPY --from=builder /var/www/app/src /var/www/app/vendor /var/www/app/
COPY --from=builder /var/www/app/web/app.php /var/www/app/vendo /var/www/app/web/
FROM nginx AS web
COPY default /etc/nginx/default
COPY --from=builder /var/www/app/web /var/www/app/web
I solve the problem by making a shared volume with the docker-compose file:
version: '3'
volumes:
share_place:
services:
php:
image: php:5-fpm-alpine
ports:
- 9000:9000
volumes:
- share_place:/var/www/app
nginx:
image: nginx:alpine
ports:
- 3000:80
volumes:
- share_place:/var/www/app
This will create a volume share_place that will share the data between the two container.