From b117f4ea0c030e084d92b00697fb56ea3712d995 Mon Sep 17 00:00:00 2001 From: Vincent Lopes-Vicente Date: Wed, 1 Apr 2020 22:09:06 +0200 Subject: [PATCH] Add docker + other various fixes --- .docker/mysql-data/.gitkeep | 0 .docker/nginx/nginx.conf | 55 +++++++++++ .docker/php-fpm/Dockerfile | 19 ++++ .docker/php-fpm/php-ini-overrides.ini | 14 +++ .gitignore | 28 +----- Readme.md | 129 ++++++++++++++++---------- composer.json | 8 +- docker-compose.yml | 37 ++++++++ 8 files changed, 213 insertions(+), 77 deletions(-) create mode 100644 .docker/mysql-data/.gitkeep create mode 100644 .docker/nginx/nginx.conf create mode 100644 .docker/php-fpm/Dockerfile create mode 100644 .docker/php-fpm/php-ini-overrides.ini create mode 100755 docker-compose.yml diff --git a/.docker/mysql-data/.gitkeep b/.docker/mysql-data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.docker/nginx/nginx.conf b/.docker/nginx/nginx.conf new file mode 100644 index 0000000..decbb57 --- /dev/null +++ b/.docker/nginx/nginx.conf @@ -0,0 +1,55 @@ +server { + listen 80; + + root /application/web/; + index index.php; + + access_log /var/log/nginx/starter.tld_access.log; + error_log /var/log/nginx/starter.tld_error.log; + + + location / { + try_files $uri $uri/ @rewriteapp; + } + + location @rewriteapp { + # rewrite all to index.php + rewrite ^(.*)$ /index.php/$1 last; + } + + # Php configuration + location ~ ^/(index|index_dev)\.php(/|$) { + # Php-FPM Config (Socks or Network) + #fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; + fastcgi_pass php-fpm:9000; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_read_timeout 3000; + } + + # Security. discard all files and folders starting with a "." + location ~ /\. { + deny all; + access_log off; + log_not_found off; + } + # Stuffs + location = /favicon.ico { + allow all; + access_log off; + log_not_found off; + } + location ~ /robots.txt { + allow all; + access_log off; + log_not_found off; + } + + # Static files + location ~* ^.+\.(jpg|jpeg|gif|css|png|js|pdf|zip)$ { + expires 30d; + access_log off; + log_not_found off; + } +} \ No newline at end of file diff --git a/.docker/php-fpm/Dockerfile b/.docker/php-fpm/Dockerfile new file mode 100644 index 0000000..6d8c27b --- /dev/null +++ b/.docker/php-fpm/Dockerfile @@ -0,0 +1,19 @@ +FROM phpdockerio/php73-fpm:latest +WORKDIR "/application" + +# Fix debconf warnings upon build +ARG DEBIAN_FRONTEND=noninteractive + +# Install selected extensions and other stuff +RUN apt-get update \ + && apt-get -y --no-install-recommends install php7.3-mysql php7.3-gd php-imagick php7.3-intl php-xdebug \ + && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +# Install git +RUN apt-get update \ + && apt-get -y install git \ + && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +RUN apt-get update \ + && apt-get -y install vim \ + && apt-get clean; \ No newline at end of file diff --git a/.docker/php-fpm/php-ini-overrides.ini b/.docker/php-fpm/php-ini-overrides.ini new file mode 100644 index 0000000..8647ab2 --- /dev/null +++ b/.docker/php-fpm/php-ini-overrides.ini @@ -0,0 +1,14 @@ +upload_max_filesize = 100M +post_max_size = 108M +html_errors=On +display_errors=On +date.timezone=Europe/Paris +max_execution_time = 80 + +xdebug.remote_enable=1 +xdebug.remote_autostart=0 +xdebug.remote_port=9000 +xdebug.remote_handler=dbgp +xdebug.profiler_enable=0 +xdebug.profiler_enable_trigger=1 +xdebug.profiler_output_dir="/application/log" diff --git a/.gitignore b/.gitignore index 1ea59fe..cec8ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ !/cache/.gitkeep !/log/.gitkeep !/cache/.htaccess +.docker/mysql-data/* +!.docker/mysql-data/.gitkeep # Thelia default templates /templates/frontOffice/default @@ -20,29 +22,7 @@ /local/media /local/session -# Thelia default modules -/local/modules/Cheque -/local/modules/Carousel -/local/modules/HookCurrency -/local/modules/HookProductsNew -/local/modules/Tinymce -/local/modules/Colissimo -/local/modules/HookCustomer -/local/modules/HookProductsOffer -/local/modules/VirtualProductControl -/local/modules/Front -/local/modules/HookLang -/local/modules/HookSearch -/local/modules/VirtualProductDelivery -/local/modules/HookAnalytics -/local/modules/HookLinks -/local/modules/HookSocial -/local/modules/HookCart -/local/modules/HookNavigation -/local/modules/TheliaDebugBar -/local/modules/HookContact -/local/modules/HookNewsletter -/local/modules/TheliaSmarty -/local/modules/FreeOrder +# Thelia modules +/local/modules/* ### Please add your dependancies here diff --git a/Readme.md b/Readme.md index 76d3c70..3530612 100644 --- a/Readme.md +++ b/Readme.md @@ -33,6 +33,85 @@ Requirements * Web Server Apache 2 or Nginx * MySQL 5 +## Create a Thelia project + +``` bash +$ curl -sS https://getcomposer.org/installer | php +$ php composer.phar create-project thelia/thelia-project path/ 2.3.2 (or 2.2.4) +``` + +## Install it with your own environment + +You can install Thelia using the cli tool and the scripts provided by thelia/setup + +``` bash +$ php Thelia thelia:install +``` + +Consult the page : http://localhost/thelia/web/index_dev.php + +You can create a virtual host and choose web folder for root directory. + +## Quick install with docker-compose + +`Docker` and `docker-compose` have to be installed. + +Build your docker containers on detached mode +``` bash +$ docker-compose up -d +``` + +Install thelia +``` bash +$ php Thelia thelia:install +``` +By default if you haven't changed the `docker-compose.yml` you'll have to answer these questions like this + +``` +Database host [default: localhost] : mariadb +``` +``` +Database port [default: 3306] : 3306 +``` +``` +Database name (if database does not exist, Thelia will try to create it) : thelia +``` + +``` +Database username : thelia +``` + +``` +Database pasword : thelia +``` + +Next just go to http://localhost:8080 and you should see your Thelia installed ! + +If you want add some sample data just execute this command (still in your container) +``` bash +$ php local/setup/import.php +``` + +If you want to access your database from your computer (with DBeaver, Sequel Pro or anything else) the host is `localhost` and the port is `8086` + +Documentation +------------- + +Thelia documentation is available at http://doc.thelia.net + +Roadmap +------- + +The Roadmap is available at http://thelia.net/community/roadmap + + +Contribute +---------- + +See the documentation : http://doc.thelia.net/en/documentation/contribute.html + +### Mac OSX + If you use Mac OSX, it still doesn't use php 5.4 as default php version... There are many solutions for you : * use [phpbrew](https://github.com/c9s/phpbrew) @@ -81,52 +160,4 @@ phar.readonly = Off For tar.bz2 archives, you need tar's dependencies and the extension "bzip2". See [PHP Doc](http://php.net/manual/fr/book.bzip2.php) -For tar.gz archives, you need tar's dependencies and the extension "zlib". See [PHP Doc](http://fr2.php.net/manual/fr/book.zlib.php) - -## Create a Thelia project - -``` bash -$ curl -sS https://getcomposer.org/installer | php -$ php composer.phar create-project thelia/thelia-project path/ 2.4.0 (or 2.3.5) -``` - -## Install it - -You can install Thelia using the cli tool and the scripts provided by thelia/setup - -### Using cli tools - -``` bash -$ php Thelia thelia:install -``` - -You just have to follow all instructions. - -Documentation -------------- - -Thelia documentation is available at http://doc.thelia.net - -The documentation is also in beta version and some part can be obsolete cause to some refactor. - - -Roadmap -------- - -The Roadmap is available at http://thelia.net/community/roadmap - - -Contribute ----------- - -see the documentation : http://doc.thelia.net/en/documentation/contribute.html - -Usage ------ - -Consult the page : http://localhost/thelia/web/index_dev.php - -You can create a virtual host and choose web folder for root directory. - -We still have lot of work to achieve but enjoy this part. - +For tar.gz archives, you need tar's dependencies and the extension "zlib". See [PHP Doc](http://fr2.php.net/manual/fr/book.zlib.php) \ No newline at end of file diff --git a/composer.json b/composer.json index cc7aeb4..54943f7 100644 --- a/composer.json +++ b/composer.json @@ -30,10 +30,10 @@ "thelia/hook-customer-module": "2.4.0", "thelia/hook-products-offer-module": "2.4.0", "thelia/hook-newsletter-module": "2.4.0", - "thelia/carousel-module": "dev-master", - "thelia/free-order-module": "dev-master", - "thelia/thelia-migrate-country-module": "dev-master", - "thelia/hook-admin-home-module": "dev-master" + "thelia/carousel-module": "2.4.0", + "thelia/free-order-module": "2.4.0", + "thelia/thelia-migrate-country-module": "2.4.0", + "thelia/hook-admin-home-module": "2.4.0" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..3df6913 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +version: "3.1" + +services: + + mariadb: + image: mariadb:10.1 + container_name: thelia-mariadb + working_dir: /application + volumes: + - .:/application + - .docker/mysql-data:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=root + - MYSQL_DATABASE=thelia + - MYSQL_USER=thelia + - MYSQL_PASSWORD=thelia + ports: + - "8086:3306" + + webserver: + image: nginx:alpine + container_name: thelia-webserver + working_dir: /application + volumes: + - .:/application + - .docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf + ports: + - "8080:80" + + php-fpm: + build: .docker/php-fpm + container_name: thelia-php-fpm + working_dir: /application + volumes: + - .:/application + - .docker/php-fpm/php-ini-overrides.ini:/etc/php/7.3/fpm/conf.d/99-overrides.ini + - .docker/php-fpm/php-ini-overrides.ini:/etc/php/7.3/cli/conf.d/99-overrides.ini \ No newline at end of file