From 70f435b5a5a37a1440c8be718805d3d16150f038 Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Mon, 14 Jan 2019 19:40:41 +0100
Subject: [PATCH 01/11] Implement Docker

---
 .env                                     |   1 +
 .gitignore                               |   4 +
 .php_cs.dist                             |   1 +
 Dockerfile                               | 181 +++++++++++++++++++++++
 Makefile                                 | 165 +++++++++++++++++++++
 docker-compose.override.yml.dist         |  11 ++
 docker-compose.yml                       |  52 +++++++
 docker/MysqlDockerfile                   |   8 +
 docker/NginxDockerfile                   |  41 +++++
 src/Migrations/Version20190113114527.php |  46 ++++++
 10 files changed, 510 insertions(+)
 create mode 100644 Dockerfile
 create mode 100644 Makefile
 create mode 100644 docker-compose.override.yml.dist
 create mode 100644 docker-compose.yml
 create mode 100644 docker/MysqlDockerfile
 create mode 100644 docker/NginxDockerfile
 create mode 100644 src/Migrations/Version20190113114527.php

diff --git a/.env b/.env
index db9043940..43188ef65 100644
--- a/.env
+++ b/.env
@@ -11,6 +11,7 @@ APP_SECRET=67d829bf61dc5f87a73fd814e2c9f629
 ###> doctrine/doctrine-bundle ###
 # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
 # For a MySQL database, use: "mysql://db_user:db_password@127.0.0.1:3306/db_name"
+# If you want to use Docker MySQL, use: "mysql://symfony-demo:symfony-demo@db:3306/symfony-demo"
 # Configure your db driver and server_version in config/packages/doctrine.yaml
 DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
 ###< doctrine/doctrine-bundle ###
diff --git a/.gitignore b/.gitignore
index 7d5655849..dcd594ffe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,10 @@
 /public/build/fonts/glyphicons-*
 /public/build/images/glyphicons-*
 
+###> docker ###
+docker-compose.override.yml
+###< docker ###
+
 ###> symfony/framework-bundle ###
 /.env.local
 /.env.*.local
diff --git a/.php_cs.dist b/.php_cs.dist
index edafec3af..d94c8dcc6 100644
--- a/.php_cs.dist
+++ b/.php_cs.dist
@@ -12,6 +12,7 @@ COMMENT;
 $finder = PhpCsFixer\Finder::create()
     ->in(__DIR__)
     ->exclude('config')
