Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to customize the server name (+ several improvements) #100

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Symfony application's path (absolute or relative)
# Symfony application
SYMFONY_APP_PATH=../path/to/symfony/folder
SYMFONY_NGINX_HOST=symfony.local

# MySQL
MYSQL_ROOT_PASSWORD=root
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Docker-symfony gives you everything you need for developing Symfony application.
$ docker-compose up -d
```

3. Update your system host file (add symfony.local)
3. Update your system host file (add value you've assigned to `SYMFONY_NGINX_HOST` ENV variable)

```bash
# UNIX only: get containers IP address and update host (replace IP according to your configuration) (on Windows, edit C:\Windows\System32\drivers\etc\hosts)
$ sudo echo $(docker network inspect bridge | grep Gateway | grep -o -E '[0-9\.]+') "symfony.local" >> /etc/hosts
$ echo $(docker network inspect bridge | grep Gateway | grep -o -E '[0-9\.]+') 'YOUR_HOSTNAME' | sudo tee --append /etc/hosts
```

**Note:** For **OS X**, please take a look [here](https://docs.docker.com/docker-for-mac/networking/) and for **Windows** read [this](https://docs.docker.com/docker-for-windows/#/step-4-explore-the-application-and-run-examples) (4th step).
Expand Down
17 changes: 15 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,44 @@ version: '2'
services:
db:
image: mysql
container_name: docker-symfony-mysql
volumes:
- "./.data/db:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- 3306:3306
php:
build:
context: php7-fpm
args:
TIMEZONE: ${TIMEZONE}
container_name: docker-symfony-php
volumes:
- ${SYMFONY_APP_PATH}:/var/www/symfony
- ./logs/symfony:/var/www/symfony/app/logs
- ./logs/symfony:/var/www/symfony/var/logs
- ${SYMFONY_APP_PATH}:/var/www/symfony/var/logs
ports:
- 9000:9000
nginx:
build: nginx
image: nginx
container_name: docker-symfony-nginx
ports:
- 80:80
volumes_from:
- php
volumes:
- ./nginx/default.template:/etc/nginx/conf.d/default.template
- ./logs/nginx/:/var/log/nginx
environment:
- SYMFONY_NGINX_HOST=${SYMFONY_NGINX_HOST}
command: /bin/sh -c "envsubst '$$SYMFONY_NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
elk:
image: willdurand/elk
container_name: docker-symfony-elk
ports:
- 81:80
volumes:
Expand Down
4 changes: 2 additions & 2 deletions elk/logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ input {
}
file {
type => "symfony_dev"
path => "/var/www/symfony/app/logs/dev.log"
path => "/var/www/symfony/var/logs/dev.log"
start_position => beginning
}
file {
type => "symfony_prod"
path => "/var/www/symfony/app/logs/prod.log"
path => "/var/www/symfony/var/logs/prod.log"
start_position => beginning
}
}
Expand Down
21 changes: 0 additions & 21 deletions nginx/Dockerfile

This file was deleted.

6 changes: 4 additions & 2 deletions nginx/symfony.conf → nginx/default.template.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
server {
server_name symfony.local;
listen 80 default_server;
listen [::]:80 default_server;
server_name ${SYMFONY_NGINX_HOST};
root /var/www/symfony/web;

location / {
Expand All @@ -11,7 +13,7 @@ server {
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Expand Down
29 changes: 0 additions & 29 deletions nginx/nginx.conf

This file was deleted.

51 changes: 30 additions & 21 deletions php7-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
# See https://github.com/docker-library/php/blob/master/7.1/fpm/Dockerfile
FROM php:7.1-fpm
FROM php:7.2-fpm
ARG TIMEZONE

MAINTAINER Maxence POUTORD <[email protected]>
LABEL creator="Maxence POUTORD <[email protected]>"
LABEL maintainer="Julien DE CONTI <[email protected]>"

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

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer --version
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer --version

# Install Symfony
RUN curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony \
&& chmod a+x /usr/local/bin/symfony

# Set timezone
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone
RUN printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini
RUN "date"
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone \
&& printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini \
&& "date"

# Type docker-php-ext-install to see available extensions
# Install pdo mysql
RUN docker-php-ext-install pdo pdo_mysql

# Install symfony php-intl dependency
RUN docker-php-ext-configure intl && docker-php-ext-install intl

# Install php-opcache
RUN docker-php-ext-install opcache && docker-php-ext-enable opcache

# 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 sf="php app/console"' >> ~/.bashrc
RUN echo 'alias sf3="php bin/console"' >> ~/.bashrc
RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.idekey=\"PHPSTORM\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN echo 'alias sf="php bin/console"' >> ~/.bashrc

WORKDIR /var/www/symfony