Skip to content

Instantly share code, notes, and snippets.

@pumano
Created November 5, 2019 08:51
Show Gist options
  • Save pumano/34e5a9962899e8f67255c41ce189d1c8 to your computer and use it in GitHub Desktop.
Save pumano/34e5a9962899e8f67255c41ce189d1c8 to your computer and use it in GitHub Desktop.
php + nginx + composer docker-compose for development
server {
listen 80;
listen [::]:80;
server_name localhost;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location / {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
version: '3'
services:
web:
image: nginx:alpine
ports:
- "8082:80"
volumes:
- "./api:/var/www/html"
- "./default.conf:/etc/nginx/conf.d/default.conf"
depends_on:
- php
networks:
- www
php:
build:
context: .
ports:
- "9000:9000"
volumes:
- "./api:/app"
networks:
- www
networks:
www:
FROM composer:1.7 as builder
COPY composer.json composer.lock /app/
RUN composer install \
--ignore-platform-reqs \
--no-autoloader \
--no-interaction \
--no-scripts
COPY ./api /app/
RUN composer dump-autoload --optimize --classmap-authoritative
FROM php:7.2-fpm-alpine
WORKDIR /app
RUN apk --update upgrade \
&& apk add zip unzip wget curl
COPY --from=builder /app /var/www/html/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment