diff --git a/.env b/.env new file mode 100644 index 0000000..94e095e --- /dev/null +++ b/.env @@ -0,0 +1 @@ +COMPOSE_PROJECT_NAME=sylius \ No newline at end of file diff --git a/.gitignore b/.gitignore index ddc6e66..28c79b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ docker-compose.local.yml +src/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f129e84..f0d7684 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,35 @@ -FROM sylius/nginx-php-fpm:latest +FROM php:7.2-fpm-alpine3.8 MAINTAINER Sylius Docker Team -ARG AS_UID=33 - -ENV SYLIUS_VERSION 1.1.1 +ENV SYLIUS_VERSION 1.3.2 ENV BASE_DIR /var/www ENV SYLIUS_DIR ${BASE_DIR}/sylius -#Modify UID of www-data into UID of local user -RUN usermod -u ${AS_UID} www-data - # Operate as www-data in SYLIUS_DIR per default WORKDIR ${BASE_DIR} -# Create Sylius project +RUN apk --no-cache upgrade && \ + apk --no-cache add curl icu-dev libpng-dev + +RUN docker-php-ext-install intl exif gd fileinfo pdo_mysql opcache > /dev/null 2>&1 + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer && \ + chmod +x /usr/bin/composer + +RUN chown www-data:www-data -R ${BASE_DIR}; + USER www-data -RUN composer create-project \ - sylius/sylius-standard \ - ${SYLIUS_DIR} \ - ${SYLIUS_VERSION} \ - && chmod +x sylius/bin/console \ - # Patch Sylius Standard from master (required for version < 1.1) \ - && cd sylius \ - && rm -f app/config/parameters.yml \ - && curl -o app/config/parameters.yml.dist https://raw.githubusercontent.com/Sylius/Sylius-Standard/master/app/config/parameters.yml.dist \ - && composer run-script post-install-cmd -USER root -# entrypoint.d scripts -COPY entrypoint.d/* /entrypoint.d/ +COPY sylius/sylius-fpm.ini /usr/local/etc/php/conf.d/sylius.ini + +RUN composer global require hirak/prestissimo && \ + composer create-project sylius/sylius-standard ${SYLIUS_DIR} ${SYLIUS_VERSION} -# nginx configuration -COPY nginx/nginx.conf /etc/nginx/nginx.conf -COPY nginx/sylius_params /etc/nginx/sylius_params +COPY sylius/.env ${SYLIUS_DIR}/.env -RUN chown www-data.www-data /etc/nginx/sylius_params +RUN chmod +x sylius/bin/console && \ + mkdir -p ${SYLIUS_DIR}/public/media/image + +# entrypoint.d scripts +COPY entrypoint.d/* /entrypoint.d/ diff --git a/README.md b/README.md index 889d1ca..6e63cd4 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Because ``docker-compose.yml`` uses Compose file format 2.1 at least **Docker ve ``` git clone https://github.com/sylius/docker sylius-docker +cd sylius-docker make help make up make console CMD=sylius:install diff --git a/docker-compose.yml b/docker-compose.yml index 57f90ea..b901d31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,30 @@ -version: '2.1' +version: '3.1' services: - sylius: - container_name: ${NAME}-app + nginx: + image: nginx:1-alpine + depends_on: + - php-fpm + ports: + - 8000:80 + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf + - ./nginx/sylius_params:/etc/nginx/sylius_params + - ./src:/var/www/sylius + + php-fpm: build: - context: . - args: - - AS_UID=${AS_UID:-33} + context: . environment: - SYLIUS_DATABASE_HOST=mysql - SYLIUS_DATABASE_USER=sylius - SYLIUS_DATABASE_PASSWORD=sylius - SYLIUS_MAILER_HOST=mailhog:1025 - SYLIUS_APP_DEV_PERMITTED=1 - ports: - - 8000:80 + volumes: + - ./src:/var/www/sylius mysql: - container_name: ${NAME}-mysql image: percona:5.7 environment: MYSQL_ROOT_PASSWORD: sylius @@ -28,7 +35,6 @@ services: - 127.0.0.1:3606:3306 mailhog: - container_name: ${NAME}-mailhog image: mailhog/mailhog:latest ports: - 8025:8025 diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 8f1f8a0..b3ce42d 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,4 +1,3 @@ -user www-data; worker_processes auto; worker_rlimit_nofile 2048; @@ -11,7 +10,7 @@ events { http { upstream sylius { - server sylius:9000; + server php-fpm:9000; } include /etc/nginx/mime.types; @@ -36,8 +35,8 @@ http { # General virtual host settings server_name _; - root /var/www/sylius/web/; - index app_dev.php; + root /var/www/sylius/public/; + index index.php; charset utf-8; # Don't send the nginx version number in error pages and Server header @@ -45,14 +44,14 @@ http { # Root directory location handler location / { - try_files $uri $uri/ /app_dev.php?$query_string; + try_files $uri $uri/ /index.php?$query_string; } # php-fpm configuration location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass sylius; - fastcgi_index app_dev.php; + fastcgi_index index.php; include fastcgi_params; diff --git a/sylius/.env b/sylius/.env new file mode 100644 index 0000000..3afdeb0 --- /dev/null +++ b/sylius/.env @@ -0,0 +1,23 @@ +# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file +# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production. +# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration + +###> symfony/framework-bundle ### +APP_ENV=dev +APP_DEBUG=1 +APP_SECRET=EDITME +###< symfony/framework-bundle ### + +###> 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 sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" +# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls +DATABASE_URL=mysql://sylius:sylius@mysql/sylius_%kernel.environment% +###< doctrine/doctrine-bundle ### + +###> symfony/swiftmailer-bundle ### +# For Gmail as a transport, use: "gmail://username:password@localhost" +# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" +# Delivery is disabled by default via "null://localhost" +MAILER_URL=smtp://localhost +###< symfony/swiftmailer-bundle ### diff --git a/sylius/.gitignore b/sylius/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/sylius/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/sylius/sylius-fpm.ini b/sylius/sylius-fpm.ini new file mode 100644 index 0000000..3b35e2f --- /dev/null +++ b/sylius/sylius-fpm.ini @@ -0,0 +1,9 @@ +memory_limit = 2560M + +error_reporting = E_ALL +error_log = /var/log/php/php_errors.log +log_errors = on + +date.timezone = Europe/Zurich +date.default_latitude = 47.3676407 +date.default_longitude = 8.5620881 \ No newline at end of file