Skip to content

Commit

Permalink
feat(symfony4-php72) Refacto docker and docker-composee
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grevin committed Dec 27, 2017
1 parent db7d86f commit 55c0846
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 277 deletions.
4 changes: 2 additions & 2 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# APP
SYMFONY_APP_PATH=/
APP_DIR=/var/www/symfony
SYMFONY_ENV=dev

# DOCKER
LOGS_DIR=/docker/logs
Expand All @@ -12,7 +13,6 @@ POSTGRES_PORT=

# PORT WEB
WEB_PORT=
ELK_PORT=

# SYMFONY
SECRET=
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"files": ["vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"]
},
"require": {
"php": ">=7.1",
"php": ">=7.2",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"friendsofsymfony/rest-bundle": "^2.2",
Expand Down
79 changes: 37 additions & 42 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
version: '2'
version: '3'

services:
postgres:
image: postgres:9.6
ports:
- ${POSTGRES_PORT}:5432
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
postgres:
image: postgres:10
env_file:
- .env
ports:
- ${POSTGRES_PORT}:5432

php:
build: docker/php7-fpm
env_file: ./.env
volumes:
- ${SYMFONY_APP_PATH}:/var/www/symfony
links:
- postgres
php:
build:
context: .
dockerfile: docker/php/Dockerfile
env_file:
- .env
user: www-data
working_dir: ${APP_DIR}
volumes:
- ${PWD}:${APP_DIR}

nginx:
build: docker/nginx
ports:
- ${WEB_PORT}:80
volumes_from:
- php
volumes:
- ${LOGS_DIR}/nginx/:/var/log/nginx
nginx:
build:
context: .
dockerfile: docker/nginx/Dockerfile
ports:
- ${WEB_PORT}:80
volumes:
- ${PWD}:${APP_DIR}

elk:
image: willdurand/elk
ports:
- ${ELK_PORT}:80
volumes:
- ./docker/elk/logstash:/etc/logstash
- ./docker/elk/logstash/patterns:/opt/logstash/patterns
volumes_from:
- php
- nginx
redis:
image: redis:4

redis:
image: redis:3.2.10

node:
build: docker/node
volumes:
- ${SYMFONY_APP_PATH}:/var/www/symfony
command: bash -c "yarn && yarn dev"
node:
build:
context: .
dockerfile: docker/node/Dockerfile
env_file:
- .env
working_dir: ${APP_DIR}
volumes:
- ${PWD}:${APP_DIR}
command: bash -c "yarn && yarn dev"
39 changes: 0 additions & 39 deletions docker/elk/logstash/logstash.conf

This file was deleted.

85 changes: 0 additions & 85 deletions docker/elk/logstash/patterns/default.conf

This file was deleted.

1 change: 0 additions & 1 deletion docker/elk/logstash/patterns/nginx.conf

This file was deleted.

34 changes: 0 additions & 34 deletions docker/elk/logstash/patterns/symfony.conf

This file was deleted.

24 changes: 5 additions & 19 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
FROM debian:jessie
FROM nginx:1.13

MAINTAINER Maxence POUTORD <[email protected]>
RUN rm -f /etc/nginx/nginx.conf /etc/nginx/conf.d/*

RUN apt-get update && apt-get install -y \
nginx

ADD nginx.conf /etc/nginx/
ADD symfony.conf /etc/nginx/sites-available/

RUN ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/sites-enabled/symfony
RUN rm /etc/nginx/sites-enabled/default

RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf

RUN usermod -u 1000 www-data

CMD ["nginx"]

EXPOSE 80
EXPOSE 443
ADD ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
ADD ./docker/nginx/upstream.conf /etc/nginx/conf.d/upstream.conf
ADD ./docker/nginx/symfony.conf /etc/nginx/conf.d/symfony.conf
17 changes: 5 additions & 12 deletions docker/nginx/symfony.conf
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
server {
server_name _;
root /var/www/symfony/web;
root /var/www/symfony/public;
index index.php;

location / {
try_files $uri @rewriteapp;
}

location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
location ~ \.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}

error_log /var/log/nginx/symfony_error.log;
access_log /var/log/nginx/symfony_access.log;
error_log /var/www/symfony/var/log/nginx.error.log;
access_log /var/www/symfony/var/log/nginx.access.log;
}
3 changes: 3 additions & 0 deletions docker/nginx/upstream.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
upstream php-upstream {
server php:9000;
}
2 changes: 1 addition & 1 deletion docker/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:8
FROM node:9

RUN apt-get update && \
apt-get install -y \
Expand Down
24 changes: 24 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM php:7.2-fpm

RUN apt-get update && \
apt-get install -y \
git \
unzip \
libpq-dev

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer --version
RUN mkdir /var/www/.composer && chown -R www-data /var/www/.composer

# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
RUN "date"

# Type docker-php-ext-install to see available extensions
RUN docker-php-ext-install pdo_pgsql

RUN usermod -u 1000 www-data

WORKDIR /var/www/symfony
Loading

0 comments on commit 55c0846

Please sign in to comment.