From 5ccee36b1431385e0bda9097811c424fdeaa2113 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 31 May 2018 19:27:00 +0200 Subject: [PATCH 1/6] Require Sylius v1.3.x@dev --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4d013dacb7..66b782cd0c 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require": { "php": "^7.1", - "sylius/sylius": "1.2.*@beta", + "sylius/sylius": "1.3.*dev", "symfony/symfony": "^3.4|^4.0" }, "require-dev": { @@ -86,7 +86,7 @@ "file": "app/config/parameters.yml" }, "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } From 34cffaf16a60f247537de397587cfc8c728cc60f Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 7 Jun 2018 22:36:48 +0200 Subject: [PATCH 2/6] Update composer lockfile --- composer.lock | 55 ++++++++------------------------------------------- 1 file changed, 8 insertions(+), 47 deletions(-) diff --git a/composer.lock b/composer.lock index 3d9a7c11bc..054bc60796 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a11c85f657fdf8d05ac343edacc3bd9b", + "content-hash": "8be4f02d448db851ea551d0945adf10a", "packages": [ { "name": "behat/transliterator", @@ -5315,16 +5315,16 @@ }, { "name": "sylius/sylius", - "version": "v1.2.0-RC", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/Sylius/Sylius.git", - "reference": "1ec29efea1adbbc2ba3778d540c017c49858f535" + "reference": "558355c09044d05e4b05a2c3e3580c29902637e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Sylius/Sylius/zipball/1ec29efea1adbbc2ba3778d540c017c49858f535", - "reference": "1ec29efea1adbbc2ba3778d540c017c49858f535", + "url": "https://api.github.com/repos/Sylius/Sylius/zipball/558355c09044d05e4b05a2c3e3580c29902637e9", + "reference": "558355c09044d05e4b05a2c3e3580c29902637e9", "shasum": "" }, "require": { @@ -5476,7 +5476,7 @@ "file": "app/config/parameters.yml" }, "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -5509,7 +5509,7 @@ ], "description": "E-Commerce platform for PHP, based on Symfony framework.", "homepage": "http://sylius.com", - "time": "2018-06-07T14:13:56+00:00" + "time": "2018-06-07T15:24:12+00:00" }, { "name": "symfony/class-loader", @@ -9484,45 +9484,6 @@ ], "time": "2018-05-29T13:50:43+00:00" }, - { - "name": "se/selenium-server-standalone", - "version": "v2.53.1", - "source": { - "type": "git", - "url": "https://github.com/sveneisenschmidt/selenium-server-standalone.git", - "reference": "ef4eea9c99efb9c0e3084e9cae625662ccd43361" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sveneisenschmidt/selenium-server-standalone/zipball/ef4eea9c99efb9c0e3084e9cae625662ccd43361", - "reference": "ef4eea9c99efb9c0e3084e9cae625662ccd43361", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "bin": [ - "bin/selenium-server-standalone" - ], - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache 2.0" - ], - "authors": [ - { - "name": "Sven Eisenschmidt", - "email": "sven.eisenschmidt@gmail.com" - } - ], - "description": "Composer distribution of Selenium Server Standalone, the browser automation framework. Adds a executable to your composer bin directory.", - "homepage": "https://github.com/sveneisenschmidt/selenium-server-standalone", - "keywords": [ - "selenium", - "testing" - ], - "time": "2016-07-01T14:16:52+00:00" - }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -10619,7 +10580,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "sylius/sylius": 5, + "sylius/sylius": 20, "behat/mink": 20 }, "prefer-stable": true, From 7a68f2856e8f42768cbcdd8fa0866b3d89a692dd Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Fri, 8 Jun 2018 14:38:45 +0200 Subject: [PATCH 3/6] Fix composer.json requirements --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 26ccba9c35..3206ce211d 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require": { "php": "^7.1", - "sylius/sylius": "1.3.*dev", + "sylius/sylius": "1.3.*@dev", "symfony/symfony": "^3.4|^4.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 054bc60796..a16233bc0c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8be4f02d448db851ea551d0945adf10a", + "content-hash": "b8dd81d6056020a85fc3cd669bc116fc", "packages": [ { "name": "behat/transliterator", From 37d6ef9a9300be29f481c3fa1b4387ca50ca5da7 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Mon, 11 Jun 2018 15:46:25 +0200 Subject: [PATCH 4/6] Upgrade Composer & Yarn dependencies --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index f00f3b304a..5331fc1885 100644 --- a/composer.lock +++ b/composer.lock @@ -5319,12 +5319,12 @@ "source": { "type": "git", "url": "https://github.com/Sylius/Sylius.git", - "reference": "558355c09044d05e4b05a2c3e3580c29902637e9" + "reference": "561a88b11e6319ae56730cc3abd15b7fa5dd0fc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Sylius/Sylius/zipball/558355c09044d05e4b05a2c3e3580c29902637e9", - "reference": "558355c09044d05e4b05a2c3e3580c29902637e9", + "url": "https://api.github.com/repos/Sylius/Sylius/zipball/561a88b11e6319ae56730cc3abd15b7fa5dd0fc6", + "reference": "561a88b11e6319ae56730cc3abd15b7fa5dd0fc6", "shasum": "" }, "require": { @@ -5509,7 +5509,7 @@ ], "description": "E-Commerce platform for PHP, based on Symfony framework.", "homepage": "http://sylius.com", - "time": "2018-06-07T15:24:12+00:00" + "time": "2018-06-11T11:57:18+00:00" }, { "name": "symfony/class-loader", From fbb0750d44f06650935958ed0d39612422c44fb9 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Tue, 12 Jun 2018 16:02:17 +0200 Subject: [PATCH 5/6] Update to Sylius v1.3.0@dev --- composer.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.lock b/composer.lock index 5331fc1885..39a574f975 100644 --- a/composer.lock +++ b/composer.lock @@ -5319,12 +5319,12 @@ "source": { "type": "git", "url": "https://github.com/Sylius/Sylius.git", - "reference": "561a88b11e6319ae56730cc3abd15b7fa5dd0fc6" + "reference": "dcc532b91e4ec2ba1aca08b13a4a51987b42e1fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Sylius/Sylius/zipball/561a88b11e6319ae56730cc3abd15b7fa5dd0fc6", - "reference": "561a88b11e6319ae56730cc3abd15b7fa5dd0fc6", + "url": "https://api.github.com/repos/Sylius/Sylius/zipball/dcc532b91e4ec2ba1aca08b13a4a51987b42e1fb", + "reference": "dcc532b91e4ec2ba1aca08b13a4a51987b42e1fb", "shasum": "" }, "require": { @@ -5509,7 +5509,7 @@ ], "description": "E-Commerce platform for PHP, based on Symfony framework.", "homepage": "http://sylius.com", - "time": "2018-06-11T11:57:18+00:00" + "time": "2018-06-12T12:44:39+00:00" }, { "name": "symfony/class-loader", @@ -8178,16 +8178,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6" + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/478465659fd987669df0bd8a9bf22a8710e5f1b6", - "reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "shasum": "" }, "require": { @@ -8222,7 +8222,7 @@ "object", "object graph" ], - "time": "2018-05-29T17:25:09+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { "name": "nelmio/alice", @@ -10040,16 +10040,16 @@ }, { "name": "slevomat/coding-standard", - "version": "4.6.0", + "version": "4.6.1", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "95436f14d4a6fe8638bcba09d3a8e19266846ee4" + "reference": "de4a6fecdd6d00218e9c7d019a4ff47e123692cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/95436f14d4a6fe8638bcba09d3a8e19266846ee4", - "reference": "95436f14d4a6fe8638bcba09d3a8e19266846ee4", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/de4a6fecdd6d00218e9c7d019a4ff47e123692cf", + "reference": "de4a6fecdd6d00218e9c7d019a4ff47e123692cf", "shasum": "" }, "require": { @@ -10062,7 +10062,7 @@ "phpstan/phpstan": "0.9.2", "phpstan/phpstan-phpunit": "0.9.4", "phpstan/phpstan-strict-rules": "0.9", - "phpunit/phpunit": "7.1.5" + "phpunit/phpunit": "7.2.4" }, "type": "phpcodesniffer-standard", "autoload": { @@ -10075,7 +10075,7 @@ "MIT" ], "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", - "time": "2018-05-15T21:21:12+00:00" + "time": "2018-06-11T19:10:45+00:00" }, { "name": "squizlabs/php_codesniffer", From 5b90e85d5645ad4e7e606b207e63d294b2de2aa7 Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Fri, 1 Jun 2018 15:35:09 +0200 Subject: [PATCH 6/6] Add Docker setup --- .dockerignore | 37 +++++++ .editorconfig | 86 +++++++++++++++ .env.dist | 8 ++ .gitignore | 6 ++ Dockerfile | 151 +++++++++++++++++++++++++++ app/config/config.yml | 3 +- app/config/parameters.yml.dist | 4 +- composer.json | 2 +- composer.lock | 2 +- docker-compose.yml | 105 +++++++++++++++++++ docker/nginx/conf.d/default.conf | 39 +++++++ docker/nginx/conf.d/default_dev.conf | 62 +++++++++++ docker/nodejs/docker-entrypoint.sh | 16 +++ docker/php/docker-entrypoint.sh | 26 +++++ docker/php/php.ini | 10 ++ 15 files changed, 552 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .env.dist create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 docker/nginx/conf.d/default.conf create mode 100644 docker/nginx/conf.d/default_dev.conf create mode 100755 docker/nodejs/docker-entrypoint.sh create mode 100755 docker/php/docker-entrypoint.sh create mode 100644 docker/php/php.ini diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..6c13d444c9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,37 @@ +**/*.log +**/*.md +**/*.php~ +**/._* +**/.dockerignore +**/.DS_Store +**/.git/ +**/.gitattributes +**/.gitignore +**/.gitkeep +**/.gitmodules +**/Dockerfile +**/Thumbs.db +.editorconfig +.env* +.php_cs.cache +.travis.yml +app/config/parameters.yml +app/config/*.local.yml +bin/* +!bin/console +!bin/symfony_requirements +composer.phar +docker-compose.override.yaml +docker-compose.override.yml +docker-compose.yaml +docker-compose.yml +docker/mysql/data/ +etc/build/* +node_modules/ +var/* +vendor/ +web/assets/ +web/bundles/ +web/css/ +web/js/ +web/media/ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..b95f460c3d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,86 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.feature] +indent_style = space +indent_size = 2 + +[*.js] +indent_style = space +indent_size = 2 + +[*.json] +indent_style = space +indent_size = 2 + +[*.md] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[*.neon] +indent_style = tab +indent_size = 4 + +[*.php] +indent_style = space +indent_size = 4 + +[*.sh] +indent_style = tab +indent_size = 4 + +[*.{yaml,yml}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[.gitmodules] +indent_style = tab +indent_size = 4 + +[.php_cs{,.dist}] +indent_style = space +indent_size = 4 + +[composer.json] +indent_style = space +indent_size = 4 + +[docker-compose{,.override}.{yaml,yml}] +indent_style = space +indent_size = 2 + +[Dockerfile] +indent_style = tab +indent_size = 4 + +[package.json] +indent_style = space +indent_size = 2 + +[phpspec.yml{,.dist}] +indent_style = space +indent_size = 4 + +[phpstan.neon] +indent_style = tab +indent_size = 4 + +[phpunit.xml{,.dist}] +indent_style = space +indent_size = 4 diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000000..5cb1262d63 --- /dev/null +++ b/.env.dist @@ -0,0 +1,8 @@ +MYSQL_PASSWORD=!ChangeMe! +MYSQL_ROOT_PASSWORD=!ChangeMe! +PHP_DATE_TIMEZONE=UTC +SYLIUS_MAILER_HOST=mailhog +SYLIUS_MAILER_PASSWORD= +SYLIUS_MAILER_PORT=1025 +SYLIUS_MAILER_USER= +SYLIUS_SECRET=!ChangeMe! diff --git a/.gitignore b/.gitignore index 88aba9c46a..a99c5fcd11 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ /vendor /node_modules +/yarn-error.log /etc/build/* !/etc/build/.gitkeep @@ -26,3 +27,8 @@ /behat.yml /phpunit.xml /phpspec.yml + +/.env +/docker-compose.override.yaml +/docker-compose.override.yml +/docker/mysql/data/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..13f6ed69ed --- /dev/null +++ b/Dockerfile @@ -0,0 +1,151 @@ +ARG PHP_VERSION=7.2 +ARG NODE_VERSION=10 +ARG NGINX_VERSION=1.14 + +FROM php:${PHP_VERSION}-fpm-alpine AS sylius_php + +# persistent / runtime deps +RUN apk add --no-cache \ + acl \ + file \ + gettext \ + git \ + mariadb-client \ + ; + +ARG APCU_VERSION=5.1.11 +RUN set -eux; \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + freetype-dev \ + icu-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + libtool \ + libwebp-dev \ + libzip-dev \ + mariadb-dev \ + zlib-dev \ + ; \ + \ + docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include --with-webp-dir=/usr/include --with-freetype-dir=/usr/include/; \ + docker-php-ext-configure zip --with-libzip; \ + docker-php-ext-install -j$(nproc) \ + exif \ + gd \ + intl \ + pdo_mysql \ + zip \ + ; \ + pecl install \ + apcu-${APCU_VERSION} \ + ; \ + pecl clear-cache; \ + docker-php-ext-enable \ + apcu \ + opcache \ + ; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --no-cache --virtual .sylius-phpexts-rundeps $runDeps; \ + \ + apk del .build-deps + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +COPY docker/php/php.ini /usr/local/etc/php/php.ini + +ARG COMPOSER_AUTH= +# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser +ENV COMPOSER_ALLOW_SUPERUSER=1 +RUN set -eux; \ + composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \ + composer clear-cache +ENV PATH="${PATH}:/root/.composer/vendor/bin" + +WORKDIR /srv/sylius + +# Build for production +ARG SYMFONY_ENV=prod + +# Prevent the reinstallation of vendors at every changes in the source code +COPY composer.json composer.lock ./ +RUN set -eux; \ + composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress --no-suggest; \ + composer clear-cache + +COPY . ./ + +RUN set -eux; \ + mkdir -p var/cache var/logs; \ + composer dump-autoload --classmap-authoritative --no-dev; \ + composer run-script --no-dev post-install-cmd; \ + chmod +x bin/console; sync; \ + bin/console sylius:install:assets; \ + bin/console sylius:theme:assets:install +VOLUME /srv/sylius/var + +VOLUME /srv/sylius/web/media + +COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint +RUN chmod +x /usr/local/bin/docker-entrypoint + +ENTRYPOINT ["docker-entrypoint"] +CMD ["php-fpm"] + +FROM node:${NODE_VERSION}-alpine AS sylius_nodejs + +WORKDIR /srv/sylius + +# Build for production +ARG NODE_ENV=production +ARG GULP_ENV=prod + +RUN set -eux; \ + apk add --no-cache --virtual .build-deps \ + g++ \ + gcc \ + make \ + python \ + ; + +# Prevent the reinstallation of vendors at every changes in the source code +COPY package.json yarn.lock ./ +RUN set -eux; \ + yarn install; \ + yarn cache clean + +COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private/ +COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private/ +COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private/ + +COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js +COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js + +COPY gulpfile.babel.js .babelrc ./ +RUN set -eux; \ + if [ "${NODE_ENV}" = 'production' ]; then \ + NODE_ENV=development yarn install; \ + yarn build; \ + yarn install; \ + yarn cache clean; \ + fi + +COPY docker/nodejs/docker-entrypoint.sh /usr/local/bin/docker-entrypoint +RUN chmod +x /usr/local/bin/docker-entrypoint + +ENTRYPOINT ["docker-entrypoint"] +CMD ["node"] + +FROM nginx:${NGINX_VERSION}-alpine AS sylius_nginx + +COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/ + +WORKDIR /srv/sylius + +COPY --from=sylius_php /srv/sylius/web web/ +COPY --from=sylius_nodejs /srv/sylius/web web/ diff --git a/app/config/config.yml b/app/config/config.yml index 0e5744a731..389181b141 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -31,12 +31,12 @@ framework: doctrine: dbal: - driver: '%database_driver%' host: '%database_host%' port: '%database_port%' dbname: '%database_name%' user: '%database_user%' password: '%database_password%' + driver: pdo_mysql server_version: '5.5' charset: UTF8 @@ -49,6 +49,7 @@ doctrine_migrations: swiftmailer: transport: '%mailer_transport%' host: '%mailer_host%' + port: '%mailer_port%' username: '%mailer_user%' password: '%mailer_password%' diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index f6a60eee79..74b2665ff1 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -1,5 +1,4 @@ parameters: - database_driver: '%env(SYLIUS_DATABASE_DRIVER)%' database_host: '%env(SYLIUS_DATABASE_HOST)%' database_port: '%env(SYLIUS_DATABASE_PORT)%' database_name: '%env(SYLIUS_DATABASE_NAME)%' @@ -10,13 +9,13 @@ parameters: mailer_transport: '%env(SYLIUS_MAILER_TRANSPORT)%' mailer_host: '%env(SYLIUS_MAILER_HOST)%' + mailer_port: '%env(SYLIUS_MAILER_PORT)%' mailer_user: '%env(SYLIUS_MAILER_USER)%' mailer_password: '%env(SYLIUS_MAILER_PASSWORD)%' secret: '%env(SYLIUS_SECRET)%' # Fallback values (used if environmental variables are not set) - env(SYLIUS_DATABASE_DRIVER): pdo_mysql env(SYLIUS_DATABASE_HOST): 127.0.0.1 env(SYLIUS_DATABASE_PORT): ~ env(SYLIUS_DATABASE_NAME): sylius @@ -25,6 +24,7 @@ parameters: env(SYLIUS_MAILER_TRANSPORT): smtp env(SYLIUS_MAILER_HOST): 127.0.0.1 + env(SYLIUS_MAILER_PORT): ~ env(SYLIUS_MAILER_USER): ~ env(SYLIUS_MAILER_PASSWORD): ~ diff --git a/composer.json b/composer.json index 3206ce211d..7f9e41531c 100644 --- a/composer.json +++ b/composer.json @@ -80,7 +80,7 @@ "symfony-var-dir": "var", "symfony-web-dir": "web", "symfony-tests-dir": "tests", - "symfony-assets-install": "relative", + "symfony-assets-install": "copy", "incenteev-parameters": { "file": "app/config/parameters.yml" }, diff --git a/composer.lock b/composer.lock index 39a574f975..081b5a19f1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b8dd81d6056020a85fc3cd669bc116fc", + "content-hash": "01cddba0b9478c382de742c82d7d42fe", "packages": [ { "name": "behat/transliterator", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..59c5d171e1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,105 @@ +version: '3.4' + +services: + php: + build: + context: . + target: sylius_php + depends_on: + - mysql + environment: + - PHP_DATE_TIMEZONE + # Comment out the following line in production + - SYMFONY_ENV=dev + # Uncomment the following line in production + # - SYMFONY_ENV=prod + # Comment out the following line in production + - SYLIUS_APP_DEV_PERMITTED=1 + - SYLIUS_DATABASE_HOST=mysql + - SYLIUS_DATABASE_PORT=3306 + # Sylius will append SYMFONY_ENV to the database name, e.g. sylius -> sylius_dev + - SYLIUS_DATABASE_NAME=sylius + - SYLIUS_DATABASE_USER=sylius + - SYLIUS_DATABASE_PASSWORD=${MYSQL_PASSWORD-!NotSet!} + - SYLIUS_MAILER_TRANSPORT=smtp + - SYLIUS_MAILER_HOST=${SYLIUS_MAILER_HOST-mailhog} + - SYLIUS_MAILER_PORT=${SYLIUS_MAILER_PORT-1025} + - SYLIUS_MAILER_USER=${SYLIUS_MAILER_USER-} + - SYLIUS_MAILER_PASSWORD=${SYLIUS_MAILER_PASSWORD-} + - SYLIUS_SECRET=${SYLIUS_SECRET-!NotSet!} + volumes: + # Comment out the following line in production + - .:/srv/sylius:rw,cached + # If you develop on Linux, uncomment the following line to use a bind-mounted host directory instead + # - ./var:/srv/sylius/var:rw + # Comment out the following line in production + - ./web:/srv/sylius/web:rw,delegated + # If you develop on Linux, uncomment the following line to use a bind-mounted host directory instead + # - ./web/media:/srv/sylius/web/media:rw + # If you develop on Linux, comment out the following line + - web-media:/srv/sylius/web/media:rw + + mysql: + # In production, you may want to use a managed database service + image: percona:5.7 + environment: + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD-!NotSet!} + # Sylius will append SYMFONY_ENV to the database name, e.g. sylius -> sylius_dev + - MYSQL_DATABASE=sylius_dev + - MYSQL_USER=sylius + - MYSQL_PASSWORD=${MYSQL_PASSWORD-!NotSet!} + volumes: + - mysql-db-data:/var/lib/mysql:rw + # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! + # - ./docker/mysql/data:/var/lib/mysql:rw,delegated + ports: + - "3306:3306" + + nodejs: + # You don't need to deploy this in production, but it's still used in the build stage + build: + context: . + target: sylius_nodejs + # Comment out this following section in production + command: ["yarn", "watch"] + environment: + - GULP_ENV=dev + volumes: + - .:/srv/sylius:rw,cached + - ./web:/srv/sylius/web:rw,delegated + ports: + - "35729:35729" + # Comment out until here in production + + nginx: + # In production, you may want to use a static website hosting service + build: + context: . + target: sylius_nginx + depends_on: + - php + volumes: + # Comment out the following line in production + - ./docker/nginx/conf.d/default_dev.conf:/etc/nginx/conf.d/default.conf + # Comment out the following line in production + - ./web:/srv/sylius/web:ro + # If you develop on Linux, uncomment the following line to use a bind-mounted host directory instead + # - ./web/media:/srv/sylius/web/media:rw + # If you develop on Linux, comment out the following line + - web-media:/srv/sylius/web/media:ro,nocopy + ports: + - "80:80" + + mailhog: + # Do not use in production! + image: mailhog/mailhog:latest + environment: + - MH_STORAGE=maildir + volumes: + - ./docker/mailhog/maildir:/maildir:rw,delegated + ports: + - "8025:8025" + +volumes: + mysql-db-data: + web-media: diff --git a/docker/nginx/conf.d/default.conf b/docker/nginx/conf.d/default.conf new file mode 100644 index 0000000000..d8d03ee915 --- /dev/null +++ b/docker/nginx/conf.d/default.conf @@ -0,0 +1,39 @@ +server { + root /srv/sylius/web; + + location / { + # try to serve file directly, fallback to app.php + try_files $uri /app.php$is_args$args; + } + + # PROD + location ~ ^/app\.php(/|$) { + # Comment the next line and uncomment the lines after to enable dynamic resolution (incompatible with Kubernetes) + fastcgi_pass php:9000; + #resolver 127.0.0.11; + #set $upstream_host php; + #fastcgi_pass $upstream_host:9000; + + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + # When you are using symlinks to link the document root to the + # current version of your application, you should pass the real + # application path instead of the path to the symlink to PHP + # FPM. + # Otherwise, PHP's OPcache may not properly detect changes to + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 + # for more information). + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + # Prevents URIs that include the front controller. This will 404: + # http://domain.tld/app.php/some-path + # Remove the internal directive to allow URIs like this + internal; + } + + # return 404 for all other php files not matching the front controller + # this prevents access to other php files you don't want to be accessible. + location ~ \.php$ { + return 404; + } +} diff --git a/docker/nginx/conf.d/default_dev.conf b/docker/nginx/conf.d/default_dev.conf new file mode 100644 index 0000000000..2442c9302d --- /dev/null +++ b/docker/nginx/conf.d/default_dev.conf @@ -0,0 +1,62 @@ +server { + root /srv/sylius/web; + + location / { + # try to serve file directly, fallback to app.php + try_files $uri /app.php$is_args$args; + } + + # DEV + # This rule should only be placed on your development environment + # In production, don't include this and don't deploy app_dev.php or config.php + location ~ ^/(app_dev|config)\.php(/|$) { + # Comment the next line and uncomment the lines after to enable dynamic resolution (incompatible with Kubernetes) + fastcgi_pass php:9000; + #resolver 127.0.0.11; + #set $upstream_host php; + #fastcgi_pass $upstream_host:9000; + + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + # When you are using symlinks to link the document root to the + # current version of your application, you should pass the real + # application path instead of the path to the symlink to PHP + # FPM. + # Otherwise, PHP's OPcache may not properly detect changes to + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 + # for more information). + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + } + + # PROD + location ~ ^/app\.php(/|$) { + # Comment the next line and uncomment the lines after to enable dynamic resolution (incompatible with Kubernetes) + fastcgi_pass php:9000; + #resolver 127.0.0.11; + #set $upstream_host php; + #fastcgi_pass $upstream_host:9000; + + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + # When you are using symlinks to link the document root to the + # current version of your application, you should pass the real + # application path instead of the path to the symlink to PHP + # FPM. + # Otherwise, PHP's OPcache may not properly detect changes to + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 + # for more information). + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + # Prevents URIs that include the front controller. This will 404: + # http://domain.tld/app.php/some-path + # Remove the internal directive to allow URIs like this + internal; + } + + # return 404 for all other php files not matching the front controller + # this prevents access to other php files you don't want to be accessible. + location ~ \.php$ { + return 404; + } +} diff --git a/docker/nodejs/docker-entrypoint.sh b/docker/nodejs/docker-entrypoint.sh new file mode 100755 index 0000000000..97c4da8cea --- /dev/null +++ b/docker/nodejs/docker-entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- node "$@" +fi + +if [ "$1" = 'node' ] || [ "$1" = 'yarn' ]; then + if [ "$GULP_ENV" != 'prod' ]; then + yarn install + yarn build + fi +fi + +exec "$@" diff --git a/docker/php/docker-entrypoint.sh b/docker/php/docker-entrypoint.sh new file mode 100755 index 0000000000..39dca0e206 --- /dev/null +++ b/docker/php/docker-entrypoint.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -e + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- php-fpm "$@" +fi + +if [ "$1" = 'php-fpm' ] || [ "$1" = 'bin/console' ]; then + mkdir -p var/cache var/logs web/media + setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var web/media + setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var web/media + + if [ "$SYMFONY_ENV" != 'prod' ]; then + composer install --prefer-dist --no-progress --no-suggest --no-interaction + bin/console sylius:install:assets --no-interaction + bin/console sylius:theme:assets:install --no-interaction + >&2 echo "Waiting for MySQL to be ready..." + until select="$(echo 'SELECT 1' | mysql --host="${SYLIUS_DATABASE_HOST}" --database="${SYLIUS_DATABASE_NAME}_${SYMFONY_ENV}" --user="${SYLIUS_DATABASE_USER}" --password="${SYLIUS_DATABASE_PASSWORD}" --silent)" && [ "$select" = '1' ]; do + sleep 1 + done + bin/console sylius:install:database --no-interaction + fi +fi + +exec docker-php-entrypoint "$@" diff --git a/docker/php/php.ini b/docker/php/php.ini new file mode 100644 index 0000000000..3967e62972 --- /dev/null +++ b/docker/php/php.ini @@ -0,0 +1,10 @@ +apc.enable_cli = 1 +date.timezone = ${PHP_DATE_TIMEZONE} +opcache.enable_cli = 1 +session.auto_start = Off +short_open_tag = Off + +# http://symfony.com/doc/current/performance.html +opcache.max_accelerated_files = 20000 +realpath_cache_size = 4096K +realpath_cache_ttl = 600