+    ->exclude('src/Migrations')
     ->exclude('var')
     ->exclude('public/bundles')
     ->exclude('public/build')
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..647066ac8
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,181 @@
+ARG NODE_VERSION=11.6.0
+ARG COMPOSER_VERSION=1.8.0
+ARG PHP_VERSION=7.2.13
+ARG ICU_VERSION=63.1
+ARG APCU_VERSION=5.1.16
+ARG XDEBUG_VERSION=2.6.1
+
+
+#####################################
+##               APP               ##
+#####################################
+FROM php:${PHP_VERSION}-fpm as app
+
+ARG ICU_VERSION
+ARG APCU_VERSION
+
+# Used for the ICU compilation
+ENV PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11"
+ENV APP_VERSION=0.0.0
+
+WORKDIR /app
+
+# Install paquet requirements
+RUN set -ex; \
+    # Install required system packages
+    apt-get update; \
+    apt-get install -qy --no-install-recommends \
+            zlib1g-dev \
+            git \
+    ; \
+    # Compile ICU (required by intl php extension)
+    curl -L -o /tmp/icu.tar.gz http://download.icu-project.org/files/icu4c/${ICU_VERSION}/icu4c-$(echo ${ICU_VERSION} | sed s/\\./_/g)-src.tgz; \
+    tar -zxf /tmp/icu.tar.gz -C /tmp; \
+    cd /tmp/icu/source; \
+    ./configure --prefix=/usr/local; \
+    make clean; \
+    make; \
+    make install; \
+    #Install the PHP extensions
+    docker-php-ext-configure intl --with-icu-dir=/usr/local; \
+    docker-php-ext-install -j "$(nproc)" \
+            intl \
+            pdo \
+            # pdo_mysql \ Uncomment it to use MySQL, and remove the pdo_sqlite (see: docker-compose.yml, docker-compose.override.yml.dist)
+            zip \
+            bcmath \
+    ; \
+    pecl install \
+            apcu-${APCU_VERSION} \
+    ; \
+    docker-php-ext-enable \
+            opcache \
+            apcu \
+    ; \
+    docker-php-source delete; \
+    # Clean aptitude cache and tmp directory
+    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*;
+
+## set recommended PHP.ini settings
+RUN { \
+        echo 'date.timezone = Europe/Paris'; \
+        echo 'short_open_tag = off'; \
+        echo 'expose_php = off'; \
+        echo 'error_log = /proc/self/fd/2'; \
+        echo 'memory_limit = 128m'; \
+        echo 'post_max_size = 110m'; \
+        echo 'upload_max_filesize = 100m'; \
+        echo 'opcache.enable = 1'; \
+        echo 'opcache.enable_cli = 1'; \
+        echo 'opcache.memory_consumption = 256'; \
+        echo 'opcache.interned_strings_buffer = 16'; \
+        echo 'opcache.max_accelerated_files = 20011'; \
+        echo 'opcache.fast_shutdown = 1'; \
+        echo 'realpath_cache_size = 4096K'; \
+        echo 'realpath_cache_ttl = 600'; \
+    } > /usr/local/etc/php/php.ini
+
+RUN { \
+        echo 'date.timezone = Europe/Paris'; \
+        echo 'short_open_tag = off'; \
+        echo 'memory_limit = 8192M'; \
+    } > /usr/local/etc/php/php-cli.ini
+
+CMD ["php-fpm"]
+
+
+#####################################
+##             APP DEV             ##
+#####################################
+FROM app as app-dev
+
+ARG NODE_VERSION
+ARG COMPOSER_VERSION
+ARG XDEBUG_VERSION
+
+ENV COMPOSER_ALLOW_SUPERUSER=1
+ENV APP_ENV=dev
+
+# Install paquet requirements
+RUN set -ex; \
+    # Install required system packages
+    apt-get update; \
+    apt-get install -qy --no-install-recommends \
+            unzip \
+    ; \
+    # Clean aptitude cache and tmp directory
+    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*;
+
+# Install Node
+RUN set -ex; \
+    curl -L -o /tmp/nodejs.tar.gz https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz; \
+    tar xfvz /tmp/nodejs.tar.gz -C /usr/local --strip-components=1; \
+    rm -f /tmp/nodejs.tar.gz; \
+    npm install yarn -g
+
+# Install Composer
+RUN set -ex; \
+    EXPECTED_SIGNATURE="$(curl -L https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar.sha256sum)"; \
+    curl -L -o composer.phar https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar; \
+    ACTUAL_SIGNATURE="$(sha256sum composer.phar)"; \
+    if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then >&2 echo 'ERROR: Invalid installer signature' && rm /usr/local/bin/composer && exit 1 ; fi; \
+    chmod +x composer.phar && mv composer.phar /usr/local/bin/composer; \
+    RESULT=$?; \
+    exit $RESULT;
+
+# Edit OPCache configuration
+RUN set -ex; \
+    { \
+        echo 'opcache.validate_timestamps = 1'; \
+        echo 'opcache.revalidate_freq = 0'; \
+    } >> /usr/local/etc/php/php.ini
+
+# Install Xdebug
+RUN set -ex; \
+    if [ "${XDEBUG_VERSION}" != 0 ]; \
+    then \
+        pecl install xdebug-${XDEBUG_VERSION}; \
+        docker-php-ext-enable xdebug; \
+        { \
+            echo 'xdebug.remote_enable = on'; \
+            echo 'xdebug.remote_connect_back = on'; \
+        } >> /usr/local/etc/php/php.ini \
+    ; fi
+
+
+#####################################
+##       PROD ASSETS BUILDER       ##
+#####################################
+FROM node:${NODE_VERSION} as assets-builder
+
+COPY . /app
+WORKDIR /app
+
+RUN yarn install && yarn build && rm -R node_modules
+
+#####################################
+##       PROD VENDOR BUILDER       ##
+#####################################
+FROM composer:${COMPOSER_VERSION} as vendor-builder
+
+COPY --from=assets-builder /app /app
+WORKDIR /app
+
+RUN APP_ENV=prod composer install -o -n --no-ansi --no-dev
+
+
+#####################################
+##             APP PROD            ##
+#####################################
+FROM app as app-prod
+
+ENV APP_ENV=prod
+
+COPY --from=vendor-builder /app /app
+WORKDIR /app
+
+# Edit OPCache configuration
+RUN set -ex; \
+    { \
+        echo 'opcache.validate_timestamps = 0'; \
+    } >> /usr/local/etc/php/php.ini
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..fee67a149
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,165 @@
+DOCKER_COMPOSE?=docker-compose
+EXEC?=$(DOCKER_COMPOSE) exec app
+CONSOLE=bin/console
+PHPCSFIXER?=$(EXEC) php -d memory_limit=1024m vendor/bin/php-cs-fixer
+
+.DEFAULT_GOAL := help
+.PHONY: help start stop restart install uninstall reset clear-cache tty clear clean
+.PHONY: db-diff db-migrate db-rollback db-reset db-validate wait-for-db
+.PHONY: watch assets assets-build
+.PHONY: tests lint lint-symfony lint-yaml lint-twig lint-twig php-cs php-cs-fix security-check test-schema test-all
+.PHONY: build up perm
+.PHONY: docker-compose.override.yml
+
+help:
+	@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
+
+##
+## Project setup
+##---------------------------------------------------------------------------
+
+start:                                                                                                 ## Start docker containers
+	$(DOCKER_COMPOSE) start
+
+stop:                                                                                                  ## Stop docker containers
+	$(DOCKER_COMPOSE) stop
+
+restart:                                                                                               ## Restart docker containers
+	$(DOCKER_COMPOSE) restart
+
+install: docker-compose.override.yml build up vendor perm                                                ## Create and start docker containers
+
+uninstall: stop                                                                                        ## Remove docker containers
+	$(DOCKER_COMPOSE) rm -vf
+
+reset: uninstall install                                                                               ## Remove and re-create docker containers
+
+clear-cache: perm
+	$(EXEC) $(CONSOLE) cache:clear --no-warmup
+	$(EXEC) $(CONSOLE) cache:warmup
+
+tty:                                                                                                   ## Run app container in interactive mode
+	$(EXEC) /bin/bash
+
+clear: perm                                                                                            ## Remove all the cache, the logs, the sessions and the built assets
+	$(EXEC) rm -rf var/cache/*
+	$(EXEC) $(CONSOLE) redis:flushall -n
+	rm -rf var/log/*
+	rm -rf public/build
+	rm -f var/.php_cs.cache
+
+clean: clear                                                                                           ## Clear and remove dependencies
+	rm -rf vendor node_modules
+
+
+##
+## Database
+##---------------------------------------------------------------------------
+
+wait-for-db:
+	$(EXEC) php -r "set_time_limit(60);for(;;){if(@fsockopen('db',3306)){break;}echo \"Waiting for MySQL\n\";sleep(1);}"
+
+db-diff: vendor wait-for-db                                                                            ## Generate a migration by comparing your current database to your mapping information
+	$(EXEC) $(CONSOLE) doctrine:migration:diff
+
+db-migrate: vendor wait-for-db                                                                         ## Migrate database schema to the latest available version
+	$(EXEC) $(CONSOLE) doctrine:migration:migrate -n
+
+db-rollback: vendor wait-for-db                                                                        ## Rollback the latest executed migration
+	$(EXEC) $(CONSOLE) doctrine:migration:migrate prev -n
+
+db-reset: vendor wait-for-db                                                                           ## Reset the database
+	$(EXEC) $(CONSOLE) doctrine:database:drop --force --if-exists
+	$(EXEC) $(CONSOLE) doctrine:database:create --if-not-exists
+	$(EXEC) $(CONSOLE) doctrine:migrations:migrate -n
+
+db-fixtures: vendor wait-for-db                                                                        ## Apply doctrine fixtures
+	$(EXEC) $(CONSOLE) doctrine:fixtures:load -n
+
+db-validate: vendor wait-for-db                                                                        ## Check the ORM mapping
+	$(EXEC) $(CONSOLE) doctrine:schema:validate
+
+
+##
+## Assets
+##---------------------------------------------------------------------------
+
+watch: node_modules                                                                                    ## Watch the assets and build their development version on change
+	$(EXEC) yarn watch
+
+assets: node_modules                                                                                   ## Build the development version of the assets
+	$(EXEC) yarn dev
+
+assets-build: node_modules                                                                              ## Build the production version of the assets
+	$(EXEC) yarn build
+
+##
+## Tests
+##---------------------------------------------------------------------------
+
+tests:                                                                                                 ## Run all the PHP tests
+	$(EXEC) bin/phpunit
+
+lint: lint-symfony php-cs                                                                              ## Run lint on Twig, YAML, PHP and Javascript files
+
+lint-symfony: lint-yaml lint-twig lint-xliff                                                           ## Lint Symfony (Twig and YAML) files
+
+lint-yaml:                                                                                             ## Lint YAML files
+	$(EXEC) $(CONSOLE) lint:yaml config
+
+lint-twig:                                                                                             ## Lint Twig files
+	$(EXEC) $(CONSOLE) lint:twig templates
+
+lint-xliff:                                                                                             ## Lint Translation files
+	$(EXEC) $(CONSOLE) lint:xliff translations
+
+php-cs: vendor                                                                                         ## Lint PHP code
+	$(PHPCSFIXER) fix --diff --dry-run --no-interaction -v
+
+php-cs-fix: vendor                                                                                     ## Lint and fix PHP code to follow the convention
+	$(PHPCSFIXER) fix
+
+security-check: vendor                                                                                 ## Check for vulnerable dependencies
+	$(EXEC) vendor/bin/security-checker security:check
+
+test-schema: vendor                                                                                    ## Test the doctrine Schema
+	$(EXEC) $(CONSOLE) doctrine:schema:validate --skip-sync -vvv --no-interaction
+
+test-all: lint test-schema security-check tests                                                        ## Lint all, check vulnerable dependencies, run PHP tests
+
+##
+
+
+# Internal rules
+
+build:
+	$(DOCKER_COMPOSE) pull --ignore-pull-failures
+	$(DOCKER_COMPOSE) build --force-rm
+
+up:
+	$(DOCKER_COMPOSE) up -d --remove-orphans
+
+perm:
+	$(EXEC) chmod -R 777 node_modules vendor
+	$(EXEC) chown -R www-data:root node_modules vendor
+
+docker-compose.override.yml:
+ifneq ($(wildcard docker-compose.override.yml),docker-compose.override.yml)
+	@echo docker-compose.override.yml do not exists, copy docker-compose.override.yml.dist to create it, and fill it.
+	exit 1
+endif
+
+
+# Rules from files
+
+vendor: composer.lock
+	$(EXEC) composer install -n
+
+composer.lock: composer.json
+	@echo compose.lock is not up to date.
+
+node_modules: yarn.lock
+	$(EXEC) yarn install
+
+yarn.lock: package.json
+	@echo yarn.lock is not up to date.
diff --git a/docker-compose.override.yml.dist b/docker-compose.override.yml.dist
new file mode 100644
index 000000000..de184ecee
--- /dev/null
+++ b/docker-compose.override.yml.dist
@@ -0,0 +1,11 @@
+version: '3.4'
+
+services:
+    nginx:
+        ports:
+            - 127.0.0.1:8080:80
+
+# Uncomment it, if you want to use MySQL (see: Dockerfile, docker-compose.yml)
+#    db:
+#        ports:
+#            - 127.0.0.1:3306:3306
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 000000000..b20b9611b
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,52 @@
+version: '3.4'
+
+services:
+    nginx:
+        build:
+            context: docker
+            dockerfile: NginxDockerfile
+        depends_on:
+            - app
+        networks:
+            - frontend
+        volumes:
+            - .:/app
+
+    app:
+        build:
+            context: .
+            target: app-dev
+# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
+#        depends_on:
+#            - db
+        networks:
+            - frontend
+# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
+#            - backend
+        volumes:
+            - .:/app
+
+# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
+#    db:
+#        build:
+#            context: docker
+#            dockerfile: MysqlDockerfile
+#        environment:
+#          - MYSQL_ROOT_PASSWORD=symfony-demo
+#          - MYSQL_USER=symfony-demo
+#          - MYSQL_PASSWORD=symfony-demo
+#          - MYSQL_DATABASE=symfony-demo
+#        volumes:
+#            - db_data:/var/lib/mysql
+#        networks:
+#            - backend
+
+# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
+#volumes:
+#    db_data:
+#        driver: local
+
+networks:
+    frontend:
+# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
+#    backend:
diff --git a/docker/MysqlDockerfile b/docker/MysqlDockerfile
new file mode 100644
index 000000000..5c7d04190
--- /dev/null
+++ b/docker/MysqlDockerfile
@@ -0,0 +1,8 @@
+FROM mysql:8.0.13
+
+# set MySQL config
+RUN rm /etc/mysql/conf.d/mysql.cnf
+RUN { \
+        echo '[mysqld]'; \
+        echo 'default_authentication_plugin= mysql_native_password'; \
+    } > /etc/mysql/conf.d/mysql.cnf
diff --git a/docker/NginxDockerfile b/docker/NginxDockerfile
new file mode 100644
index 000000000..ab67424a4
--- /dev/null
+++ b/docker/NginxDockerfile
@@ -0,0 +1,41 @@
+FROM nginx:1.15.8
+
+# set nginx config
+RUN rm /etc/nginx/conf.d/default.conf
+RUN { \
+        echo 'server {'; \
+        echo '    listen 80;'; \
+        echo '    server_name _;'; \
+        echo '    root /app/public;'; \
+        echo ''; \
+        echo '    add_header X-Content-Type-Options nosniff;'; \
+        echo '    add_header X-XSS-Protection "1; mode=block";'; \
+        echo '    add_header X-Frame-Options SAMEORIGIN;'; \
+        echo ''; \
+        echo '    if ($http_user_agent ~* "WordPress") {'; \
+        echo '        return 403;'; \
+        echo '    }'; \
+        echo ''; \
+        echo '    location / {'; \
+        echo '        try_files $uri /index.php$is_args$args;'; \
+        echo '    }'; \
+        echo ''; \
+        echo '    location /protected-files/ {'; \
+        echo '        internal;'; \
+        echo '        alias /app/files/;'; \
+        echo '    }'; \
+        echo ''; \
+        echo '    location ~ ^/index\.php(/|$) {'; \
+        echo '        fastcgi_pass app:9000;'; \
+        echo '        fastcgi_split_path_info ^(.+\.php)(/.*)$;'; \
+        echo '        include fastcgi_params;'; \
+        echo '        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;'; \
+        echo '        fastcgi_param DOCUMENT_ROOT $realpath_root;'; \
+        echo '        internal;'; \
+        echo '    }'; \
+        echo ''; \
+        echo '    location ~ \.php$ {'; \
+        echo '        return 404;'; \
+        echo '    }'; \
+        echo '}'; \
+    } > /etc/nginx/conf.d/default.conf
diff --git a/src/Migrations/Version20190113114527.php b/src/Migrations/Version20190113114527.php
new file mode 100644
index 000000000..524c98b5f
--- /dev/null
+++ b/src/Migrations/Version20190113114527.php
@@ -0,0 +1,46 @@
+<?php declare(strict_types=1);
+
+namespace DoctrineMigrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20190113114527 extends AbstractMigration
+{
+    public function up(Schema $schema) : void
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+        $this->addSql('CREATE TABLE symfony_demo_tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_4D5855405E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE symfony_demo_user (id INT AUTO_INCREMENT NOT NULL, full_name VARCHAR(255) NOT NULL, username VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', UNIQUE INDEX UNIQ_8FB094A1F85E0677 (username), UNIQUE INDEX UNIQ_8FB094A1E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE symfony_demo_comment (id INT AUTO_INCREMENT NOT NULL, post_id INT NOT NULL, author_id INT NOT NULL, content LONGTEXT NOT NULL, published_at DATETIME NOT NULL, INDEX IDX_53AD8F834B89032C (post_id), INDEX IDX_53AD8F83F675F31B (author_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE symfony_demo_post (id INT AUTO_INCREMENT NOT NULL, author_id INT NOT NULL, title VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, summary VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, published_at DATETIME NOT NULL, INDEX IDX_58A92E65F675F31B (author_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE symfony_demo_post_tag (post_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_6ABC1CC44B89032C (post_id), INDEX IDX_6ABC1CC4BAD26311 (tag_id), PRIMARY KEY(post_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
+        $this->addSql('ALTER TABLE symfony_demo_comment ADD CONSTRAINT FK_53AD8F834B89032C FOREIGN KEY (post_id) REFERENCES symfony_demo_post (id)');
+        $this->addSql('ALTER TABLE symfony_demo_comment ADD CONSTRAINT FK_53AD8F83F675F31B FOREIGN KEY (author_id) REFERENCES symfony_demo_user (id)');
+        $this->addSql('ALTER TABLE symfony_demo_post ADD CONSTRAINT FK_58A92E65F675F31B FOREIGN KEY (author_id) REFERENCES symfony_demo_user (id)');
+        $this->addSql('ALTER TABLE symfony_demo_post_tag ADD CONSTRAINT FK_6ABC1CC44B89032C FOREIGN KEY (post_id) REFERENCES symfony_demo_post (id) ON DELETE CASCADE');
+        $this->addSql('ALTER TABLE symfony_demo_post_tag ADD CONSTRAINT FK_6ABC1CC4BAD26311 FOREIGN KEY (tag_id) REFERENCES symfony_demo_tag (id) ON DELETE CASCADE');
+    }
+
+    public function down(Schema $schema) : void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+        $this->addSql('ALTER TABLE symfony_demo_post_tag DROP FOREIGN KEY FK_6ABC1CC4BAD26311');
+        $this->addSql('ALTER TABLE symfony_demo_comment DROP FOREIGN KEY FK_53AD8F83F675F31B');
+        $this->addSql('ALTER TABLE symfony_demo_post DROP FOREIGN KEY FK_58A92E65F675F31B');
+        $this->addSql('ALTER TABLE symfony_demo_comment DROP FOREIGN KEY FK_53AD8F834B89032C');
+        $this->addSql('ALTER TABLE symfony_demo_post_tag DROP FOREIGN KEY FK_6ABC1CC44B89032C');
+        $this->addSql('DROP TABLE symfony_demo_tag');
+        $this->addSql('DROP TABLE symfony_demo_user');
+        $this->addSql('DROP TABLE symfony_demo_comment');
+        $this->addSql('DROP TABLE symfony_demo_post');
+        $this->addSql('DROP TABLE symfony_demo_post_tag');
+    }
+}

From 82ded757ec409f1c22a19bb14be9c5976fd83d5d Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Wed, 16 Jan 2019 20:27:17 +0100
Subject: [PATCH 02/11] Use a .conf file for Nginx

---
 docker/NginxDockerfile    | 39 +--------------------------------------
 docker/nginx-default.conf | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 38 deletions(-)
 create mode 100644 docker/nginx-default.conf

diff --git a/docker/NginxDockerfile b/docker/NginxDockerfile
index ab67424a4..3e157ffe5 100644
--- a/docker/NginxDockerfile
+++ b/docker/NginxDockerfile
@@ -1,41 +1,4 @@
 FROM nginx:1.15.8
 
 # set nginx config
-RUN rm /etc/nginx/conf.d/default.conf
-RUN { \
-        echo 'server {'; \
-        echo '    listen 80;'; \
-        echo '    server_name _;'; \
-        echo '    root /app/public;'; \
-        echo ''; \
-        echo '    add_header X-Content-Type-Options nosniff;'; \
-        echo '    add_header X-XSS-Protection "1; mode=block";'; \
-        echo '    add_header X-Frame-Options SAMEORIGIN;'; \
-        echo ''; \
-        echo '    if ($http_user_agent ~* "WordPress") {'; \
-        echo '        return 403;'; \
-        echo '    }'; \
-        echo ''; \
-        echo '    location / {'; \
-        echo '        try_files $uri /index.php$is_args$args;'; \
-        echo '    }'; \
-        echo ''; \
-        echo '    location /protected-files/ {'; \
-        echo '        internal;'; \
-        echo '        alias /app/files/;'; \
-        echo '    }'; \
-        echo ''; \
-        echo '    location ~ ^/index\.php(/|$) {'; \
-        echo '        fastcgi_pass app:9000;'; \
-        echo '        fastcgi_split_path_info ^(.+\.php)(/.*)$;'; \
-        echo '        include fastcgi_params;'; \
-        echo '        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;'; \
-        echo '        fastcgi_param DOCUMENT_ROOT $realpath_root;'; \
-        echo '        internal;'; \
-        echo '    }'; \
-        echo ''; \
-        echo '    location ~ \.php$ {'; \
-        echo '        return 404;'; \
-        echo '    }'; \
-        echo '}'; \
-    } > /etc/nginx/conf.d/default.conf
+ADD nginx-default.conf /etc/nginx/conf.d/default.conf
diff --git a/docker/nginx-default.conf b/docker/nginx-default.conf
new file mode 100644
index 000000000..6bcafea0c
--- /dev/null
+++ b/docker/nginx-default.conf
@@ -0,0 +1,35 @@
+ server {
+    listen 80;
+    server_name _;
+    root /app/public;
+
+    add_header X-Content-Type-Options nosniff;
+    add_header X-XSS-Protection "1; mode=block";
+    add_header X-Frame-Options SAMEORIGIN;
+
+    if ($http_user_agent ~* "WordPress") {
+        return 403;
+    }
+
+    location / {
+        try_files $uri /index.php$is_args$args;
+    }
+
+    location /protected-files/ {
+        internal;
+        alias /app/files/;
+    }
+
+    location ~ ^/index\.php(/|$) {
+        fastcgi_pass app:9000;
+        fastcgi_split_path_info ^(.+\.php)(/.*)$;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
+        fastcgi_param DOCUMENT_ROOT $realpath_root;
+        internal;
+    }
+
+    location ~ \.php$ {
+        return 404;
+    }
+}

From 871f2c4c80776399fa21edd43d48d0410d132ef5 Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Fri, 25 Jan 2019 17:41:43 +0100
Subject: [PATCH 03/11] Remove some useless parts

---
 Dockerfile                |  9 +++------
 Makefile                  |  1 -
 docker/nginx-default.conf | 13 -------------
 3 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 647066ac8..6acbf22cd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,14 +14,11 @@ FROM php:${PHP_VERSION}-fpm as app
 ARG ICU_VERSION
 ARG APCU_VERSION
 
-# Used for the ICU compilation
-ENV PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11"
-ENV APP_VERSION=0.0.0
-
 WORKDIR /app
 
 # Install paquet requirements
-RUN set -ex; \
+RUN export PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11" \
+    set -ex; \
     # Install required system packages
     apt-get update; \
     apt-get install -qy --no-install-recommends \
@@ -78,7 +75,7 @@ RUN { \
 RUN { \
         echo 'date.timezone = Europe/Paris'; \
         echo 'short_open_tag = off'; \
-        echo 'memory_limit = 8192M'; \
+        echo 'memory_limit = -1'; \
     } > /usr/local/etc/php/php-cli.ini
 
 CMD ["php-fpm"]
diff --git a/Makefile b/Makefile
index fee67a149..009e5e8c5 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,6 @@ tty:
 
 clear: perm                                                                                            ## Remove all the cache, the logs, the sessions and the built assets
 	$(EXEC) rm -rf var/cache/*
-	$(EXEC) $(CONSOLE) redis:flushall -n
 	rm -rf var/log/*
 	rm -rf public/build
 	rm -f var/.php_cs.cache
diff --git a/docker/nginx-default.conf b/docker/nginx-default.conf
index 6bcafea0c..907d3adbb 100644
--- a/docker/nginx-default.conf
+++ b/docker/nginx-default.conf
@@ -3,23 +3,10 @@
     server_name _;
     root /app/public;
 
-    add_header X-Content-Type-Options nosniff;
-    add_header X-XSS-Protection "1; mode=block";
-    add_header X-Frame-Options SAMEORIGIN;
-
-    if ($http_user_agent ~* "WordPress") {
-        return 403;
-    }
-
     location / {
         try_files $uri /index.php$is_args$args;
     }
 
-    location /protected-files/ {
-        internal;
-        alias /app/files/;
-    }
-
     location ~ ^/index\.php(/|$) {
         fastcgi_pass app:9000;
         fastcgi_split_path_info ^(.+\.php)(/.*)$;

From e1ca54aa10d1460be37ac6ab4626036d3fa3b89b Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Fri, 25 Jan 2019 17:47:59 +0100
Subject: [PATCH 04/11] Remove MySQL parts

---
 .env                             |  1 -
 Dockerfile                       |  1 -
 Makefile                         | 22 +++++++---------------
 docker-compose.override.yml.dist |  5 -----
 docker-compose.yml               | 26 --------------------------
 docker/MysqlDockerfile           |  8 --------
 6 files changed, 7 insertions(+), 56 deletions(-)
 delete mode 100644 docker/MysqlDockerfile

diff --git a/.env b/.env
index 43188ef65..db9043940 100644
--- a/.env
+++ b/.env
@@ -11,7 +11,6 @@ APP_SECRET=67d829bf61dc5f87a73fd814e2c9f629
 ###> doctrine/doctrine-bundle ###
 # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
 # For a MySQL database, use: "mysql://db_user:db_password@127.0.0.1:3306/db_name"
-# If you want to use Docker MySQL, use: "mysql://symfony-demo:symfony-demo@db:3306/symfony-demo"
 # Configure your db driver and server_version in config/packages/doctrine.yaml
 DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
 ###< doctrine/doctrine-bundle ###
diff --git a/Dockerfile b/Dockerfile
index 6acbf22cd..ddaebaea9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -38,7 +38,6 @@ RUN export PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11" \
     docker-php-ext-install -j "$(nproc)" \
             intl \
             pdo \
-            # pdo_mysql \ Uncomment it to use MySQL, and remove the pdo_sqlite (see: docker-compose.yml, docker-compose.override.yml.dist)
             zip \
             bcmath \
     ; \
diff --git a/Makefile b/Makefile
index 009e5e8c5..0a0273487 100644
--- a/Makefile
+++ b/Makefile
@@ -5,9 +5,9 @@ PHPCSFIXER?=$(EXEC) php -d memory_limit=1024m vendor/bin/php-cs-fixer
 
 .DEFAULT_GOAL := help
 .PHONY: help start stop restart install uninstall reset clear-cache tty clear clean
-.PHONY: db-diff db-migrate db-rollback db-reset db-validate wait-for-db
+.PHONY: db-diff db-migrate db-rollback db-fixtures db-validate
 .PHONY: watch assets assets-build
-.PHONY: tests lint lint-symfony lint-yaml lint-twig lint-twig php-cs php-cs-fix security-check test-schema test-all
+.PHONY: tests lint lint-symfony lint-yaml lint-twig lint-xliff php-cs php-cs-fix security-check test-schema test-all
 .PHONY: build up perm
 .PHONY: docker-compose.override.yml
 
@@ -55,27 +55,19 @@ clean: clear
 ## Database
 ##---------------------------------------------------------------------------
 
-wait-for-db:
-	$(EXEC) php -r "set_time_limit(60);for(;;){if(@fsockopen('db',3306)){break;}echo \"Waiting for MySQL\n\";sleep(1);}"
-
-db-diff: vendor wait-for-db                                                                            ## Generate a migration by comparing your current database to your mapping information
+db-diff: vendor                                                                                        ## Generate a migration by comparing your current database to your mapping information
 	$(EXEC) $(CONSOLE) doctrine:migration:diff
 
-db-migrate: vendor wait-for-db                                                                         ## Migrate database schema to the latest available version
+db-migrate: vendor                                                                                     ## Migrate database schema to the latest available version
 	$(EXEC) $(CONSOLE) doctrine:migration:migrate -n
 
-db-rollback: vendor wait-for-db                                                                        ## Rollback the latest executed migration
+db-rollback: vendor                                                                                    ## Rollback the latest executed migration
 	$(EXEC) $(CONSOLE) doctrine:migration:migrate prev -n
 
-db-reset: vendor wait-for-db                                                                           ## Reset the database
-	$(EXEC) $(CONSOLE) doctrine:database:drop --force --if-exists
-	$(EXEC) $(CONSOLE) doctrine:database:create --if-not-exists
-	$(EXEC) $(CONSOLE) doctrine:migrations:migrate -n
-
-db-fixtures: vendor wait-for-db                                                                        ## Apply doctrine fixtures
+db-fixtures: vendor                                                                                    ## Apply doctrine fixtures
 	$(EXEC) $(CONSOLE) doctrine:fixtures:load -n
 
-db-validate: vendor wait-for-db                                                                        ## Check the ORM mapping
+db-validate: vendor                                                                                    ## Check the ORM mapping
 	$(EXEC) $(CONSOLE) doctrine:schema:validate
 
 
diff --git a/docker-compose.override.yml.dist b/docker-compose.override.yml.dist
index de184ecee..d06d68fad 100644
--- a/docker-compose.override.yml.dist
+++ b/docker-compose.override.yml.dist
@@ -4,8 +4,3 @@ services:
     nginx:
         ports:
             - 127.0.0.1:8080:80
-
-# Uncomment it, if you want to use MySQL (see: Dockerfile, docker-compose.yml)
-#    db:
-#        ports:
-#            - 127.0.0.1:3306:3306
diff --git a/docker-compose.yml b/docker-compose.yml
index b20b9611b..3247b297d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -16,37 +16,11 @@ services:
         build:
             context: .
             target: app-dev
-# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
-#        depends_on:
-#            - db
         networks:
             - frontend
-# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
-#            - backend
         volumes:
             - .:/app
 
-# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
-#    db:
-#        build:
-#            context: docker
-#            dockerfile: MysqlDockerfile
-#        environment:
-#          - MYSQL_ROOT_PASSWORD=symfony-demo
-#          - MYSQL_USER=symfony-demo
-#          - MYSQL_PASSWORD=symfony-demo
-#          - MYSQL_DATABASE=symfony-demo
-#        volumes:
-#            - db_data:/var/lib/mysql
-#        networks:
-#            - backend
-
-# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
-#volumes:
-#    db_data:
-#        driver: local
 
 networks:
     frontend:
-# Uncomment if you want to use MySQL (see: Dockerfile, docker-compose.override.yml)
-#    backend:
diff --git a/docker/MysqlDockerfile b/docker/MysqlDockerfile
deleted file mode 100644
index 5c7d04190..000000000
--- a/docker/MysqlDockerfile
+++ /dev/null
@@ -1,8 +0,0 @@
-FROM mysql:8.0.13
-
-# set MySQL config
-RUN rm /etc/mysql/conf.d/mysql.cnf
-RUN { \
-        echo '[mysqld]'; \
-        echo 'default_authentication_plugin= mysql_native_password'; \
-    } > /etc/mysql/conf.d/mysql.cnf

From 23c594eba28c0b63dd7c6b062a741ca92c920766 Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Fri, 25 Jan 2019 18:20:31 +0100
Subject: [PATCH 05/11] Remove Migration and network from docker-compose

---
 docker-compose.yml                       |  4 ---
 src/Migrations/Version20190113114527.php | 46 ------------------------
 2 files changed, 50 deletions(-)
 delete mode 100644 src/Migrations/Version20190113114527.php

diff --git a/docker-compose.yml b/docker-compose.yml
index 3247b297d..8049a095b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -20,7 +20,3 @@ services:
             - frontend
         volumes:
             - .:/app
-
-
-networks:
-    frontend:
diff --git a/src/Migrations/Version20190113114527.php b/src/Migrations/Version20190113114527.php
deleted file mode 100644
index 524c98b5f..000000000
--- a/src/Migrations/Version20190113114527.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php declare(strict_types=1);
-
-namespace DoctrineMigrations;
-
-use Doctrine\DBAL\Schema\Schema;
-use Doctrine\Migrations\AbstractMigration;
-
-/**
- * Auto-generated Migration: Please modify to your needs!
- */
-final class Version20190113114527 extends AbstractMigration
-{
-    public function up(Schema $schema) : void
-    {
-        // this up() migration is auto-generated, please modify it to your needs
-        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
-        $this->addSql('CREATE TABLE symfony_demo_tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_4D5855405E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
-        $this->addSql('CREATE TABLE symfony_demo_user (id INT AUTO_INCREMENT NOT NULL, full_name VARCHAR(255) NOT NULL, username VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', UNIQUE INDEX UNIQ_8FB094A1F85E0677 (username), UNIQUE INDEX UNIQ_8FB094A1E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
-        $this->addSql('CREATE TABLE symfony_demo_comment (id INT AUTO_INCREMENT NOT NULL, post_id INT NOT NULL, author_id INT NOT NULL, content LONGTEXT NOT NULL, published_at DATETIME NOT NULL, INDEX IDX_53AD8F834B89032C (post_id), INDEX IDX_53AD8F83F675F31B (author_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
-        $this->addSql('CREATE TABLE symfony_demo_post (id INT AUTO_INCREMENT NOT NULL, author_id INT NOT NULL, title VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, summary VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, published_at DATETIME NOT NULL, INDEX IDX_58A92E65F675F31B (author_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
-        $this->addSql('CREATE TABLE symfony_demo_post_tag (post_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_6ABC1CC44B89032C (post_id), INDEX IDX_6ABC1CC4BAD26311 (tag_id), PRIMARY KEY(post_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
-        $this->addSql('ALTER TABLE symfony_demo_comment ADD CONSTRAINT FK_53AD8F834B89032C FOREIGN KEY (post_id) REFERENCES symfony_demo_post (id)');
-        $this->addSql('ALTER TABLE symfony_demo_comment ADD CONSTRAINT FK_53AD8F83F675F31B FOREIGN KEY (author_id) REFERENCES symfony_demo_user (id)');
-        $this->addSql('ALTER TABLE symfony_demo_post ADD CONSTRAINT FK_58A92E65F675F31B FOREIGN KEY (author_id) REFERENCES symfony_demo_user (id)');
-        $this->addSql('ALTER TABLE symfony_demo_post_tag ADD CONSTRAINT FK_6ABC1CC44B89032C FOREIGN KEY (post_id) REFERENCES symfony_demo_post (id) ON DELETE CASCADE');
-        $this->addSql('ALTER TABLE symfony_demo_post_tag ADD CONSTRAINT FK_6ABC1CC4BAD26311 FOREIGN KEY (tag_id) REFERENCES symfony_demo_tag (id) ON DELETE CASCADE');
-    }
-
-    public function down(Schema $schema) : void
-    {
-        // this down() migration is auto-generated, please modify it to your needs
-        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
-        $this->addSql('ALTER TABLE symfony_demo_post_tag DROP FOREIGN KEY FK_6ABC1CC4BAD26311');
-        $this->addSql('ALTER TABLE symfony_demo_comment DROP FOREIGN KEY FK_53AD8F83F675F31B');
-        $this->addSql('ALTER TABLE symfony_demo_post DROP FOREIGN KEY FK_58A92E65F675F31B');
-        $this->addSql('ALTER TABLE symfony_demo_comment DROP FOREIGN KEY FK_53AD8F834B89032C');
-        $this->addSql('ALTER TABLE symfony_demo_post_tag DROP FOREIGN KEY FK_6ABC1CC44B89032C');
-        $this->addSql('DROP TABLE symfony_demo_tag');
-        $this->addSql('DROP TABLE symfony_demo_user');
-        $this->addSql('DROP TABLE symfony_demo_comment');
-        $this->addSql('DROP TABLE symfony_demo_post');
-        $this->addSql('DROP TABLE symfony_demo_post_tag');
-    }
-}

From c380ea12352f0c35ef2dd84efec3f9201db5b2ed Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Wed, 30 Jan 2019 08:47:19 +0100
Subject: [PATCH 06/11] Rename make tty to make shell

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 0a0273487..71cdf1dbe 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ clear-cache: perm
 	$(EXEC) $(CONSOLE) cache:clear --no-warmup
 	$(EXEC) $(CONSOLE) cache:warmup
 
-tty:                                                                                                   ## Run app container in interactive mode
+shell:                                                                                                 ## Run app container in interactive mode
 	$(EXEC) /bin/bash
 
 clear: perm                                                                                            ## Remove all the cache, the logs, the sessions and the built assets

From cf9c6c938a0fe0e80f92c2f2aecc9bfb7e81e335 Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Tue, 5 Feb 2019 10:45:10 +0100
Subject: [PATCH 07/11] Fix Dockerfile

---
 Dockerfile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index ddaebaea9..906042b9b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,12 +17,12 @@ ARG APCU_VERSION
 WORKDIR /app
 
 # Install paquet requirements
-RUN export PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11" \
+RUN export PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11"; \
     set -ex; \
     # Install required system packages
     apt-get update; \
     apt-get install -qy --no-install-recommends \
-            zlib1g-dev \
+            libzip-dev \
             git \
     ; \
     # Compile ICU (required by intl php extension)

From 4f184d2a91d4675114c5195ecb0aeb8c75acdddb Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Tue, 5 Feb 2019 11:21:10 +0100
Subject: [PATCH 08/11] Remove/Update some forgetten parts

---
 Makefile           | 8 ++++----
 docker-compose.yml | 4 ----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 71cdf1dbe..6b3867f1b 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ CONSOLE=bin/console
 PHPCSFIXER?=$(EXEC) php -d memory_limit=1024m vendor/bin/php-cs-fixer
 
 .DEFAULT_GOAL := help
-.PHONY: help start stop restart install uninstall reset clear-cache tty clear clean
+.PHONY: help start stop restart install uninstall reset clear-cache shell clear clean
 .PHONY: db-diff db-migrate db-rollback db-fixtures db-validate
 .PHONY: watch assets assets-build
 .PHONY: tests lint lint-symfony lint-yaml lint-twig lint-xliff php-cs php-cs-fix security-check test-schema test-all
@@ -48,7 +48,7 @@ clear: perm
 	rm -f var/.php_cs.cache
 
 clean: clear                                                                                           ## Clear and remove dependencies
-	rm -rf vendor node_modules
+	rm -rf vendor
 
 
 ##
@@ -131,8 +131,8 @@ up:
 	$(DOCKER_COMPOSE) up -d --remove-orphans
 
 perm:
-	$(EXEC) chmod -R 777 node_modules vendor
-	$(EXEC) chown -R www-data:root node_modules vendor
+	$(EXEC) chmod -R 777 vendor
+	$(EXEC) chown -R www-data:root vendor
 
 docker-compose.override.yml:
 ifneq ($(wildcard docker-compose.override.yml),docker-compose.override.yml)
diff --git a/docker-compose.yml b/docker-compose.yml
index 8049a095b..4f7fa8653 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,8 +7,6 @@ services:
             dockerfile: NginxDockerfile
         depends_on:
             - app
-        networks:
-            - frontend
         volumes:
             - .:/app
 
@@ -16,7 +14,5 @@ services:
         build:
             context: .
             target: app-dev
-        networks:
-            - frontend
         volumes:
             - .:/app

From 561eb0aa0eaa96dba197e475ec635327369759b6 Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Fri, 1 Mar 2019 09:24:49 +0100
Subject: [PATCH 09/11] [Dockerfile] Set PHP timezone on UTC

---
 Dockerfile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 906042b9b..7c755fddb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -54,7 +54,7 @@ RUN export PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11"; \
 
 ## set recommended PHP.ini settings
 RUN { \
-        echo 'date.timezone = Europe/Paris'; \
+        echo 'date.timezone = UTC'; \
         echo 'short_open_tag = off'; \
         echo 'expose_php = off'; \
         echo 'error_log = /proc/self/fd/2'; \
@@ -72,7 +72,7 @@ RUN { \
     } > /usr/local/etc/php/php.ini
 
 RUN { \
-        echo 'date.timezone = Europe/Paris'; \
+        echo 'date.timezone = UTC'; \
         echo 'short_open_tag = off'; \
         echo 'memory_limit = -1'; \
     } > /usr/local/etc/php/php-cli.ini

From d618831bec681d08022a36bd1dec844e6caad7d2 Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Fri, 29 Mar 2019 10:45:26 +0100
Subject: [PATCH 10/11] Add some fixes

---
 Dockerfile |  6 ++++--
 Makefile   | 36 +++++++++++++++++++++++-------------
 2 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 7c755fddb..3fe91b2a4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,6 +16,8 @@ ARG APCU_VERSION
 
 WORKDIR /app
 
+EXPOSE 80
+
 # Install paquet requirements
 RUN export PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11"; \
     set -ex; \
@@ -23,7 +25,6 @@ RUN export PHP_CPPFLAGS="${PHP_CPPFLAGS} -std=c++11"; \
     apt-get update; \
     apt-get install -qy --no-install-recommends \
             libzip-dev \
-            git \
     ; \
     # Compile ICU (required by intl php extension)
     curl -L -o /tmp/icu.tar.gz http://download.icu-project.org/files/icu4c/${ICU_VERSION}/icu4c-$(echo ${ICU_VERSION} | sed s/\\./_/g)-src.tgz; \
@@ -98,6 +99,7 @@ RUN set -ex; \
     apt-get update; \
     apt-get install -qy --no-install-recommends \
             unzip \
+            git \
     ; \
     # Clean aptitude cache and tmp directory
     apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*;
@@ -154,7 +156,7 @@ RUN yarn install && yarn build && rm -R node_modules
 #####################################
 FROM composer:${COMPOSER_VERSION} as vendor-builder
 
-COPY --from=assets-builder /app /app
+COPY --chown=www-data --from=assets-builder /app /app
 WORKDIR /app
 
 RUN APP_ENV=prod composer install -o -n --no-ansi --no-dev
diff --git a/Makefile b/Makefile
index 6b3867f1b..e3a2662fc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 DOCKER_COMPOSE?=docker-compose
 EXEC?=$(DOCKER_COMPOSE) exec app
-CONSOLE=bin/console
+CONSOLE=php bin/console
 PHPCSFIXER?=$(EXEC) php -d memory_limit=1024m vendor/bin/php-cs-fixer
 
 .DEFAULT_GOAL := help
@@ -8,12 +8,13 @@ PHPCSFIXER?=$(EXEC) php -d memory_limit=1024m vendor/bin/php-cs-fixer
 .PHONY: db-diff db-migrate db-rollback db-fixtures db-validate
 .PHONY: watch assets assets-build
 .PHONY: tests lint lint-symfony lint-yaml lint-twig lint-xliff php-cs php-cs-fix security-check test-schema test-all
-.PHONY: build up perm
-.PHONY: docker-compose.override.yml
+.PHONY: deps
+.PHONY: build up perm docker-compose.override.yml
 
 help:
 	@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
 
+
 ##
 ## Project setup
 ##---------------------------------------------------------------------------
@@ -27,7 +28,7 @@ stop:
 restart:                                                                                               ## Restart docker containers
 	$(DOCKER_COMPOSE) restart
 
-install: docker-compose.override.yml build up vendor perm                                                ## Create and start docker containers
+install: docker-compose.override.yml build up deps perm                                                ## Create and start docker containers
 
 uninstall: stop                                                                                        ## Remove docker containers
 	$(DOCKER_COMPOSE) rm -vf
@@ -48,7 +49,7 @@ clear: perm
 	rm -f var/.php_cs.cache
 
 clean: clear                                                                                           ## Clear and remove dependencies
-	rm -rf vendor
+	rm -rf vendor node_modules
 
 
 ##
@@ -81,9 +82,10 @@ watch: node_modules
 assets: node_modules                                                                                   ## Build the development version of the assets
 	$(EXEC) yarn dev
 
-assets-build: node_modules                                                                              ## Build the production version of the assets
+assets-build: node_modules                                                                             ## Build the production version of the assets
 	$(EXEC) yarn build
 
+
 ##
 ## Tests
 ##---------------------------------------------------------------------------
@@ -91,7 +93,7 @@ assets-build: node_modules
 tests:                                                                                                 ## Run all the PHP tests
 	$(EXEC) bin/phpunit
 
-lint: lint-symfony php-cs                                                                              ## Run lint on Twig, YAML, PHP and Javascript files
+lint: lint-symfony php-cs                                                                              ## Run lint on Twig, YAML, XLIFF, and PHP files
 
 lint-symfony: lint-yaml lint-twig lint-xliff                                                           ## Lint Symfony (Twig and YAML) files
 
@@ -101,13 +103,13 @@ lint-yaml:
 lint-twig:                                                                                             ## Lint Twig files
 	$(EXEC) $(CONSOLE) lint:twig templates
 
-lint-xliff:                                                                                             ## Lint Translation files
+lint-xliff:                                                                                            ## Lint Translation files
 	$(EXEC) $(CONSOLE) lint:xliff translations
 
 php-cs: vendor                                                                                         ## Lint PHP code
 	$(PHPCSFIXER) fix --diff --dry-run --no-interaction -v
 
-php-cs-fix: vendor                                                                                     ## Lint and fix PHP code to follow the convention
+php-cs-fix: vendor                                                                                     ## Fix PHP code to follow the convention
 	$(PHPCSFIXER) fix
 
 security-check: vendor                                                                                 ## Check for vulnerable dependencies
@@ -116,7 +118,15 @@ security-check: vendor
 test-schema: vendor                                                                                    ## Test the doctrine Schema
 	$(EXEC) $(CONSOLE) doctrine:schema:validate --skip-sync -vvv --no-interaction
 
-test-all: lint test-schema security-check tests                                                        ## Lint all, check vulnerable dependencies, run PHP tests
+test-all: lint test-schema security-check tests                                                        ## Lint all, run schema and security check, then unit and functionnal tests
+
+
+##
+## Dependencies
+##---------------------------------------------------------------------------
+
+deps: vendor assets                                                                                    ## Install the project dependencies
+
 
 ##
 
@@ -131,8 +141,8 @@ up:
 	$(DOCKER_COMPOSE) up -d --remove-orphans
 
 perm:
-	$(EXEC) chmod -R 777 vendor
-	$(EXEC) chown -R www-data:root vendor
+	$(EXEC) chmod -R 777 var public/build node_modules vendor
+	$(EXEC) chown -R www-data:root var public/build node_modules vendor
 
 docker-compose.override.yml:
 ifneq ($(wildcard docker-compose.override.yml),docker-compose.override.yml)
@@ -147,7 +157,7 @@ vendor: composer.lock
 	$(EXEC) composer install -n
 
 composer.lock: composer.json
-	@echo compose.lock is not up to date.
+	@echo composer.lock is not up to date.
 
 node_modules: yarn.lock
 	$(EXEC) yarn install

From c49b24a90910f66f24cec75ba936fbffcd908418 Mon Sep 17 00:00:00 2001
From: Mathieu Piot <math.piot@gmail.com>
Date: Fri, 2 Aug 2019 16:12:59 +0200
Subject: [PATCH 11/11] Add a Dockerignore file

---
 .dockerignore | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 .dockerignore

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 000000000..ba64667f1
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,20 @@
+/.git
+/public/build
+/public/bundles
+/var/log/*
+var/sessions/*
+/vendor
+.dockerignore
+.editorconfig
+.env.local
+.env.test
+.gitignore
+.php_cs.dist
+.travis.yml
+appveyor.yml
+docker-compose.override.yml.dist
+docker-compose.yml
+Dockerfile
+Makefile
+phpunit.xml.dist
+README.md