From db2be56d4d603e83463e9ee1ec1faf688a41c14e Mon Sep 17 00:00:00 2001 From: "developer@nicolas-grevin.com" Date: Fri, 5 Jan 2018 14:12:06 +0100 Subject: [PATCH] article(upgrade-docker) --- .env.dist | 22 +++--- .gitignore | 3 - app/config/config.yml | 4 +- app/config/parameters.yml | 4 +- bin/app | 10 +-- bin/console | 0 docker-compose.yml | 80 ++++++++++----------- docker/elk/logstash/logstash.conf | 39 ----------- docker/elk/logstash/patterns/default.conf | 85 ----------------------- docker/elk/logstash/patterns/nginx.conf | 1 - docker/elk/logstash/patterns/symfony.conf | 34 --------- docker/nginx/Dockerfile | 25 +++---- docker/nginx/nginx.conf | 2 - docker/nginx/symfony.conf | 4 +- docker/nginx/upstream.conf | 3 + docker/node/Dockerfile | 14 +--- docker/php/Dockerfile | 24 +++++++ docker/php/php.ini | 10 +++ docker/php7-fpm/Dockerfile | 41 ----------- 19 files changed, 108 insertions(+), 297 deletions(-) mode change 100755 => 100644 bin/console delete mode 100644 docker/elk/logstash/logstash.conf delete mode 100644 docker/elk/logstash/patterns/default.conf delete mode 100644 docker/elk/logstash/patterns/nginx.conf delete mode 100644 docker/elk/logstash/patterns/symfony.conf create mode 100644 docker/nginx/upstream.conf create mode 100644 docker/php/Dockerfile create mode 100644 docker/php/php.ini delete mode 100644 docker/php7-fpm/Dockerfile diff --git a/.env.dist b/.env.dist index bc2c9a8f..50897231 100644 --- a/.env.dist +++ b/.env.dist @@ -1,27 +1,29 @@ # APP -SYMFONY_APP_PATH=/ +APP_DIR=/var/www/symfony -# DOCKER -LOGS_DIR=/docker/logs +# Symfony +APP_ENV=dev +APP_DEBUG=1 +SECRET= + +# NODE +NODE_ENV=dev # DATABASE +POSTGRES_HOST= POSTGRES_DB= POSTGRES_USER= POSTGRES_PASSWORD= POSTGRES_PORT= -# PORT WEB -WEB_PORT= -ELK_PORT= - -# SYMFONY -SECRET= - #SMTP SMTP_USER= SMTP_PASSWORD= SMTP_HOST= SMTP_TRANSPORT= +# PORT WEB +WEB_PORT= + #REDIS REDIS_DSN= diff --git a/.gitignore b/.gitignore index dc20ef30..e73df539 100644 --- a/.gitignore +++ b/.gitignore @@ -21,9 +21,6 @@ ### PHPUnit /phpunit.xml -### Docker -docker/logs/ - ### NodeJS - NPM - YARN node_modules/ npm-debug.log* diff --git a/app/config/config.yml b/app/config/config.yml index 5dd8c46c..01054474 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -86,8 +86,8 @@ snc_redis: type: predis logging: false alias: session_client - dsn: %redis_dsn% - options: %redis_options% + dsn: '%redis_dsn%' + options: '%redis_options%' session: client: session_client prefix: app_session_ diff --git a/app/config/parameters.yml b/app/config/parameters.yml index 454dd53f..004b60a8 100644 --- a/app/config/parameters.yml +++ b/app/config/parameters.yml @@ -7,7 +7,7 @@ parameters: database_password: '%env(POSTGRES_PASSWORD)%' # Mailer parameters - mailer_transport: %env(SMTP_TRANSPORT)% + mailer_transport: '%env(SMTP_TRANSPORT)%' mailer_host: '%env(SMTP_HOST)%' mailer_user: '%env(SMTP_USER)%' mailer_password: '%env(SMTP_PASSWORD)%' @@ -16,6 +16,6 @@ parameters: secret: '%env(SECRET)%' # Redis parameters - redis_dsn: '%env(REDIS_DSN)%' + redis_dsn: 'redis://%env(REDIS_DSN)%' redis_options: ~ session_ttl: 86400 diff --git a/bin/app b/bin/app index a35b391e..0dd870f2 100755 --- a/bin/app +++ b/bin/app @@ -53,10 +53,10 @@ stop () docker-compose stop } -# run bash -bash () +# run sh +sh () { - docker-compose exec --user www-data php bash + docker-compose exec --user www-data php sh } # exec a command into app container (as root) @@ -105,7 +105,7 @@ usage () init Initialize project start Start project stop Stop project - bash Use bash inside the app container + sh Use sh inside the app container exec Executes a command inside the app container destroy Remove all the project Docker containers with their volumes console Use the Symfony console @@ -123,7 +123,7 @@ main () exit 0 fi - if [[ ! $1 =~ ^init|start|stop|bash|destroy|console|composer|exec|tests$ ]]; then + if [[ ! $1 =~ ^init|start|stop|sh|destroy|console|composer|exec|tests$ ]]; then echo "$1 is not a supported command" exit 1 fi diff --git a/bin/console b/bin/console old mode 100755 new mode 100644 diff --git a/docker-compose.yml b/docker-compose.yml index 38481ac6..987f2617 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,48 +1,44 @@ -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-alpine + env_file: + - .env + ports: + - ${POSTGRES_PORT}:5432 - php: - build: docker/php7-fpm - env_file: ./.env - volumes: - - ${PWD}:/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-alpine - redis: - image: redis:3.2.10 - - node: - build: docker/node - volumes: - - ${SYMFONY_APP_PATH}:/var/www/symfony - command: bash -c "yarn && yarn dev" \ No newline at end of file + node: + build: + context: . + dockerfile: docker/node/Dockerfile + env_file: + - .env + user: node + working_dir: ${APP_DIR} + volumes: + - ${PWD}:${APP_DIR} + command: sh -c "yarn && yarn dev" diff --git a/docker/elk/logstash/logstash.conf b/docker/elk/logstash/logstash.conf deleted file mode 100644 index f9e14bd5..00000000 --- a/docker/elk/logstash/logstash.conf +++ /dev/null @@ -1,39 +0,0 @@ -input { - file { - type => "nginx_access" - path => "/var/log/nginx/symfony_access.log" - start_position => beginning - } - file { - type => "symfony_dev" - path => "/var/www/symfony/app/logs/dev.log" - start_position => beginning - } - file { - type => "symfony_prod" - path => "/var/www/symfony/app/logs/prod.log" - start_position => beginning - } -} - -filter { - if [type] == "nginx_access" { - grok { - patterns_dir => "./patterns" - match => { "message" => "%{NGINXACCESS}"} - } - } - else if [type] in ["symfony_dev", "symfony_prod"] { - grok { - patterns_dir => "./patterns" - match => { "message" => "%{SYMFONY}"} - } - } -} - -output { - elasticsearch { - host => "localhost" - cluster => "logstash" - } -} \ No newline at end of file diff --git a/docker/elk/logstash/patterns/default.conf b/docker/elk/logstash/patterns/default.conf deleted file mode 100644 index 70a2900c..00000000 --- a/docker/elk/logstash/patterns/default.conf +++ /dev/null @@ -1,85 +0,0 @@ -USERNAME [a-zA-Z0-9._-]+ -USER %{USERNAME} -INT (?:[+-]?(?:[0-9]+)) -BASE10NUM (?[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+))) -NUMBER (?:%{BASE10NUM}) -BASE16NUM (?(?"(?>\\.|[^\\"]+)+"|""|(?>'(?>\\.|[^\\']+)+')|''|(?>`(?>\\.|[^\\`]+)+`)|``)) -UUID [A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12} -# Networking -MAC (?:%{CISCOMAC}|%{WINDOWSMAC}|%{COMMONMAC}) -CISCOMAC (?:(?:[A-Fa-f0-9]{4}\.){2}[A-Fa-f0-9]{4}) -WINDOWSMAC (?:(?:[A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2}) -COMMONMAC (?:(?:[A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}) -IPV6 ((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)? -IPV4 (?/(?>[\w_%!$@:.,-]+|\\.)*)+ -TTY (?:/dev/(pts|tty([pq])?)(\w+)?/?(?:[0-9]+)) -WINPATH (?>[A-Za-z]+:|\\)(?:\\[^\\?*]*)+ -URIPROTO [A-Za-z]+(\+[A-Za-z+]+)? -URIHOST %{IPORHOST}(?::%{POSINT:port})? -# uripath comes loosely from RFC1738, but mostly from what Firefox -# doesn't turn into %XX -URIPATH (?:/[A-Za-z0-9$.+!*'(){},~:;=@#%_\-]*)+ -#URIPARAM \?(?:[A-Za-z0-9]+(?:=(?:[^&]*))?(?:&(?:[A-Za-z0-9]+(?:=(?:[^&]*))?)?)*)? -URIPARAM \?[A-Za-z0-9$.+!*'|(){},~@#%&/=:;_?\-\[\]]* -URIPATHPARAM %{URIPATH}(?:%{URIPARAM})? -URI %{URIPROTO}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST})?(?:%{URIPATHPARAM})? -# Months: January, Feb, 3, 03, 12, December -MONTH \b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\b -MONTHNUM (?:0?[1-9]|1[0-2]) -MONTHNUM2 (?:0[1-9]|1[0-2]) -MONTHDAY (?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9]) -# Days: Monday, Tue, Thu, etc... -DAY (?:Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?) -# Years? -YEAR (?>\d\d){1,2} -HOUR (?:2[0123]|[01]?[0-9]) -MINUTE (?:[0-5][0-9]) -# '60' is a leap second in most time standards and thus is valid. -SECOND (?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?) -TIME (?!<[0-9])%{HOUR}:%{MINUTE}(?::%{SECOND})(?![0-9]) -# datestamp is YYYY/MM/DD-HH:MM:SS.UUUU (or something like it) -DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR} -DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR} -ISO8601_TIMEZONE (?:Z|[+-]%{HOUR}(?::?%{MINUTE})) -ISO8601_SECOND (?:%{SECOND}|60) -TIMESTAMP_ISO8601 %{YEAR}-%{MONTHNUM}-%{MONTHDAY}[T ]%{HOUR}:?%{MINUTE}(?::?%{SECOND})?%{ISO8601_TIMEZONE}? -DATE %{DATE_US}|%{DATE_EU} -DATESTAMP %{DATE}[- ]%{TIME} -TZ (?:[PMCE][SD]T|UTC) -DATESTAMP_RFC822 %{DAY} %{MONTH} %{MONTHDAY} %{YEAR} %{TIME} %{TZ} -DATESTAMP_RFC2822 %{DAY}, %{MONTHDAY} %{MONTH} %{YEAR} %{TIME} %{ISO8601_TIMEZONE} -DATESTAMP_OTHER %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{TZ} %{YEAR} -DATESTAMP_EVENTLOG %{YEAR}%{MONTHNUM2}%{MONTHDAY}%{HOUR}%{MINUTE}%{SECOND} -# Syslog Dates: Month Day HH:MM:SS -SYSLOGTIMESTAMP %{MONTH} +%{MONTHDAY} %{TIME} -PROG (?:[\w._/%-]+) -SYSLOGPROG %{PROG:program}(?:\[%{POSINT:pid}\])? -SYSLOGHOST %{IPORHOST} -SYSLOGFACILITY <%{NONNEGINT:facility}.%{NONNEGINT:priority}> -HTTPDATE %{MONTHDAY}/%{MONTH}/%{YEAR}:%{TIME} %{INT} -# Shortcuts -QS %{QUOTEDSTRING} -# Log formats -SYSLOGBASE %{SYSLOGTIMESTAMP:timestamp} (?:%{SYSLOGFACILITY} )?%{SYSLOGHOST:logsource} %{SYSLOGPROG}: -COMMONAPACHELOG %{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-) -COMBINEDAPACHELOG %{COMMONAPACHELOG} %{QS:referrer} %{QS:agent} -# Log Levels -LOGLEVEL ([Aa]lert|ALERT|[Tt]race|TRACE|[Dd]ebug|DEBUG|[Nn]otice|NOTICE|[Ii]nfo|INFO|[Ww]arn?(?:ing)?|WARN?(?:ING)?|[Ee]rr?(?:or)?|ERR?(?:OR)?|[Cc]rit?(?:ical)?|CRIT?(?:ICAL)?|[Ff]atal|FATAL|[Ss]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?) \ No newline at end of file diff --git a/docker/elk/logstash/patterns/nginx.conf b/docker/elk/logstash/patterns/nginx.conf deleted file mode 100644 index 9025e084..00000000 --- a/docker/elk/logstash/patterns/nginx.conf +++ /dev/null @@ -1 +0,0 @@ -NGINXACCESS %{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{URIPATHPARAM:request}(?: HTTP/%{NUMBER:httpversion})?|-)" %{NUMBER:response} (?:%{NUMBER:bytes}|-) "(?:%{URI:referrer}|-)" %{QS:agent} %{NUMBER:request_time} %{NUMBER:upstream_response_time} %{NUMBER:gzip_ratio} (?:%{WORD:cache_hit}|-)%{GREEDYDATA} \ No newline at end of file diff --git a/docker/elk/logstash/patterns/symfony.conf b/docker/elk/logstash/patterns/symfony.conf deleted file mode 100644 index d8d59140..00000000 --- a/docker/elk/logstash/patterns/symfony.conf +++ /dev/null @@ -1,34 +0,0 @@ -VERYGREEDYDATA (.|\n)* - -SYMFONY_EXCEPTION [^:]* - -SYMFONY_LOG_TYPE request|security|app|profiler|doctrine|event -SYMFONY_LOG_LEVEL DEBUG|INFO|WARNING|ERROR|CRITICAL|ALERT -SYMFONY_LOG %{SYMFONY_LOG_TYPE:log_type}\.%{SYMFONY_LOG_LEVEL:log_level} - -SYMFONY_PARAMETER "[^"]*":( )?"[^"]*" -SYMFONY_PARAMETERS (%{SYMFONY_PARAMETER}(, )?)* -SYMFONY_CONTEXT {.*} -SYMFONY_REQUEST_METHOD GET|POST|PUT|DELETE|HEAD|OPTIONS|CONNECT -SYMFONY_REQUEST_PARAMETERS {"url":"%{GREEDYDATA:request_url}","ip":"%{IP:request_ip}","http_method":"%{SYMFONY_REQUEST_METHOD:request_method}"} - -SYMFONY_REQUEST_INFO Matched route "%{GREEDYDATA:route}" \(parameters: %{SYMFONY_PARAMETERS:parameters}\) -SYMFONY_REQUEST_UNCAUGHT_EXCEPTION %{SYMFONY_EXCEPTION:exception}: %{VERYGREEDYDATA:exception_message} \(uncaught exception\) at %{VERYGREEDYDATA:exception_file} line %{NUMBER:exception_file_line} -SYMFONY_REQUEST_CRITICAL Exception thrown when handling an exception \(ErrorException: %{GREEDYDATA:exception_message} in %{GREEDYDATA:exception_file} line %{NUMBER:exception_file_line}\) -SYMFONY_SECURITY_WARNING_USER_MISSING Username "%{GREEDYDATA:user}" could not be found. -SYMFONY_SECURITY_INFO_USER_AUTHENTICATED User "%{GREEDYDATA:user}" has been authenticated successfully -SYMFONY_SECURITY_INFO_AUTHENTICATION_FAILED Authentication request failed: %{GREEDYDATA:authentication_fail_reason} -SYMFONY_SECURITY_DEBUG Username "%{GREEDYDATA:user}" was reloaded from user provider. -SYMFONY_EVENT_DEBUG_NOTIFICATION Notified event "%{GREEDYDATA:event}" to listener "%{GREEDYDATA:listener}". -SYMFONY_EVENT_DEBUG_PROPAGATION_STOP Listener "%{GREEDYDATA:listener}" stopped propagation of the event "%{GREEDYDATA:event}". -SYMFONY_DOCTRINE_DEBUG (?<=doctrine.DEBUG: ).* - -SYMFONY_REQUEST %{SYMFONY_REQUEST_INFO}|%{SYMFONY_REQUEST_UNCAUGHT_EXCEPTION}|%{SYMFONY_REQUEST_CRITICAL} -SYMFONY_SECURITY %{SYMFONY_SECURITY_WARNING_USER_MISSING}|%{SYMFONY_SECURITY_INFO_USER_AUTHENTICATED}|%{SYMFONY_SECURITY_DEBUG}|%{SYMFONY_SECURITY_INFO_AUTHENTICATION_FAILED} -SYMFONY_EVENT %{SYMFONY_EVENT_DEBUG_NOTIFICATION}|%{SYMFONY_EVENT_DEBUG_PROPAGATION_STOP} -SYMFONY_DOCTRINE %{SYMFONY_DOCTRINE_DEBUG:doctrine_sql_query} -SYMFONY_VARIOUS_INFO Write SecurityContext in the session|Reloading user from user provider.|Read SecurityContext from the session|Populated SecurityContext with an anonymous Token|Access is denied (and user is neither anonymous, nor remember-me)|Unable to store the profiler information.|Remember-me cookie accepted. - -SYMFONY_LOG_MESSAGE %{SYMFONY_REQUEST}|%{SYMFONY_SECURITY}|%{SYMFONY_EVENT}|%{SYMFONY_DOCTRINE}|%{SYMFONY_VARIOUS_INFO:log_various_info}|%{VERYGREEDYDATA:log_unparsed_message} - -SYMFONY ^\[%{TIMESTAMP_ISO8601:date}\] %{SYMFONY_LOG}: %{SYMFONY_LOG_MESSAGE:log_message} (\[\]|%{SYMFONY_CONTEXT:log_context}) (\[\]|%{SYMFONY_REQUEST_PARAMETERS:log_request}) \ No newline at end of file diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 8011b3ab..17a3d44a 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -1,21 +1,12 @@ -FROM debian:jessie +FROM nginx:1.13-alpine -MAINTAINER Maxence POUTORD +RUN apk --no-cache add shadow -RUN apt-get update && apt-get install -y \ - nginx +RUN rm -f /etc/nginx/nginx.conf /etc/nginx/conf.d/* -ADD nginx.conf /etc/nginx/ -ADD symfony.conf /etc/nginx/sites-available/ +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 -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 +RUN addgroup -g 1000 -S www-data && \ + adduser -u 1000 -D -S -G www-data www-data diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index a9ecf0e5..f25e8ce2 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -25,5 +25,3 @@ http { include /etc/nginx/sites-enabled/*; open_file_cache max=100; } - -daemon off; diff --git a/docker/nginx/symfony.conf b/docker/nginx/symfony.conf index 3965ffa6..dc69a4da 100644 --- a/docker/nginx/symfony.conf +++ b/docker/nginx/symfony.conf @@ -18,6 +18,6 @@ server { 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/logs/nginx_error.log; + access_log /var/www/symfony/var/logs/nginx_access.log; } diff --git a/docker/nginx/upstream.conf b/docker/nginx/upstream.conf new file mode 100644 index 00000000..af558ed8 --- /dev/null +++ b/docker/nginx/upstream.conf @@ -0,0 +1,3 @@ +upstream php-upstream { + server php:9000; +} diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index a3f56b8a..1d958717 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -1,13 +1,3 @@ -FROM node:8 +FROM node:9-alpine -RUN apt-get update && \ - apt-get install -y \ - curl \ - apt-transport-https - -RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - -RUN apt-get update && apt-get install yarn - -WORKDIR /var/www/symfony +RUN apk add --no-cache python make g++ \ No newline at end of file diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 00000000..815e6652 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,24 @@ +FROM php:7.2-fpm-alpine + +ADD docker/php/php.ini ${PHP_INI_DIR}/php.ini + +RUN apk --no-cache add \ + git \ + pcre-dev \ + postgresql-dev \ + shadow + +RUN usermod -u 1000 www-data + +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +RUN sh -s www-data -c "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 opcache diff --git a/docker/php/php.ini b/docker/php/php.ini new file mode 100644 index 00000000..096aa9e1 --- /dev/null +++ b/docker/php/php.ini @@ -0,0 +1,10 @@ +short_open_tag = Off +memory_limit = 512M +date.timezone = Europe/Paris + +apc.enable_cli = 1 + +# http://symfony.com/doc/current/performance.html +opcache.max_accelerated_files = 20000 +realpath_cache_size = 4096K +realpath_cache_ttl = 600 diff --git a/docker/php7-fpm/Dockerfile b/docker/php7-fpm/Dockerfile deleted file mode 100644 index 47d0b00a..00000000 --- a/docker/php7-fpm/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -# See https://github.com/docker-library/php/blob/4677ca134fe48d20c820a19becb99198824d78e3/7.0/fpm/Dockerfile -FROM php:7.1-fpm - -MAINTAINER Maxence POUTORD - -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 pdo_pgsql - -# install xdebug -RUN pecl install xdebug -RUN docker-php-ext-enable xdebug - -RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.idekey=\"PHPSTORM\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - -RUN echo 'alias sf3="php bin/console"' >> ~/.bashrc - -RUN usermod -u 1000 www-data - -WORKDIR /var/www/symfony