├── .gitignore
├── README.md
├── bin
├── bash
├── cache-clean
├── clear-download
├── cli
├── clinotty
├── composer
├── composer1
├── copyfromcontainer
├── copytocontainer
├── create-envfile
├── destroy
├── dev-urn-catalog-generate
├── devconsole
├── docker-compose
├── docker-copy
├── down
├── env-set
├── exec
├── exec-root
├── fixowns
├── fixperms
├── grunt
├── helper
│ ├── base-options
│ ├── container-id
│ ├── docker-ip
│ ├── env-create
│ ├── question
│ ├── random
│ ├── services-status
│ ├── version-compare
│ ├── xdebug-prepare
│ └── xdebug-status
├── install
├── logs
├── magento
├── magento-download
├── magento-extract
├── mkcert
├── mkcert-ca-copy
├── mkcert-ca-generate
├── mkcert-generate
├── mkcert-generate-ca
├── mysql
├── mysqldump
├── n98
├── nginx
├── nginx-reload
├── node
├── npm
├── php
├── phpunit
├── pwa-studio
├── redis
├── remove
├── restart
├── revive
├── root
├── rootnotty
├── setup
├── setup-grunt
├── setup-pmm
├── setup-pwa-studio
├── setup-ssl
├── setup-ssl-ca
├── setup-vhost
├── ssh
├── start
├── status
├── stop
├── up
├── update
├── xdebug
├── xdebug-mode
└── xdebug-request-mode
├── config
├── apache
│ └── conf
│ │ └── vhosts
│ │ ├── magento2.conf
│ │ └── magento2.ssl.conf.example
├── nginx
│ └── conf.d
│ │ ├── .gitignore
│ │ ├── 000_upstream.conf
│ │ ├── 000_xdefault.conf
│ │ └── include
│ │ ├── magento1
│ │ ├── base.conf
│ │ ├── gzip.conf
│ │ └── location
│ │ │ ├── application.conf
│ │ │ ├── errors.conf
│ │ │ ├── media.conf
│ │ │ ├── pub.conf
│ │ │ ├── setup.conf
│ │ │ ├── static.conf
│ │ │ └── update.conf
│ │ └── magento2
│ │ ├── base.conf
│ │ ├── gzip.conf
│ │ └── location
│ │ ├── application.conf
│ │ ├── default_ssl.conf
│ │ ├── errors.conf
│ │ ├── media.conf
│ │ ├── pub.conf
│ │ ├── setup.conf
│ │ ├── static.conf
│ │ └── update.conf
└── varnish
│ ├── default.vcl
│ └── original.vcl
├── docker-compose.yml
├── services
├── .gitignore
├── docker-compose.blackfire.yml
├── docker-compose.dev.mac.yml
├── docker-compose.dev.yml
├── docker-compose.elastichq.yml
├── docker-compose.kibana.yml
├── docker-compose.mailhog.yml
├── docker-compose.rabbitmq.yml
└── docker-compose.varnish.yml
└── var
├── .dockerlab
├── .gitignore
├── dumps
└── .gitignore
├── ssl
├── .gitignore
└── certificates
│ └── .gitignore
├── template
├── docker-compose
│ └── custom.yml
└── nginx
│ ├── magento2-ssl.conf
│ ├── magento2-vars.conf
│ ├── magento2.conf
│ └── upstream.conf
└── volumes
└── .gitignore
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea/
2 | /src
3 | /*.sql
4 | /*.tar*
5 | /*.php
6 | /*.yml
7 | /*.yaml
8 | !/docker-compose.yml
9 | /*.gz
10 | /.env
11 | *.pem
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Magento DockerLab
2 |
3 | A development environment for Magento 2.
4 |
5 | [](https://travis-ci.org/magedin/magento-dockerlab)
6 |
7 | Magento DockerLab is intended to be an easy and fast Magento 2 Docker development environment setup. Some of the key features of this environment are:
8 |
9 | - Setup a Magento 2 development environment in seconds.
10 | - You can have the latest Magento 2 version (or whatever version you need) with one single line of command.
11 | - Everything you need when it comes to Magento 2 dependencies.
12 | - Turn on and off XDebug automatically with only one command.
13 | - Many more features!
14 |
15 | ## What's included?
16 |
17 | Magento DockerLab is a complete stack just for your convenience and it includes the following services out of the box:
18 |
19 | - PHP
20 | - Nginx
21 | - MySQL (You can use MariaDB and Percona too)
22 | - Redis
23 | - RabbitMQ with RabbitMQ Management
24 | - MailHog
25 | - ElasticSearch
26 | - Kibana (for data visualization in ElasticSearch)
27 |
28 | ## Compatibility
29 |
30 | - Linux
31 | - macOS
32 | - Windows (WSL2)
33 |
34 | ## Prerequisites
35 |
36 | This setup assumes you are running Docker on a computer with at least 4GB of allocated RAM, a dual-core, and an SSD hard drive. [Download & Install Docker Desktop](https://www.docker.com/products/docker-desktop).
37 |
38 | This configuration has been tested on Linux.
39 |
40 | ## Getting Started
41 |
42 | This docker compose project is intended to make the developer's life easier when it comes to Magento 2 development environment. The Magento 2 installation process is very straightforward by using this project.
43 |
44 | ### Installing Everything Automatically
45 |
46 | In many cases, when we are starting a new project or we just want to play around with Magento 2, we just need to setup a new environment without any complexity, configuration or anything like that. The problem is that most of the times we struggle so much with setting up a new environment that we give up in the middle of the process.
47 |
48 | This docker compose has an automation to avoid any headaches when it comes to having a Magento 2 running in your local machine. Just follow the following steps:
49 |
50 | #### Setup a Virtual Host
51 |
52 | With a vhost it becomes easier to install and run Magento 2.
53 |
54 | - Open your terminal;
55 | - Run `> sudo vim /etc/hosts`;
56 | - Add the follwing line if it does not exist: `127.0.0.1 ::1 magento2.test`;
57 | - Save the document.
58 |
59 | #### Install Magento 2
60 |
61 | This is very simple!
62 |
63 | - Run `bin/setup`
64 |
65 | #### Test the New Installation
66 |
67 | Now go to your default browser and type the following address in the address bar:
68 |
69 | `https://magento2.test`
70 |
71 | Because of the SSL was a self-signed one the browser will complain about the risk of accessing this resource, blá, blá, blá. Just keep on accessing the website.
72 |
73 | #### Setup Self Signed SSL
74 |
75 | For each installation of this project you'll have a new Certified Authority (CA) file generated. You probably don't know exactly what this means and what's it importance of this file but, in a nutshell, I can say that this file makes your browser to trust your self-signed SSL certificate as if you had bought one.
76 |
77 | To import the CA file you need to take the following steps:
78 |
79 | ##### For Google Chrome
80 |
81 | - Go to `Settings > Privacy and Security > Security > Manage Certificates > Authorities > Import`.
82 | - Navigate to the root project where your Magento was installed and go to `var/ssl/ca` and choose the auto-generated file `rootCA.pem`.
83 |
84 | ##### For Firefox
85 |
86 | - Go to `Preferences > Privacy & Security > Certificates > View Certificates > Authorities > Import`.
87 | - Navigate to the root project where your Magento was installed and go to `var/ssl/ca` and choose the auto-generated file `rootCA.pem`.
88 |
89 | - That's it! Now the little locks in the left side of your browser's address bar is green and you are not going to be warned again about self-signed certificates for this project.
90 |
91 | ## Debugging Magento 2 with XDebug
92 |
93 | TBD
94 |
95 | ## Linux
96 |
97 | Running Docker on Linux should be pretty straight-forward. Note that you need to run some [post install commands](https://docs.docker.com/install/linux/linux-postinstall/) as well as [installing Docker Compose](https://docs.docker.com/compose/install/). These steps are taken care of automatically with Docker Desktop, but not on Linux.
98 |
99 | You may have to increase a virtual memory map count on the host system. It is required by [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html).
100 |
101 | Add following line to `/etc/sysctl.conf`:
102 |
103 | ```bash
104 | vm.max_map_count=262144
105 | ```
106 |
107 | ## License
108 |
109 | [MIT](https://opensource.org/licenses/MIT)
110 |
--------------------------------------------------------------------------------
/bin/bash:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/cli bash
3 |
--------------------------------------------------------------------------------
/bin/cache-clean:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/xdebug-status
4 |
5 | ENABLE=0
6 |
7 | if ( isXdebugEnabled ); then
8 | disableXdebug
9 | ENABLE=1
10 | fi
11 |
12 | if [ -z "$@" ]; then
13 | echo "Cleaning all Magento cache."
14 | else
15 | echo "Cleaning Magento cache type(s): $@"
16 | fi
17 |
18 | bin/magento cache:clean "$@" &> /dev/null
19 | echo "Rebuilding the cache..."
20 | bin/magento &> /dev/null
21 |
22 | if [ $ENABLE == 1 ]; then
23 | enableXdebug
24 | fi
25 |
--------------------------------------------------------------------------------
/bin/clear-download:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./var/env/config.env
4 |
5 | if [ -z "$1" ]; then
6 | FILE="*"
7 | else
8 | FILE="$1.tar.gz"
9 | fi
10 |
11 | rm -rf $DOWNLOAD_DIR/$FILE
12 |
--------------------------------------------------------------------------------
/bin/cli:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
3 | bin/exec php "$@"
4 |
--------------------------------------------------------------------------------
/bin/clinotty:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
3 | bin/docker-compose exec -T php "$@"
4 |
--------------------------------------------------------------------------------
/bin/composer:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/services-status
4 |
5 | if ( ! areServicesRunning ); then
6 | echo "Services are not running.";
7 | exit 1;
8 | fi
9 |
10 | bin/cli composer "$@"
11 |
--------------------------------------------------------------------------------
/bin/composer1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/services-status
4 |
5 | if ( ! areServicesRunning ); then
6 | echo "Services are not running.";
7 | exit 1;
8 | fi
9 |
10 | bin/cli composer1 "$@"
11 |
--------------------------------------------------------------------------------
/bin/copyfromcontainer:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a directory or file to copy from container (ex. vendor, --all)" && exit
3 |
4 | function containerId() {
5 | echo $(bin/helper/container-id $1);
6 | }
7 |
8 | REAL_SRC=$(cd -P "src" && pwd)
9 | CONTAINER_ID=$(containerId php)
10 | if [ "$1" == "--all" ]; then
11 | docker cp ${CONTAINER_ID}:/var/www/html/./ $REAL_SRC/
12 | echo "Completed copying all files from container to host"
13 | else
14 | if [ -f "$1" ] ; then
15 | docker cp ${CONTAINER_ID}:/var/www/html/$1 $REAL_SRC/$1
16 | else
17 | docker cp ${CONTAINER_ID}:/var/www/html/$1 $REAL_SRC/$(dirname $1)
18 | fi
19 | echo "Completed copying $1 from container to host"
20 | fi
21 |
--------------------------------------------------------------------------------
/bin/copytocontainer:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a directory or file to copy to container (ex. vendor, --all)" && exit
3 |
4 | function containerId() {
5 | echo $(bin/helper/container-id $1);
6 | }
7 |
8 | REAL_SRC=$(cd -P "src" && pwd)
9 | CONTAINER_ID=$(containerId php)
10 |
11 | if [ "$1" == "--all" ]; then
12 | docker cp $REAL_SRC/./ ${CONTAINER_ID}:/var/www/html/
13 | echo "Completed copying all files from host to container"
14 |
15 | bin/fixowns
16 | bin/fixperms
17 | else
18 | if [ -f "$REAL_SRC/$1" ]; then
19 | docker cp $REAL_SRC/$1 ${CONTAINER_ID}:/var/www/html/$1
20 | else
21 | docker cp $REAL_SRC/$1 ${CONTAINER_ID}:/var/www/html/$(dirname $1)
22 | fi
23 |
24 | echo "Completed copying $1 from host to container"
25 |
26 | bin/fixowns $1
27 | bin/fixperms $1
28 | fi
29 |
--------------------------------------------------------------------------------
/bin/create-envfile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | ./bin/helper/env-create
3 |
--------------------------------------------------------------------------------
/bin/destroy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source bin/create-envfile
4 | source ./var/env/config.env
5 | source ./.env
6 |
7 | bin/remove -a
8 | #rm -rf $EXTRACT_DIR
9 | rm -rf $NGINX_CONF_DIR/$BASE_URL*
10 |
--------------------------------------------------------------------------------
/bin/dev-urn-catalog-generate:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/magento dev:urn-catalog:generate misc.xml
3 | bin/copyfromcontainer misc.xml
4 | mv src/misc.xml src/.idea/misc.xml
5 |
6 | echo "URN's have been generated, you may now restart PHPStorm"
7 |
--------------------------------------------------------------------------------
/bin/devconsole:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/cli bin/n98-magerun2.phar dev:console
3 |
--------------------------------------------------------------------------------
/bin/docker-compose:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/base-options
4 | source ./.env
5 |
6 | # -------------------------------------------------------------
7 |
8 | OPTIONS="-f ./docker-compose.yml"
9 | OS=$(uname)
10 |
11 | # DEVELOPMENT
12 | if [[ -f ./docker-compose.dev.mac.yml ]] && [[ ${OS} == 'Darwin' ]]; then
13 | OPTIONS="${OPTIONS} -f ./docker-compose.dev.mac.yml"
14 | elif [[ -f ./docker-compose.dev.yml ]]; then
15 | OPTIONS="${OPTIONS} -f ./docker-compose.dev.yml"
16 | fi
17 |
18 | # KIBANA
19 | if [ -f ./docker-compose.kibana.yml ] && [ "${SERVICE_KIBANA_ENABLED}" == 1 ] ; then
20 | OPTIONS="${OPTIONS} -f ./docker-compose.kibana.yml"
21 | fi
22 |
23 | # MAILHOG
24 | if [ -f ./docker-compose.mailhog.yml ] && [ "${SERVICE_MAILHOG_ENABLED}" == 1 ] ; then
25 | OPTIONS="${OPTIONS} -f ./docker-compose.mailhog.yml"
26 | fi
27 |
28 | # JENKINS
29 | if [ -f ./docker-compose.jenkins.yml ] && [ "${SERVICE_JENKINS_ENABLED}" == 1 ] ; then
30 | OPTIONS="${OPTIONS} -f ./docker-compose.jenkins.yml"
31 | fi
32 |
33 | # PERCONA MONITORING AND MANAGEMENT
34 | if [ -f ./docker-compose.pmm.yml ] && [ "${SERVICE_PMM_ENABLED}" == 1 ] ; then
35 | OPTIONS="${OPTIONS} -f ./docker-compose.pmm.yml"
36 | fi
37 |
38 | # CUSTOM
39 | if [ -f ./docker-compose.custom.yml ]; then
40 | OPTIONS="${OPTIONS} -f ./docker-compose.custom.yml"
41 | fi
42 |
43 | docker-compose ${OPTIONS} "$@"
44 |
--------------------------------------------------------------------------------
/bin/docker-copy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a directory or file to copy from container (ex. vendor, --all)" && exit
3 |
4 | CONTAINER=$1
5 | DIR_FROM=$2
6 | DIR_TO=$3
7 |
8 | docker cp $(bin/docker-compose ps -q ${CONTAINER}|awk '{print $1}'):${DIR_FROM} ${DIR_TO}
9 |
--------------------------------------------------------------------------------
/bin/down:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | echo "Getting the environment down. Please wait..."
3 | #bin/remove &> /dev/null
4 | bin/remove
5 |
6 | if [ $? -eq 0 ]; then
7 | echo "Done! Take some rest."
8 | else
9 | echo "Something went wrong on trying to stop the services."
10 | exit 1
11 | fi
12 |
--------------------------------------------------------------------------------
/bin/env-set:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | [ -z "$1" ] && echo "Please specify the environment variable you wanna change." && exit
4 | [ -z "$2" ] && echo "Please specify the environment variable value you wanna set." && exit
5 |
6 | source ./bin/create-envfile
7 | source ./.env
8 |
9 | VARIABLE=$1
10 | VALUE=$2
11 |
12 | sed -i -e "s/${VARIABLE}\=.*/${VARIABLE}\=${VALUE}/g" ./.env
13 |
--------------------------------------------------------------------------------
/bin/exec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a container and right after the command to be executed in the container." && exit
3 | [ -z "$2" ] && echo "Please specify the command to be executed in the container." && exit
4 | bin/docker-compose exec "$@"
5 |
--------------------------------------------------------------------------------
/bin/exec-root:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a container and right after the command to be executed in the container." && exit
3 | [ -z "$2" ] && echo "Please specify the command to be executed in the container." && exit
4 | bin/exec -u root "$@"
5 |
--------------------------------------------------------------------------------
/bin/fixowns:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | echo "Correcting filesystem ownerships..."
3 |
4 | if [ -z "$1" ]; then
5 | bin/rootnotty chown -R www:www /var/www/
6 | else
7 | bin/rootnotty chown -R www:www /var/www/html/$1
8 | fi
9 |
10 | echo "Filesystem ownerships corrected."
11 |
--------------------------------------------------------------------------------
/bin/fixperms:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | echo "Correcting filesystem permissions..."
3 |
4 | if [ -z "$1" ]; then
5 | bin/root find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \;
6 | bin/root find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \;
7 | bin/root chmod u+x bin/magento
8 | else
9 | bin/root find $1 -type f -exec chmod u+w {} \;
10 | bin/root find $1 -type d -exec chmod u+w {} \;
11 | fi
12 |
13 | echo "Filesystem permissions corrected."
14 |
--------------------------------------------------------------------------------
/bin/grunt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/cli grunt "$@"
3 |
--------------------------------------------------------------------------------
/bin/helper/base-options:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | WITH_PMM=0
4 | WITH_JENKINS=0
5 | WITH_MAILHOG=0
6 |
7 | for option in "$@"; do
8 | # echo $option
9 | case $option in
10 | --with-pmm)
11 | WITH_PMM=1;
12 | # shift # past argument with no value
13 | ;;
14 | --with-jenkins)
15 | WITH_JENKINS=1;
16 | # shift # past argument with no value
17 | ;;
18 | --with-mailhog)
19 | WITH_MAILHOG=1;
20 | # shift # past argument with no value
21 | ;;
22 | --default)
23 | # shift # past argument with no value
24 | ;;
25 | esac
26 | done
27 |
28 | # ------------------------------------------------
29 |
30 | function with_pmm() {
31 | if [ $WITH_PMM -eq 1 ]; then
32 | return 0;
33 | fi
34 | #return 1;
35 | # For now, aways return true.
36 | return 0;
37 | }
38 |
39 |
40 | function with_jenkins() {
41 | if [ $WITH_JENKINS -eq 1 ]; then
42 | return 0;
43 | fi
44 | #return 1;
45 | # For now, aways return true.
46 | return 0;
47 | }
48 |
49 | function with_mailhog() {
50 | if [ $WITH_MAILHOG -eq 1 ]; then
51 | return 0;
52 | fi
53 | #return 1;
54 | # For now, aways return true.
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/bin/helper/container-id:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/services-status
4 |
5 | if ( ! servicesExist ); then
6 | echo "Services are down.";
7 | exit 1;
8 | fi
9 |
10 | if [ -z "$1" ]; then
11 | echo "Please specify one of the containers below:";
12 | bin/status --services;
13 | exit 1;
14 | fi
15 |
16 | bin/docker-compose ps -q $1|awk '{print $1}';
17 |
--------------------------------------------------------------------------------
/bin/helper/docker-ip:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | docker run --rm alpine ip route | awk 'NR==1 {print $3}'
3 |
--------------------------------------------------------------------------------
/bin/helper/env-create:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | BASE_FILE=.env
4 | FILES=('services' 'magento' 'db' 'redis' 'elasticsearch' 'rabbitmq' 'aws')
5 |
6 | function copy() {
7 | echo "# - ${1} Variables ----------------------------------" | cat - ${2} >> ${BASE_FILE}
8 | echo "# - ${1} Variables ----------------------------------" >> ${BASE_FILE}
9 |
10 | if [ ! -z ${3} ]; then
11 | echo >> ${BASE_FILE}
12 | echo >> ${BASE_FILE}
13 | fi
14 | }
15 |
16 | function create_base_file() {
17 | touch ${BASE_FILE};
18 | }
19 |
20 | function loop_files() {
21 | for i in ${FILES[@]}; do
22 | if [ -f ./var/env/${i}.env ]; then
23 | copy ${i} ./var/env/${i}.env y;
24 | fi
25 | done ;
26 | }
27 |
28 | if [ ! -f ${BASE_FILE} ]; then
29 | create_base_file
30 | loop_files
31 | fi
32 |
--------------------------------------------------------------------------------
/bin/helper/question:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | read -p "$1. Please type 'y' for YES or any other key for NO." -n 1 -r
3 |
4 | echo
5 |
6 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then
7 | echo 0
8 | exit 1
9 | fi
10 |
11 | echo 1
12 |
--------------------------------------------------------------------------------
/bin/helper/random:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo $(openssl rand -hex 12)
4 |
--------------------------------------------------------------------------------
/bin/helper/services-status:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | function areServicesRunning() {
4 | RESULT=$(bin/status --filter "status=running" --services)
5 |
6 | if [ -z "$RESULT" ]; then
7 | return 1;
8 | else
9 | return 0;
10 | fi
11 | }
12 |
13 |
14 | function areServicesStopped() {
15 | RESULT=$(bin/status --filter "status=stopped" --services)
16 |
17 | if [ -z "$RESULT" ]; then
18 | return 1;
19 | else
20 | return 0;
21 | fi
22 | }
23 |
24 |
25 | function servicesExist() {
26 | RESULT=$(bin/status --quiet)
27 |
28 | if [ -z "$RESULT" ]; then
29 | return 1;
30 | else
31 | return 0;
32 | fi
33 | }
34 |
--------------------------------------------------------------------------------
/bin/helper/version-compare:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CURRENT_VERSION=${1}
4 |
5 | TWO_ZERO="^2\.([0-9])\..*"
6 | TWO_ONE="^2\.([1-9])\..*"
7 | TWO_TWO="^2\.([2-9])\..*"
8 | TWO_THREE="^2\.([3-9])\..*"
9 | TWO_FOUR="^2\.([4-9])\..*"
10 | TWO_FIVE="^^2\.([5-9])\..*"
11 | TWO_SIX="^2\.([6-9])\..*"
12 | TWO_SEVEN="^2\.([7-9])\..*"
13 |
14 | function compare() {
15 | if [[ "$1" =~ $2 ]]; then
16 | return 0;
17 | fi
18 | return 1;
19 | }
20 |
21 | # ------------------------------------------
22 |
23 | function isTwoZeroOrGreater() {
24 | return $(compare "$1" ${TWO_ZERO})
25 | }
26 |
27 | function isTwoOneOrGreater() {
28 | return $(compare "$1" ${TWO_ONE})
29 | }
30 |
31 | function isTwoTwoOrGreater() {
32 | return $(compare "$1" ${TWO_TWO})
33 | }
34 |
35 | function isTwoThreeOrGreater() {
36 | compare "$1" ${TWO_THREE}
37 | }
38 |
39 | function isTwoFourOrGreater() {
40 | return $(compare "$1" ${TWO_FOUR})
41 | }
42 |
43 | function isTwoFiveOrGreater() {
44 | return $(compare "$1" ${TWO_FIVE})
45 | }
46 |
47 | function isTwoSixOrGreater() {
48 | return $(compare "$1" ${TWO_SIX})
49 | }
50 |
51 | function isTwoSevenOrGreater() {
52 | return $(compare "$1" ${TWO_SEVEN})
53 | }
54 |
--------------------------------------------------------------------------------
/bin/helper/xdebug-prepare:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | COMPOSE_DEV=./docker-compose.dev.yml
4 | COMPOSE_TEMPLATE=./var/template/docker-compose/custom.yml
5 | COMPOSE_CUSTOM=./docker-compose.custom.yml
6 |
7 | function getDockerIp() {
8 | DOCKER_IP=$(./bin/helper/docker-ip);
9 | echo $DOCKER_IP;
10 | }
11 |
12 | function copyCustomFileTemplate() {
13 | if [ -f "$COMPOSE_CUSTOM" ]; then
14 | exit 0;
15 | fi
16 |
17 | cp ${COMPOSE_TEMPLATE} ${COMPOSE_CUSTOM}
18 | }
19 |
20 | function replacePlaceholders() {
21 | sed -i -e 's/#extra_hosts:/extra_hosts:/g' $COMPOSE_CUSTOM
22 | sed -i -e "s/host.docker.internal:{{IP}}/host.docker.internal:$(getDockerIp)/g" $COMPOSE_CUSTOM
23 | sed -i -e 's/# - "host/ - "host/g' $COMPOSE_CUSTOM
24 | }
25 |
26 | copyCustomFileTemplate
27 | replacePlaceholders
28 |
--------------------------------------------------------------------------------
/bin/helper/xdebug-status:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | INI_DIR=/usr/local/etc/php/conf.d
4 | ACTIVE_FILE=${INI_DIR}/docker-php-ext-xdebug.ini
5 | CONFIG_FILE=${INI_DIR}/zzz-xdebug.ini
6 |
7 | function isXdebugEnabled() {
8 | RESULT=$(bin/php -m | grep "Xdebug")
9 |
10 | if [ -z "$RESULT" ]; then
11 | return 1;
12 | else
13 | return 0;
14 | fi
15 | }
16 |
17 |
18 | function restartContainers() {
19 | bin/restart php &> /dev/null;
20 | }
21 |
22 |
23 | function disableXdebug() {
24 | if ( ! isXdebugEnabled ); then
25 | echo "Xdebug is already disabled."
26 | exit 0;
27 | fi
28 |
29 | echo "Disabling Xdebug..."
30 | bin/cli sed -i -e 's/^zend_extension/\;zend_extension/g' ${ACTIVE_FILE}
31 | restartContainers
32 | echo "Xdebug has been disabled."
33 | }
34 |
35 |
36 | function enableXdebug() {
37 | if ( isXdebugEnabled ); then
38 | echo "Xdebug is already enabled."
39 | exit 0;
40 | fi
41 |
42 | echo "Enabling Xdebug..."
43 | bin/cli sed -i -e 's/^\;zend_extension/zend_extension/g' ${ACTIVE_FILE}
44 | restartContainers
45 | echo "Xdebug has been enabled."
46 | }
47 |
48 |
49 | function changeXdebugMode() {
50 | XDEBUG_MODE=$1
51 | echo "Setting Xdebug mode..."
52 | bin/cli sed -i -e "s/^xdebug.mode.*/xdebug.mode = ${XDEBUG_MODE}/g" ${CONFIG_FILE}
53 | restartContainers
54 | echo "Xdebug mode has been changed to ${XDEBUG_MODE}."
55 | }
56 |
57 |
58 | function changeRequestMode() {
59 | XDEBUG_REQUEST_MODE=$1
60 | echo "Setting Xdebug request mode..."
61 | bin/cli sed -i -e "s/^xdebug.start_with_request.*/xdebug.start_with_request = ${XDEBUG_REQUEST_MODE}/g" ${CONFIG_FILE}
62 | restartContainers
63 | echo "Xdebug request mode has been changed to ${XDEBUG_REQUEST_MODE}."
64 | }
65 |
66 |
67 | function toggleXdebug() {
68 | if ( isXdebugEnabled ); then
69 | disableXdebug
70 | else
71 | enableXdebug
72 | fi
73 | }
74 |
--------------------------------------------------------------------------------
/bin/install:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/create-envfile
4 | source ./bin/helper/version-compare
5 | source ./bin/helper/services-status
6 |
7 | if ( ! areServicesRunning ); then
8 | echo "Services are not running. Please run bin/up prior to installation.";
9 | exit 1;
10 | fi
11 |
12 | if [ "$1" ]; then
13 | bin/download "$1"
14 | fi
15 |
16 | if [ $? -eq 1 ]; then
17 | echo "Magento download has failed."
18 | exit 1
19 | fi
20 |
21 | # After downloading Magento
22 | # ----------------------------------------------------------------------------
23 |
24 | source ./.env
25 |
26 | #BASE_URL=${1:-magento2.test}
27 |
28 | #echo "Waiting for all the services to be up and running..."
29 | #sleep 5 #Ensure containers are started...
30 | bin/clinotty chmod u+x bin/magento
31 |
32 | # Let's make sure the database exists.
33 | echo "Checking if the database exists... If not, it will be created...";
34 | bin/exec db mysql -u root -p${MYSQL_ROOT_PASSWORD} -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE} CHARACTER SET utf8 COLLATE utf8_general_ci;" 2>/dev/null;
35 | bin/exec db mysql -u root -p${MYSQL_ROOT_PASSWORD} -e "GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO ${MYSQL_USER};" 2>/dev/null;
36 |
37 | if hash composer 2>/dev/null; then
38 | MAGENTO_PUBLIC_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.username\]' | cut -c40-)"
39 | MAGENTO_PRIVATE_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.password\]' | cut -c40-)"
40 | fi
41 |
42 | if [ -z "$MAGENTO_PUBLIC_KEY" ] || [ -z "$MAGENTO_PRIVATE_KEY" ]; then
43 | exec < /dev/tty
44 | echo
45 | echo
46 | echo " Authentication required (repo.magento.com, public_key and private_key):"
47 | read -p " Username: " MAGENTO_PUBLIC_KEY
48 | read -p " Password: " MAGENTO_PRIVATE_KEY
49 | echo
50 | if [ -n "$MAGENTO_PUBLIC_KEY" ] && [ -n "$MAGENTO_PRIVATE_KEY" ] && hash composer 2>/dev/null; then
51 | read -p " Add authentication information to host composer config? y/n: " ADD_AUTH
52 | echo
53 | if [[ $ADD_AUTH =~ ^[Yy]$ ]]; then
54 | composer global config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
55 | fi
56 | ADD_AUTH=''
57 | fi
58 | exec <&-
59 | fi
60 |
61 | if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ]; then
62 | bin/clinotty composer config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
63 | MAGENTO_PUBLIC_KEY=''
64 | MAGENTO_PRIVATE_KEY=''
65 | fi
66 |
67 | #bin/clinotty composer global require hirak/prestissimo
68 | #bin/clinotty composer update
69 |
70 | MAGENTO_URL=https://$BASE_URL/
71 |
72 | INSTALL_COMMAND="setup:install \
73 | --db-host="${MYSQL_HOST}" \
74 | --db-name="${MYSQL_DATABASE}" \
75 | --db-user="${MYSQL_USER}" \
76 | --db-password="${MYSQL_PASSWORD}" \
77 | --base-url=${MAGENTO_URL}/ \
78 | --backend-frontname="${ADMIN_URI}" \
79 | --admin-firstname="${ADMIN_FIRSTNAME}" \
80 | --admin-lastname="${ADMIN_LASTNAME}" \
81 | --admin-email="${ADMIN_EMAIL}" \
82 | --admin-user="${ADMIN_USER}" \
83 | --admin-password="${ADMIN_PASSWORD}" \
84 | --language=${LANGUAGE} \
85 | --currency=${CURRENCY} \
86 | --timezone=${TIMEZONE} \
87 | --amqp-host=${RABBITMQ_HOST} \
88 | --amqp-port=${RABBITMQ_PORT} \
89 | --amqp-user=${RABBITMQ_DEFAULT_USER} \
90 | --amqp-password=${RABBITMQ_DEFAULT_PASS} \
91 | --amqp-virtualhost=${RABBITMQ_DEFAULT_VHOST} \
92 | --cache-backend=${CACHE_BACKEND} \
93 | --cache-backend-redis-server=${CACHE_BACKEND_REDIS_SERVER} \
94 | --cache-backend-redis-db=${CACHE_BACKEND_REDIS_DB} \
95 | --page-cache=${PAGE_CACHE} \
96 | --page-cache-redis-server=${PAGE_CACHE_REDIS_SERVER} \
97 | --page-cache-redis-db=${PAGE_CACHE_REDIS_DB} \
98 | --session-save=${SESSION_SAVE} \
99 | --session-save-redis-host=${SESSION_SAVE_REDIS_HOST} \
100 | --session-save-redis-log-level=${SESSION_SAVE_REDIS_LOG_LEVEL} \
101 | --session-save-redis-db=${SESSION_SAVE_REDIS_DB} \
102 | --use-rewrites=1"
103 |
104 | if ( isTwoFourOrGreater ${MAGENTO_VERSION} ) || [[ ${MAGENTO_VERSION} == 'latest' ]]; then
105 | INSTALL_COMMAND="${INSTALL_COMMAND} \
106 | --search-engine=${SEARCH_ENGINE} \
107 | --elasticsearch-host=${ES_HOST}"
108 | fi
109 |
110 | #echo $INSTALL_COMMAND
111 | bin/magento ${INSTALL_COMMAND}
112 |
113 | if [ $? -eq 1 ]; then
114 | echo "Magento installation process has failed."
115 | echo "The install parameters: ${INSTALL_COMMAND}"
116 | exit 1
117 | fi
118 |
119 | # After installation process.
120 | # ----------------------------------------------------------------------------
121 |
122 | echo "Turning on developer mode.."
123 | bin/clinotty bin/magento deploy:mode:set developer
124 |
125 | if [ $? -eq 1 ]; then
126 | echo "Setting Magento to developer mode has failed."
127 | exit 1
128 | fi
129 |
130 | # After turning developer mode on.
131 | # ----------------------------------------------------------------------------
132 |
133 | bin/clinotty bin/magento indexer:reindex
134 |
135 | if [ $? -eq 1 ]; then
136 | echo "Magento reindexing has failed."
137 | exit 1
138 | fi
139 |
140 | # After reindex
141 | # ----------------------------------------------------------------------------
142 |
143 | echo "Your installation is ready. Please find below the details of it."
144 | echo "Magento Url: ${MAGENTO_URL}"
145 | echo "Admin Path: ${ADMIN_URI}"
146 | echo "Admin Username: ${ADMIN_USER}"
147 | echo "Admin Password: ${ADMIN_PASSWORD}"
148 |
149 | # echo "Forcing deploy of static content to speed up initial requests..."
150 | # bin/clinotty bin/magento setup:static-content:deploy -f
151 |
152 | # echo "Re-indexing with Elasticsearch..."
153 | # bin/clinotty bin/magento indexer:reindex
154 |
155 | # echo "Clearing the cache to apply updates..."
156 | # bin/clinotty bin/magento cache:flush
157 |
--------------------------------------------------------------------------------
/bin/logs:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | bin/docker-compose logs -f $1
4 |
--------------------------------------------------------------------------------
/bin/magento:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/php bin/magento "$@"
3 |
--------------------------------------------------------------------------------
/bin/magento-download:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # [ -z "$1" ] && echo "Please specify the version to download (ex. 2.0.0)" && exit
3 | source bin/create-envfile
4 | source ./var/env/config.env
5 |
6 | # Reference: https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/
7 | while getopts ":l" opt; do
8 | case ${opt} in
9 | l ) ls -1 $DOWNLOAD_DIR | sed -e 's/\.tar.gz$//'; exit;
10 | ;;
11 | esac
12 | done
13 | shift $((OPTIND -1))
14 |
15 | if [ ! -d "$DOWNLOAD_DIR" ]; then
16 | mkdir $DOWNLOAD_DIR
17 | fi
18 |
19 | if [ -z "$1" ]; then
20 | source ./.env
21 | else
22 | MAGENTO_VERSION="$1"
23 | fi
24 |
25 | # ----------------------------------------------------------------------------
26 |
27 | function repoExists() {
28 | HTTP_CODE=$(curl -ILs "$2" | grep "HTTP/1.1" | tail -1 | cut -d$' ' -f2)
29 | if [ "$HTTP_CODE" == "404" ]; then
30 | echo "The version $1 does not exist or is not available."
31 | exit 1
32 | fi
33 | }
34 |
35 | function downloadVersion() {
36 | repoExists $3 $1
37 | echo "Downloading Magento $3 version..."
38 | (cd $2 && curl -OLs $1)
39 | }
40 |
41 | # ----------------------------------------------------------------------------
42 |
43 | if [ -z "$MAGENTO_VERSION" ]; then
44 | MAGENTO_VERSION=latest
45 | echo "The latest version of Magento 2 will be used..."
46 | else
47 | echo "Using the version $MAGENTO_VERSION..."
48 | fi
49 |
50 | FILE_NAME=$MAGENTO_VERSION.tar.gz
51 | REPO=$REPOSITORY_URL/$FILE_NAME
52 | LOCAL_FILE=$DOWNLOAD_DIR/$FILE_NAME
53 |
54 | if [ ! -f $LOCAL_FILE ]; then
55 | downloadVersion $REPO $DOWNLOAD_DIR $MAGENTO_VERSION
56 | echo "Magento was downloaded."
57 | else
58 | echo "Magento $MAGENTO_VERSION version already exists locally."
59 | fi
60 |
--------------------------------------------------------------------------------
/bin/magento-extract:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # [ -z "$1" ] && echo "Please specify the version to download (ex. 2.0.0)" && exit
3 |
4 | source ./bin/create-envfile
5 | source ./var/env/config.env
6 |
7 |
8 | function isTargetDirEmpty() {
9 | if [ -d $1 ] && [ "$(ls -A $1)" ]; then
10 | echo "The $1 directory is not empty."
11 | exit 1
12 | fi
13 | }
14 |
15 |
16 | function sourceFileExists() {
17 | if [ ! -f $1 ]; then
18 | echo "Magento version $MAGENTO_VERSION was not downloaded."
19 | ANSWER=$(./bin/helper/question "Do you want to download it now")
20 | ### https://stackoverflow.com/questions/1885525/how-do-i-prompt-a-user-for-confirmation-in-bash-script
21 |
22 | if [ $ANSWER == "0" ]; then
23 | echo
24 | echo "Ok! Stopping the process."
25 | exit 1
26 | fi
27 |
28 | echo
29 | bin/magento-download $MAGENTO_VERSION
30 | fi
31 | }
32 |
33 |
34 | if [ -z "$1" ]; then
35 | source ./.env
36 | else
37 | MAGENTO_VERSION="$1"
38 | fi
39 |
40 | FILE_NAME=$MAGENTO_VERSION.tar.gz
41 | SOURCE_FILE=$DOWNLOAD_DIR/$FILE_NAME
42 |
43 | mkdir -p $EXTRACT_DIR
44 |
45 | isTargetDirEmpty $EXTRACT_DIR
46 | sourceFileExists $SOURCE_FILE
47 |
48 | echo "Extracting Magento $MAGENTO_VERSION version to $EXTRACT_DIR"
49 | tar xzf $SOURCE_FILE -o -C $EXTRACT_DIR --strip 1
50 |
--------------------------------------------------------------------------------
/bin/mkcert:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/exec nginx mkcert "$@"
3 |
--------------------------------------------------------------------------------
/bin/mkcert-ca-copy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CA_DIR_CONTAINER=/var/www/ssl/ca
4 | CA_DIR_HOST=./var/ssl/ca/
5 |
6 | mkdir -p ${CA_DIR_HOST}
7 | rm -rf ${CA_DIR_HOST}/*.pem
8 |
9 | bin/docker-copy nginx ${CA_DIR_CONTAINER}/rootCA.pem ${CA_DIR_HOST}
10 | # bin/docker-copy nginx ${CA_DIR_CONTAINER}/rootCA-key.pem ${CA_DIR_HOST}
11 |
--------------------------------------------------------------------------------
/bin/mkcert-ca-generate:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CA_DIR_CONTAINER=/var/www/ssl/ca
4 | CA_DIR_HOST=./var/ssl/ca/
5 |
6 | mkdir -p ${CA_DIR_HOST}
7 | rm -rf ${CA_DIR_HOST}/*.pem
8 |
9 | bin/exec -T -u root nginx mkcert -install
10 | bin/docker-copy nginx ${CA_DIR_CONTAINER}/rootCA.pem ${CA_DIR_HOST}
11 | # bin/docker-copy nginx ${CA_DIR_CONTAINER}/rootCA-key.pem ${CA_DIR_HOST}
12 |
13 | echo "System password requested to install certificate authority on host..."
14 |
15 | if [ "$(uname)" == "Darwin" ]; then
16 | # sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem
17 | rm ${CA_DIR_HOST}/rootCA.pem
18 | else
19 | sudo mv -f ${CA_DIR_HOST}/rootCA.pem /usr/local/share/ca-certificates/rootCA.pem
20 | sudo update-ca-certificates
21 | fi
22 |
--------------------------------------------------------------------------------
/bin/mkcert-generate:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./.env
4 |
5 | HOST=$1
6 |
7 | if [[ -z "$1" ]] && [[ -z "$BASE_URL" ]] ; then
8 | echo "Please specify a hostname like localhost, magento2.test, etc.";
9 | exit 1;
10 | elif [ -z "$1" ] ; then
11 | HOST=${BASE_URL}
12 | echo "Using the BASE URL declared in .env file: ${HOST}";
13 | fi
14 |
15 | CERT_DIR=/var/www/ssl/certificates
16 | CA_DIR=/var/www/ssl/ca
17 |
18 | FILE_PREFIX=${HOST}
19 | KEY_FILE=${CERT_DIR}/${FILE_PREFIX}-key.pem
20 | CERT_FILE=${CERT_DIR}/${FILE_PREFIX}.pem
21 |
22 | bin/exec nginx rm -rf ${KEY_FILE} ${CERT_FILE} ${CA_DIR}/*.pem
23 |
24 | bin/exec nginx mkdir -p ${CERT_DIR}
25 | bin/exec nginx mkdir -p ${CA_DIR}
26 | bin/mkcert -key-file ${KEY_FILE} -cert-file ${CERT_FILE} "${HOST}"
27 |
28 | bin/mkcert-ca-copy
29 |
--------------------------------------------------------------------------------
/bin/mkcert-generate-ca:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CA_DIR_CONTAINER=/var/www/ssl/ca
4 |
5 | bin/exec -T -u root nginx mkcert -install
6 |
7 | echo "System password requested to install certificate authority on host..."
8 |
9 | if [ "$(uname)" == "Darwin" ]; then
10 | # sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem
11 | rm ${CA_DIR_HOST}/rootCA.pem
12 | else
13 | sudo mv -f ${CA_DIR_HOST}/rootCA.pem /usr/local/share/ca-certificates/rootCA.pem
14 | sudo update-ca-certificates
15 | fi
16 |
--------------------------------------------------------------------------------
/bin/mysql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | source bin/create-envfile
3 | source ./.env
4 |
5 | COMMAND_BASE="mysql -h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -A ${MYSQL_DATABASE}"
6 |
7 | if [ -t 0 ]; then
8 | # Need tty to run mysql shell
9 | bin/exec db $COMMAND_BASE "$@"
10 | else
11 | # Read from stdin, ex: bin/mysql < dbdump.sql
12 | bin/exec -T db COMMAND_BASE "$@"
13 | fi
14 |
--------------------------------------------------------------------------------
/bin/mysqldump:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | source ./bin/create-envfile
3 | source ./.env
4 |
5 | TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
6 |
7 | FILENAME="${MYSQL_DATABASE}.${TIMESTAMP}.sql.gz"
8 | REMOTE_FILENAME="${MYSQL_DUMP_DIR}/${FILENAME}"
9 | BASE_COMMAND="/usr/bin/mysqldump -u root -p${MYSQL_ROOT_PASSWORD} ${MYSQL_DATABASE} | gzip -9 > ${REMOTE_FILENAME}"
10 |
11 | echo "Exporting database to ${REMOTE_FILENAME}..."
12 | bin/exec-root -T db /bin/bash -c "${BASE_COMMAND}"
13 | bin/exec-root chown 1000: ${REMOTE_FILENAME}
14 |
15 | if ! [[ "$1" == "aws" ]] || [[ -z ${AWS_S3_BUCKET} ]] ; then
16 | exit 0;
17 | fi
18 |
19 | LOCAL_FILENAME=./var/dumps/${FILENAME}
20 |
21 | echo "Copying the backup file to AWS S3..."
22 | aws s3 cp ${LOCAL_FILENAME} ${AWS_S3_PATH}/${FILENAME} --profile ${AWS_PROFILE}
23 |
24 | #echo "Copying from container to ${MYSQL_DUMP_DIR}"
25 | #docker cp $(bin/helper/container-id db):${REMOTE_FILENAME} ${MYSQL_DUMP_DIR}
26 | #bin/exec-root -T db rm -rf ${MYSQL_DUMP_DIR}/*
27 |
--------------------------------------------------------------------------------
/bin/n98:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | bin/exec php n98 "$@"
4 |
5 |
--------------------------------------------------------------------------------
/bin/nginx:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/exec nginx nginx "$@"
3 |
--------------------------------------------------------------------------------
/bin/nginx-reload:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Restart nginx to apply the updates
4 | echo "Checking if nginx configuration is valid..."
5 | if ( ! bin/nginx -t $1 &> /dev/null ); then
6 | echo "Nginx configuration is not valid.";
7 | exit 1;
8 | fi
9 |
10 | echo "Reloading nginx configuration..."
11 | bin/nginx -s reload $1 &> /dev/null
12 |
--------------------------------------------------------------------------------
/bin/node:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/cli node "$@"
3 |
--------------------------------------------------------------------------------
/bin/npm:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/cli npm "$@"
3 |
--------------------------------------------------------------------------------
/bin/php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/services-status
4 |
5 | if ( ! areServicesRunning ); then
6 | echo "Services are not running.";
7 | exit 1;
8 | fi
9 |
10 |
11 | if [ -z "$1" ]; then
12 | bin/cli php -v
13 | exit 0;
14 | fi
15 |
16 | bin/cli php "$@"
17 |
--------------------------------------------------------------------------------
/bin/phpunit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/exec php vendor/bin/phpunit -c /var/www/html/dev/tests/unit/phpunit.xml.dist "$@"
3 |
--------------------------------------------------------------------------------
/bin/pwa-studio:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | if [ ! -d pwa-studio ]; then
3 | echo "PWA studio must first be installed by running bin/setup-pwa-studio"
4 | exit
5 | fi
6 |
7 | cd pwa-studio
8 | NODE_TLS_REJECT_UNAUTHORIZED=0 yarn run watch:all
9 |
--------------------------------------------------------------------------------
/bin/redis:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/docker-compose exec redis "$@"
3 |
--------------------------------------------------------------------------------
/bin/remove:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/services-status
4 |
5 | if ( ! servicesExist ); then
6 | echo "Services are already down.";
7 | exit 1;
8 | fi
9 |
10 | function help() {
11 | printf "bin/$(basename "$0") [-h] [-av]
12 |
13 | where:
14 | -h Show this help text
15 | -a Removes all (containers and volumes)
16 | -v Removes volumes
17 | ";
18 | }
19 |
20 | function removeVolumes() {
21 | echo "Removing volumes...";
22 | current_folder=${PWD##*/}
23 | volume_prefix=`echo $current_folder | awk '{print tolower($0)}' | sed 's/\.//g'`
24 | docker volume rm ${volume_prefix}_appdata "$@"
25 | docker volume rm ${volume_prefix}_dbdata "$@"
26 | docker volume rm ${volume_prefix}_rabbitmqdata "$@"
27 | docker volume rm ${volume_prefix}_sockdata "$@"
28 | docker volume rm ${volume_prefix}_ssldata "$@"
29 | docker volume rm ${volume_prefix}_esdata "$@"
30 | echo "Done!";
31 | }
32 |
33 | function removeContainers() {
34 | echo "Removing containers...";
35 | bin/docker-compose rm --stop -f "$@";
36 | echo "Done!";
37 | }
38 |
39 | function removeNetworks() {
40 | echo "Removing networks...";
41 | docker network rm magento_dockerlab
42 | echo "Done!";
43 | }
44 |
45 | # By default it removes only the containers.
46 | if [ -z "$1" ]; then
47 | removeContainers;
48 | removeNetworks;
49 | exit 0;
50 | fi
51 |
52 | # Reference: https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/
53 | while getopts ":av" opt; do
54 | case ${opt} in
55 | a )
56 | removeContainers;
57 | removeVolumes;
58 | removeNetworks;
59 | exit 0;
60 | ;;
61 | v )
62 | removeVolumes;
63 | exit 0;
64 | ;;
65 | h )
66 | help;
67 | exit 0;
68 | ;;
69 | \? )
70 | help;
71 | exit 0;
72 | ;;
73 | : )
74 | echo "Invalid";
75 | exit 1;
76 | ;;
77 | * )
78 | echo "Default option."
79 | exit 1;
80 | ;;
81 | esac
82 | done
83 | shift $((OPTIND -1))
84 |
--------------------------------------------------------------------------------
/bin/restart:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/docker-compose restart $1
3 |
4 |
--------------------------------------------------------------------------------
/bin/revive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | echo "Killing containers."
3 | bin/down $1 &> /dev/null;
4 | echo "Creating containers."
5 | bin/up $1 &> /dev/null;
6 | echo "Done!"
7 |
--------------------------------------------------------------------------------
/bin/root:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
3 | bin/docker-compose exec -u root php "$@"
4 |
--------------------------------------------------------------------------------
/bin/rootnotty:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
3 | bin/docker-compose exec -u root -T php "$@"
4 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/create-envfile
4 |
5 | VERSION=$1
6 | VHOST=$2
7 |
8 | # Downloading and extracting Magento
9 | # ----------------------------------------------------------------------------
10 |
11 | bin/magento-extract ${VERSION}
12 | if [ $? -eq 1 ]; then
13 | echo "Something went wrong when extracting Magento application."
14 | exit 1
15 | fi
16 |
17 | # After downloading and extracting let's replace the infos on environment.
18 | # ----------------------------------------------------------------------------
19 |
20 | if [ ! -z "${VERSION}" ]; then
21 | ./bin/env-set MAGENTO_VERSION ${VERSION}
22 | fi
23 |
24 | if [ ! -z "${VHOST}" ]; then
25 | ./bin/env-set BASE_URL ${VHOST}
26 | fi
27 |
28 | # ----------------------------------------------------------------------------
29 |
30 | # Start the services
31 | bin/up
32 | if [ $? -eq 1 ]; then
33 | echo "Something went wrong when trying to start the services."
34 | exit 1
35 | fi
36 |
37 | # Setup virtual host
38 | # ----------------------------------------------------------------------------
39 |
40 | bin/setup-vhost
41 | if [ $? -eq 1 ]; then
42 | echo "Something went wrong when trying to setup virtual host."
43 | exit 1
44 | fi
45 |
46 | # Copy to container
47 | # ----------------------------------------------------------------------------
48 |
49 | bin/copytocontainer --all
50 | if [ $? -eq 1 ]; then
51 | echo "Something went wrong when trying to copy the files to container."
52 | exit 1
53 | fi
54 |
55 | # Make installation
56 | # ----------------------------------------------------------------------------
57 |
58 | bin/install
59 | if [ $? -eq 1 ]; then
60 | echo "Something went wrong with the installation process."
61 | exit 1
62 | fi
63 |
64 | echo "Enjoy your new Magento installation!"
65 |
--------------------------------------------------------------------------------
/bin/setup-grunt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | DEFAULT_THEME_ID="select value from core_config_data where path = 'design/theme/theme_id'"
3 | THEME_PATH="select theme_path from theme where theme_id in ($DEFAULT_THEME_ID);"
4 | VENDOR_THEME=`bin/n98-magerun2 db:query "$THEME_PATH" | sed -n 2p | cut -d$'\r' -f1`
5 | THEME=`echo $VENDOR_THEME | cut -d'/' -f2`
6 |
7 | # Generate local-theme.js for custom theme
8 | read -d '' GEN_THEME_JS << EOM
9 | var fs = require('fs');
10 | var util = require('util');
11 | var theme = require('./dev/tools/grunt/configs/themes');
12 |
13 | theme['$THEME'] = {
14 | area: 'frontend',
15 | name: '$VENDOR_THEME',
16 | locale: 'en_US',
17 | files: [
18 | 'css/styles-m',
19 | 'css/styles-l'
20 | ],
21 | dsl: 'less'
22 | };
23 | fs.writeFileSync('./dev/tools/grunt/configs/local-themes.js', '"use strict"; module.exports = ' + util.inspect(theme), 'utf-8');
24 | EOM
25 |
26 | if [ -z "$VENDOR_THEME" ] || [ -z "$THEME" ]; then
27 | echo "Using Magento/luma theme for grunt config"
28 | THEME=luma
29 | bin/clinotty cp ./dev/tools/grunt/configs/themes.js ./dev/tools/grunt/configs/local-themes.js
30 | else
31 | echo "Using $VENDOR_THEME theme for grunt config"
32 | bin/node -e "$GEN_THEME_JS"
33 | fi
34 |
35 | bin/clinotty cp package.json.sample package.json
36 | bin/clinotty cp Gruntfile.js.sample Gruntfile.js
37 | bin/clinotty cp grunt-config.json.sample grunt-config.json
38 | bin/npm install ajv@^5.0.0 --save
39 | bin/npm install
40 | bin/magento cache:clean
41 | bin/grunt clean
42 | bin/grunt exec:$THEME
43 | bin/grunt less:$THEME
44 |
--------------------------------------------------------------------------------
/bin/setup-pmm:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Refer to https://www.percona.com/software/pmm/quickstart#
4 |
5 | source ./.env
6 |
7 | bin/exec pmm pmm-admin config --server-insecure-tls --server-url=https://admin:admin@localhost
8 |
9 | QUERY="CREATE USER 'pmm'@'%' IDENTIFIED BY 'pass' WITH MAX_USER_CONNECTIONS 10; \
10 | GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'%'; \
11 | FLUSH PRIVILEGES;"
12 |
13 | bin/exec -T db mysql -h${MYSQL_HOST} -uroot -p${MYSQL_ROOT_PASSWORD} <<< "${QUERY}"
14 | bin/exec pmm pmm-admin add mysql --host=${MYSQL_HOST} --username=pmm --password=pass --query-source=perfschema magento_database
15 |
--------------------------------------------------------------------------------
/bin/setup-pwa-studio:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | echo "Install NodeJS and Yarn on host machine, otherwise setup will fail"
3 |
4 | BASE_URL=${1:-master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud}
5 | git clone https://github.com/magento/pwa-studio.git
6 | cd pwa-studio
7 | yarn install
8 | yarn buildpack create-custom-origin packages/venia-concept
9 | MAGENTO_BACKEND_URL="https://$BASE_URL/" yarn buildpack create-env-file packages/venia-concept
10 |
--------------------------------------------------------------------------------
/bin/setup-ssl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | [ -z "$1" ] && echo "Please specify a domain (ex. mydomain.test)" && exit
3 |
4 | # Generate certificate authority if not already setup
5 | if ! docker-compose exec -T -u root nginx cat /root/.local/share/mkcert/rootCA.pem | grep -q 'BEGIN CERTIFICATE'; then
6 | bin/setup-ssl-ca
7 | fi
8 |
9 | # Generate the certificate for the specified domain
10 | docker-compose exec -T -u root nginx mkcert -key-file nginx.key -cert-file nginx.crt "$@"
11 | echo "Moving key and cert to /etc/nginx/certs/..."
12 | docker-compose exec -T -u root nginx chown app:app nginx.key nginx.crt
13 | docker-compose exec -T -u root nginx mv nginx.key nginx.crt /etc/nginx/certs/
14 |
15 | # Restart nginx to apply the updates
16 | echo "Restarting containers to apply updates..."
17 | bin/restart
18 |
--------------------------------------------------------------------------------
/bin/setup-ssl-ca:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | docker-compose exec -T -u root nginx mkcert -install
3 | docker cp $(docker-compose ps -q nginx|awk '{print $1}'):/root/.local/share/mkcert/rootCA.pem .
4 | echo "System password requested to install certificate authority on host..."
5 |
6 | if [ "$(uname)" == "Darwin" ]; then
7 | sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem
8 | rm rootCA.pem
9 | else
10 | sudo mv rootCA.pem /usr/local/share/ca-certificates/rootCA.pem
11 | sudo update-ca-certificates
12 | fi
13 |
--------------------------------------------------------------------------------
/bin/setup-vhost:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./.env
4 | source ./bin/helper/services-status
5 |
6 | if ( ! areServicesRunning ); then
7 | echo "Services are not running.";
8 | exit 1;
9 | fi
10 |
11 | if [ -z "$1" ]; then
12 | HOST="${BASE_URL}"
13 | else
14 | HOST="$1"
15 | fi
16 |
17 | HASH="fastcgi_$(./bin/helper/random)"
18 |
19 | [ -z "${HOST}" ] && echo "There's no BASE_URL specified. Please check the file .env." && exit;
20 |
21 | TEMPLATE_DIR=./var/template/nginx
22 |
23 | TEMPLATE_UPSTREAM=${TEMPLATE_DIR}/upstream.conf
24 | TEMPLATE_NO_SSL=${TEMPLATE_DIR}/magento2.conf
25 | TEMPLATE_SSL=${TEMPLATE_DIR}/magento2-ssl.conf
26 |
27 | DESTINY_DIR=config/nginx/conf.d
28 | DESTINY_UPSTREAM_DIR=${DESTINY_DIR}/"$HOST"
29 | DESTINY_UPSTREAM_FILE=${DESTINY_UPSTREAM_DIR}.conf
30 |
31 | if [ -f ${DESTINY_FILE} ]; then
32 | rm -rf ${DESTINY_FILE}
33 | rm -rf ${DESTINY_DIR}/${HOST}
34 | fi
35 |
36 | echo "Generating SSL certificates..."
37 | bin/mkcert-generate ${HOST} $1 &> /dev/null
38 |
39 | echo "Setting up the vhost in nginx..."
40 | cp ${TEMPLATE_UPSTREAM} ${DESTINY_UPSTREAM_FILE}
41 | sed -i -e "s/{{host}}/${HOST}/g" ${DESTINY_UPSTREAM_FILE}
42 | sed -i -e "s/{{upstream}}/${HASH}/g" ${DESTINY_UPSTREAM_FILE}
43 |
44 | mkdir -p ${DESTINY_UPSTREAM_DIR}
45 |
46 | # Copying and replacing the placeholders from vhost file (NO SSL).
47 | FILE=${DESTINY_UPSTREAM_DIR}/default.conf
48 | cp ${TEMPLATE_NO_SSL} ${FILE}
49 | sed -i -e "s/{{host}}/${HOST}/g" ${FILE}
50 | sed -i -e "s/{{upstream}}/${HASH}/g" ${FILE}
51 |
52 | # Copying and replacing the placeholders from vhost file (SSL).
53 | FILE=${DESTINY_UPSTREAM_DIR}/ssl.conf
54 | cp ${TEMPLATE_SSL} ${FILE}
55 | sed -i -e "s/{{host}}/${HOST}/g" ${FILE}
56 | sed -i -e "s/{{upstream}}/${HASH}/g" ${FILE}
57 |
58 | bin/nginx-reload
59 |
60 | echo "Done!"
61 |
--------------------------------------------------------------------------------
/bin/ssh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if [ -z "$1" ]; then
4 | echo "Please specify one of the containers below:"
5 | bin/status --services
6 | exit 1;
7 | fi
8 |
9 | bin/docker-compose exec "$@" bash
10 |
--------------------------------------------------------------------------------
/bin/start:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source bin/create-envfile
4 | source ./var/env/config.env
5 | source ./bin/helper/services-status
6 |
7 | if ( areServicesRunning -eq 0 ); then
8 | echo "The services are already running."
9 | exit
10 | fi
11 |
12 | if [ ! -d "$EXTRACT_DIR" ]; then
13 | mkdir -p $EXTRACT_DIR
14 | fi
15 |
16 | ./bin/helper/xdebug-prepare
17 | bin/docker-compose up -d --remove-orphans $1
18 |
19 | ## Blackfire support
20 | # ------------------
21 | ## First register the blackfire agent with:
22 | #bin/root blackfire-agent --register --server-id={YOUR_SERVER_ID} --server-token={YOUR_SERVER_TOKEN}
23 | ## Then uncomment the below line (and leave uncommented) to start the agent automatically with bin/start:
24 | #bin/root /etc/init.d/blackfire-agent start
25 |
--------------------------------------------------------------------------------
/bin/status:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | bin/docker-compose ps "$@"
3 |
--------------------------------------------------------------------------------
/bin/stop:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/services-status
4 |
5 | if ( areServicesStopped ); then
6 | echo "Services are already stopped.";
7 | exit 1;
8 | fi
9 |
10 | bin/docker-compose stop $1
11 |
--------------------------------------------------------------------------------
/bin/up:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | echo "Getting the environment up. Please wait..."
3 |
4 | # bin/start $1 &> /dev/null
5 | bin/start $1
6 |
7 | if [ $? -eq 0 ]; then
8 | echo "Done! Have great ideas!"
9 | else
10 | echo "Something went wrong on trying to start the services."
11 | exit 1
12 | fi
13 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | mkdir -p tmpupdate && cd $_
3 | curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/template | bash
4 | rm -rf .git
5 | rsync -av ./ ../
6 | cd ..
7 | rm -rf tmpupdate
8 | echo "docker-magento has been updated, run bin/restart to apply the updates"
9 |
--------------------------------------------------------------------------------
/bin/xdebug:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/xdebug-status
4 |
5 | function help() {
6 | printf "bin/$(basename "$0") [-h] [-des]
7 |
8 | where:
9 | -h Show this help text
10 | -d Disable Xdebug
11 | -e Enable Xdebug
12 | -s Show Xdebug status
13 | ";
14 | }
15 |
16 | # Reference: https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/
17 | while getopts ":desh" opt; do
18 | case ${opt} in
19 | d )
20 | disableXdebug
21 | exit 0;
22 | ;;
23 | e )
24 | enableXdebug
25 | exit 0;
26 | ;;
27 | s )
28 | if ( isXdebugEnabled ); then
29 | echo "Xdebug is ENABLED."
30 | else
31 | echo "Xdebug is DISABLED."
32 | fi
33 | exit 0;
34 | ;;
35 |
36 | h )
37 | help;
38 | exit 0;
39 | ;;
40 | \? )
41 | #help;
42 | echo "Invalid option.";
43 | exit 0;
44 | ;;
45 | : )
46 | echo "Invalid option.";
47 | exit 1;
48 | ;;
49 | * )
50 | echo "Default option."
51 | exit 1;
52 | ;;
53 | esac
54 | done
55 | shift $((OPTIND -1))
56 |
57 | toggleXdebug
58 |
--------------------------------------------------------------------------------
/bin/xdebug-mode:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/xdebug-status
4 |
5 | function help() {
6 | printf "bin/$(basename "$0") [-h] [-des]
7 |
8 | where:
9 | -h Show this help text
10 | -d Disbale Xdebug
11 | -e Enable Xdebug
12 | -s Show Xdebug status
13 | ";
14 | }
15 |
16 | # Reference: https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/
17 | while getopts ":desh" opt; do
18 | case ${opt} in
19 | d )
20 | disableXdebug
21 | exit 0;
22 | ;;
23 | e )
24 | enableXdebug
25 | exit 0;
26 | ;;
27 | s )
28 | if ( isXdebugEnabled ); then
29 | echo "Xdebug is ENABLED."
30 | else
31 | echo "Xdebug is DISABLED."
32 | fi
33 | exit 0;
34 | ;;
35 |
36 | h )
37 | help;
38 | exit 0;
39 | ;;
40 | \? )
41 | #help;
42 | echo "Invalid option.";
43 | exit 0;
44 | ;;
45 | : )
46 | echo "Invalid option.";
47 | exit 1;
48 | ;;
49 | * )
50 | echo "Default option."
51 | exit 1;
52 | ;;
53 | esac
54 | done
55 | shift $((OPTIND -1))
56 |
57 | changeXdebugMode $1
58 |
--------------------------------------------------------------------------------
/bin/xdebug-request-mode:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source ./bin/helper/xdebug-status
4 |
5 | function help() {
6 | printf "bin/$(basename "$0") [-h] [-yt]
7 |
8 | where:
9 | -h Show this help text
10 | -y Set mode to yes
11 | -t Set mode to "trigger"
12 | ";
13 | }
14 |
15 | if [ -z "$1" ]; then
16 | echo "Please specify an option."
17 | help
18 | exit 1;
19 | fi
20 |
21 | # Reference: https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/
22 | while getopts ":hyt" opt; do
23 | case ${opt} in
24 | y )
25 | changeRequestMode yes
26 | exit 0;
27 | ;;
28 | t )
29 | changeRequestMode trigger
30 | exit 0;
31 | ;;
32 |
33 | h )
34 | help;
35 | exit 0;
36 | ;;
37 | \? )
38 | #help;
39 | echo "Invalid option.";
40 | exit 0;
41 | ;;
42 | : )
43 | echo "Invalid option.";
44 | exit 1;
45 | ;;
46 | * )
47 | echo "Default option."
48 | exit 1;
49 | ;;
50 | esac
51 | done
52 | shift $((OPTIND -1))
53 |
54 | changeRequestMode $1
55 |
--------------------------------------------------------------------------------
/config/apache/conf/vhosts/magento2.conf:
--------------------------------------------------------------------------------
1 | ## HTTP ------------------------------------------------------------------------
2 |
3 |
4 | ServerName magento2.test
5 | ServerAlias magento.test
6 |
7 | SetEnv MAGE_RUN_CODE "base"
8 | SetEnv MAGE_RUN_TYPE "website"
9 |
10 | DocumentRoot "/var/www/html/pub"
11 |
12 |
13 | AllowOverride All
14 | Order Allow,Deny
15 | Allow from all
16 |
17 |
18 | DirectoryIndex index.php index.html
19 | ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/html/pub/$1
20 |
21 | ErrorLog "logs/magento2.test-error_log"
22 | CustomLog "logs/magento2.test-access_log" common
23 |
24 |
--------------------------------------------------------------------------------
/config/apache/conf/vhosts/magento2.ssl.conf.example:
--------------------------------------------------------------------------------
1 | ## HTTPS -----------------------------------------------------------------------
2 |
3 | Listen 443
4 |
5 | SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES
6 | SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES
7 |
8 | SSLHonorCipherOrder on
9 |
10 | SSLProtocol all -SSLv3
11 | SSLProxyProtocol all -SSLv3
12 |
13 | SSLPassPhraseDialog builtin
14 |
15 | SSLSessionCache "shmcb:/usr/local/apache2/logs/ssl_scache(512000)"
16 | SSLSessionCacheTimeout 300
17 |
18 |
19 | ServerName magento2.test
20 | ServerAlias magento.test
21 |
22 | SetEnv MAGE_RUN_CODE "base"
23 | SetEnv MAGE_RUN_TYPE "website"
24 |
25 | DocumentRoot "/var/www/html/pub"
26 |
27 |
28 | AllowOverride All
29 | Order Allow,Deny
30 | Allow from all
31 |
32 |
33 | DirectoryIndex index.php index.html
34 | ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/html/pub/$1
35 |
36 | SSLEngine on
37 | SSLCertificateFile "/var/www/ssl/certificates/magento2.test.pem"
38 | SSLCertificateKeyFile "/var/www/ssl/certificates/magento2.test-key.pem"
39 |
40 | ErrorLog "logs/magento2.test-error_log"
41 | CustomLog "logs/magento2.test-access_log" common
42 |
43 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/.gitignore:
--------------------------------------------------------------------------------
1 | /*
2 | !/000_upstream.conf
3 | !/000_xdefault.conf
4 | !/include
5 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/000_upstream.conf:
--------------------------------------------------------------------------------
1 | # default Docker DNS server
2 | resolver 127.0.0.11;
3 |
4 | # Select upstream backend to use based on presense of Xdebug cookies and Blackfire headers
5 | map "$cookie_XDEBUG_SESSION$cookie_XDEBUG_PROFILE$cookie_XDEBUG_TRACE" $fastcgi_backend {
6 | # Nothing for debug means its a pure request
7 | "" php:9000;
8 |
9 | # In all other cases, a debug cookie will be present; use debug container
10 | default php-debug:9000;
11 | }
12 |
13 | #upstream fastcgi_magento {
14 | # server php:9000;
15 | #}
16 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/000_xdefault.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 8080;
3 | listen [::]:8080;
4 | server_name localhost;
5 |
6 | #charset koi8-r;
7 | #access_log /var/log/nginx/host.access.log main;
8 |
9 | location / {
10 | root /usr/share/nginx/html;
11 | index index.html index.htm;
12 | }
13 |
14 | location ~ ^/(status|ping)$ {
15 | allow 127.0.0.1;
16 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
17 | fastcgi_index index.php;
18 | include fastcgi_params;
19 | fastcgi_pass $fastcgi_backend;
20 | }
21 |
22 | #error_page 404 /404.html;
23 |
24 | # redirect server error pages to the static page /50x.html
25 | #
26 | error_page 500 502 503 504 /50x.html;
27 | location = /50x.html {
28 | root /usr/share/nginx/html;
29 | }
30 |
31 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80
32 | #
33 | #location ~ \.php$ {
34 | # proxy_pass http://127.0.0.1;
35 | #}
36 |
37 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
38 | #
39 | #location ~ \.php$ {
40 | # root html;
41 | # fastcgi_pass 127.0.0.1:9000;
42 | # fastcgi_index index.php;
43 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
44 | # include fastcgi_params;
45 | #}
46 |
47 | # deny access to .htaccess files, if Apache's document root
48 | # concurs with nginx's one
49 | #
50 | #location ~ /\.ht {
51 | # deny all;
52 | #}
53 | }
54 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/base.conf:
--------------------------------------------------------------------------------
1 | proxy_buffer_size 128k;
2 | proxy_buffers 4 256k;
3 | proxy_busy_buffers_size 256k;
4 |
5 | root $MAGE_ROOT;
6 |
7 | index index.php;
8 | autoindex off;
9 | charset UTF-8;
10 | error_page 404 403 = /errors/404.php;
11 | #add_header "X-UA-Compatible" "IE=Edge";
12 |
13 | # Deny access to sensitive files
14 | location /.user.ini {
15 | deny all;
16 | }
17 |
18 | # PHP entry point for setup application
19 | location ~* ^/setup($|/) {
20 | include conf.d/include/magento1/location/setup.conf;
21 | }
22 |
23 | # PHP entry point for update application
24 | location ~* ^/update($|/) {
25 | include conf.d/include/magento1/location/update.conf;
26 | }
27 |
28 | location / {
29 | try_files $uri $uri/ /index.php$is_args$args;
30 | }
31 |
32 | location /pub/ {
33 | include conf.d/include/magento1/location/pub.conf;
34 | }
35 |
36 | location /static/ {
37 | include conf.d/include/magento1/location/static.conf;
38 | }
39 |
40 | location /media/ {
41 | include conf.d/include/magento1/location/media.conf;
42 | }
43 |
44 | location /media/customer/ {
45 | deny all;
46 | }
47 |
48 | location /media/downloadable/ {
49 | deny all;
50 | }
51 |
52 | location /media/import/ {
53 | deny all;
54 | }
55 |
56 | location /media/custom_options/ {
57 | deny all;
58 | }
59 |
60 | location /errors/ {
61 | include conf.d/include/magento1/location/errors.conf;
62 | }
63 |
64 | # PHP entry point for main application
65 | location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check|info)\.php$ {
66 | include conf.d/include/magento1/location/application.conf;
67 | }
68 |
69 | include conf.d/include/magento1/gzip.conf;
70 |
71 | # Banned locations (only reached if the earlier PHP entry point regexes don't match)
72 | location ~* (\.php$|\.phtml$|\.htaccess$|\.git) {
73 | deny all;
74 | }
75 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/gzip.conf:
--------------------------------------------------------------------------------
1 | gzip on;
2 | gzip_disable "msie6";
3 |
4 | gzip_comp_level 6;
5 | gzip_min_length 1100;
6 | gzip_buffers 16 8k;
7 | gzip_proxied any;
8 | gzip_types
9 | text/plain
10 | text/css
11 | text/js
12 | text/xml
13 | text/javascript
14 | application/javascript
15 | application/x-javascript
16 | application/json
17 | application/xml
18 | application/xml+rss
19 | image/svg+xml;
20 | gzip_vary on;
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/location/application.conf:
--------------------------------------------------------------------------------
1 | try_files $uri =404;
2 | fastcgi_pass $fastcgi_backend;
3 | fastcgi_buffers 16 16k;
4 | fastcgi_buffer_size 32k;
5 |
6 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
7 | fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
8 | fastcgi_read_timeout 600s;
9 | fastcgi_connect_timeout 600s;
10 |
11 | fastcgi_index index.php;
12 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
13 | include fastcgi_params;
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/location/errors.conf:
--------------------------------------------------------------------------------
1 | location ~* \.xml$ {
2 | deny all;
3 | }
4 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/location/media.conf:
--------------------------------------------------------------------------------
1 | try_files $uri $uri/ /get.php$is_args$args;
2 |
3 | location ~ ^/media/theme_customization/.*\.xml {
4 | deny all;
5 | }
6 |
7 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
8 | add_header Cache-Control "public";
9 | add_header X-Frame-Options "SAMEORIGIN";
10 | expires +1y;
11 | try_files $uri $uri/ /get.php$is_args$args;
12 | }
13 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
14 | add_header Cache-Control "no-store";
15 | add_header X-Frame-Options "SAMEORIGIN";
16 | expires off;
17 | try_files $uri $uri/ /get.php$is_args$args;
18 | }
19 | add_header X-Frame-Options "SAMEORIGIN";
20 |
21 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/location/pub.conf:
--------------------------------------------------------------------------------
1 | location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) {
2 | deny all;
3 | }
4 | alias $MAGE_ROOT/pub/;
5 | add_header X-Frame-Options "SAMEORIGIN";
6 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/location/setup.conf:
--------------------------------------------------------------------------------
1 | root $MAGE_ROOT;
2 | location ~ ^/setup/index.php {
3 | fastcgi_pass $fastcgi_backend;
4 |
5 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
6 | fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600";
7 | fastcgi_read_timeout 600s;
8 | fastcgi_connect_timeout 600s;
9 |
10 | fastcgi_index index.php;
11 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
12 | include fastcgi_params;
13 | }
14 |
15 | location ~ ^/setup/(?!pub/). {
16 | deny all;
17 | }
18 |
19 | location ~ ^/setup/pub/ {
20 | add_header X-Frame-Options "SAMEORIGIN";
21 | }
22 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/location/static.conf:
--------------------------------------------------------------------------------
1 | # Uncomment the following line in production mode
2 | # expires max;
3 |
4 | # Remove signature of the static files that is used to overcome the browser cache
5 | location ~ ^/static/version {
6 | rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
7 | }
8 |
9 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ {
10 | add_header Cache-Control "public";
11 | add_header X-Frame-Options "SAMEORIGIN";
12 | expires +1y;
13 |
14 | if (!-f $request_filename) {
15 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
16 | }
17 | }
18 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
19 | add_header Cache-Control "no-store";
20 | add_header X-Frame-Options "SAMEORIGIN";
21 | expires off;
22 |
23 | if (!-f $request_filename) {
24 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
25 | }
26 | }
27 | if (!-f $request_filename) {
28 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
29 | }
30 | add_header X-Frame-Options "SAMEORIGIN";
31 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento1/location/update.conf:
--------------------------------------------------------------------------------
1 | root $MAGE_ROOT;
2 |
3 | location ~ ^/update/index.php {
4 | fastcgi_split_path_info ^(/update/index.php)(/.+)$;
5 | fastcgi_pass $fastcgi_backend;
6 | fastcgi_index index.php;
7 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
8 | fastcgi_param PATH_INFO $fastcgi_path_info;
9 | include fastcgi_params;
10 | }
11 |
12 | # Deny everything but index.php
13 | location ~ ^/update/(?!pub/). {
14 | deny all;
15 | }
16 |
17 | location ~ ^/update/pub/ {
18 | add_header X-Frame-Options "SAMEORIGIN";
19 | }
20 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/base.conf:
--------------------------------------------------------------------------------
1 | proxy_buffer_size 128k;
2 | proxy_buffers 4 256k;
3 | proxy_busy_buffers_size 256k;
4 |
5 | root $MAGE_ROOT/pub;
6 |
7 | index index.php;
8 | autoindex off;
9 | charset UTF-8;
10 | error_page 404 403 = /errors/404.php;
11 | #add_header "X-UA-Compatible" "IE=Edge";
12 |
13 | # Deny access to sensitive files
14 | location /.user.ini {
15 | deny all;
16 | }
17 |
18 | # PHP entry point for setup application
19 | location ~* ^/setup($|/) {
20 | include conf.d/include/magento2/location/setup.conf;
21 | }
22 |
23 | # PHP entry point for update application
24 | location ~* ^/update($|/) {
25 | include conf.d/include/magento2/location/update.conf;
26 | }
27 |
28 | location / {
29 | try_files $uri $uri/ /index.php$is_args$args;
30 | }
31 |
32 | location /pub/ {
33 | include conf.d/include/magento2/location/pub.conf;
34 | }
35 |
36 | location /static/ {
37 | include conf.d/include/magento2/location/static.conf;
38 | }
39 |
40 | location /media/ {
41 | include conf.d/include/magento2/location/media.conf;
42 | }
43 |
44 | location /media/customer/ {
45 | deny all;
46 | }
47 |
48 | location /media/downloadable/ {
49 | deny all;
50 | }
51 |
52 | location /media/import/ {
53 | deny all;
54 | }
55 |
56 | location /media/custom_options/ {
57 | deny all;
58 | }
59 |
60 | location /errors/ {
61 | include conf.d/include/magento2/location/errors.conf;
62 | }
63 |
64 | # PHP entry point for main application
65 | location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check|info)\.php$ {
66 | include conf.d/include/magento2/location/application.conf;
67 | }
68 |
69 | include conf.d/include/magento2/gzip.conf;
70 |
71 | # Banned locations (only reached if the earlier PHP entry point regexes don't match)
72 | location ~* (\.php$|\.phtml$|\.htaccess$|\.git) {
73 | deny all;
74 | }
75 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/gzip.conf:
--------------------------------------------------------------------------------
1 | gzip on;
2 | gzip_disable "msie6";
3 |
4 | gzip_comp_level 6;
5 | gzip_min_length 1100;
6 | gzip_buffers 16 8k;
7 | gzip_proxied any;
8 | gzip_types
9 | text/plain
10 | text/css
11 | text/js
12 | text/xml
13 | text/javascript
14 | application/javascript
15 | application/x-javascript
16 | application/json
17 | application/xml
18 | application/xml+rss
19 | image/svg+xml;
20 | gzip_vary on;
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/application.conf:
--------------------------------------------------------------------------------
1 | try_files $uri =404;
2 | fastcgi_pass $fastcgi_backend;
3 | fastcgi_buffers 16 16k;
4 | fastcgi_buffer_size 32k;
5 |
6 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
7 | fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
8 |
9 | # Timout of 24h
10 | fastcgi_read_timeout 86400s;
11 | fastcgi_connect_timeout 86400s;
12 |
13 | fastcgi_index index.php;
14 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
15 |
16 | #Multi Website
17 | fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
18 | fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
19 |
20 | include fastcgi_params;
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/default_ssl.conf:
--------------------------------------------------------------------------------
1 | # Enable QUIC and HTTP/3.
2 | # listen 443 quic reuseport;
3 | listen 8443 ssl http2;
4 | listen [::]:8443 ssl http2;
5 |
6 | # Enable all TLS versions (TLSv1.3 is required for QUIC).
7 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
8 |
9 | # Add Alt-Svc header to negotiate HTTP/3.
10 | add_header alt-svc 'h3-23=":443"; ma=86400';
11 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/errors.conf:
--------------------------------------------------------------------------------
1 | location ~* \.xml$ {
2 | deny all;
3 | }
4 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/media.conf:
--------------------------------------------------------------------------------
1 | try_files $uri $uri/ /get.php$is_args$args;
2 |
3 | location ~ ^/media/theme_customization/.*\.xml {
4 | deny all;
5 | }
6 |
7 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
8 | add_header Cache-Control "public";
9 | add_header X-Frame-Options "SAMEORIGIN";
10 | expires +1y;
11 | try_files $uri $uri/ /get.php$is_args$args;
12 | }
13 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
14 | add_header Cache-Control "no-store";
15 | add_header X-Frame-Options "SAMEORIGIN";
16 | expires off;
17 | try_files $uri $uri/ /get.php$is_args$args;
18 | }
19 | add_header X-Frame-Options "SAMEORIGIN";
20 |
21 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/pub.conf:
--------------------------------------------------------------------------------
1 | location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) {
2 | deny all;
3 | }
4 | alias $MAGE_ROOT/pub/;
5 | add_header X-Frame-Options "SAMEORIGIN";
6 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/setup.conf:
--------------------------------------------------------------------------------
1 | root $MAGE_ROOT;
2 | location ~ ^/setup/index.php {
3 | fastcgi_pass $fastcgi_backend;
4 |
5 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
6 | fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600";
7 | fastcgi_read_timeout 600s;
8 | fastcgi_connect_timeout 600s;
9 |
10 | fastcgi_index index.php;
11 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
12 | include fastcgi_params;
13 | }
14 |
15 | location ~ ^/setup/(?!pub/). {
16 | deny all;
17 | }
18 |
19 | location ~ ^/setup/pub/ {
20 | add_header X-Frame-Options "SAMEORIGIN";
21 | }
22 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/static.conf:
--------------------------------------------------------------------------------
1 | # Uncomment the following line in production mode
2 | # expires max;
3 |
4 | # Remove signature of the static files that is used to overcome the browser cache
5 | location ~ ^/static/version {
6 | rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
7 | }
8 |
9 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ {
10 | add_header Cache-Control "public";
11 | add_header X-Frame-Options "SAMEORIGIN";
12 | expires +1y;
13 |
14 | if (!-f $request_filename) {
15 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
16 | }
17 | }
18 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
19 | add_header Cache-Control "no-store";
20 | add_header X-Frame-Options "SAMEORIGIN";
21 | expires off;
22 |
23 | if (!-f $request_filename) {
24 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
25 | }
26 | }
27 | if (!-f $request_filename) {
28 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
29 | }
30 | add_header X-Frame-Options "SAMEORIGIN";
31 |
--------------------------------------------------------------------------------
/config/nginx/conf.d/include/magento2/location/update.conf:
--------------------------------------------------------------------------------
1 | root $MAGE_ROOT;
2 |
3 | location ~ ^/update/index.php {
4 | fastcgi_split_path_info ^(/update/index.php)(/.+)$;
5 | fastcgi_pass $fastcgi_backend;
6 | fastcgi_index index.php;
7 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
8 | fastcgi_param PATH_INFO $fastcgi_path_info;
9 | include fastcgi_params;
10 | }
11 |
12 | # Deny everything but index.php
13 | location ~ ^/update/(?!pub/). {
14 | deny all;
15 | }
16 |
17 | location ~ ^/update/pub/ {
18 | add_header X-Frame-Options "SAMEORIGIN";
19 | }
20 |
--------------------------------------------------------------------------------
/config/varnish/default.vcl:
--------------------------------------------------------------------------------
1 | # VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
2 | vcl 4.0;
3 |
4 | import std;
5 | # The minimal Varnish version is 6.0
6 | # For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'
7 |
8 | backend default {
9 | .host = "nginx";
10 | .port = "8080";
11 | .first_byte_timeout = 60s;
12 | .probe = {
13 | # .url = "/health_check.php";
14 | .url = "/";
15 | .timeout = 60s;
16 | .interval = 5s;
17 | .window = 10;
18 | .threshold = 5;
19 | }
20 | }
21 |
22 | acl purge {
23 | "localhost";
24 | "192.168.128.0"/24;
25 | }
26 |
27 | sub vcl_recv {
28 | if (req.method == "PURGE") {
29 | if (client.ip !~ purge) {
30 | return (synth(405, "Method not allowed"));
31 | }
32 | # To use the X-Pool header for purging varnish during automated deployments, make sure the X-Pool header
33 | # has been added to the response in your backend server config. This is used, for example, by the
34 | # capistrano-magento2 gem for purging old content from varnish during it's deploy routine.
35 | if (!req.http.X-Magento-Tags-Pattern && !req.http.X-Pool) {
36 | return (synth(400, "X-Magento-Tags-Pattern or X-Pool header required"));
37 | }
38 | if (req.http.X-Magento-Tags-Pattern) {
39 | ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
40 | }
41 | if (req.http.X-Pool) {
42 | ban("obj.http.X-Pool ~ " + req.http.X-Pool);
43 | }
44 | return (synth(200, "Purged"));
45 | }
46 |
47 | if (req.method != "GET" &&
48 | req.method != "HEAD" &&
49 | req.method != "PUT" &&
50 | req.method != "POST" &&
51 | req.method != "TRACE" &&
52 | req.method != "OPTIONS" &&
53 | req.method != "DELETE") {
54 | /* Non-RFC2616 or CONNECT which is weird. */
55 | return (pipe);
56 | }
57 |
58 | # We only deal with GET and HEAD by default
59 | if (req.method != "GET" && req.method != "HEAD") {
60 | return (pass);
61 | }
62 |
63 | # Bypass shopping cart, checkout and search requests
64 | if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
65 | return (pass);
66 | }
67 |
68 | # Bypass health check requests
69 | if (req.url ~ "/health_check.php") {
70 | return (pass);
71 | }
72 |
73 | # Set initial grace period usage status
74 | set req.http.grace = "none";
75 |
76 | # normalize url in case of leading HTTP scheme and domain
77 | set req.url = regsub(req.url, "^http[s]?://", "");
78 |
79 | # collect all cookies
80 | std.collect(req.http.Cookie);
81 |
82 | # Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression
83 | if (req.http.Accept-Encoding) {
84 | if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
85 | # No point in compressing these
86 | unset req.http.Accept-Encoding;
87 | } elsif (req.http.Accept-Encoding ~ "gzip") {
88 | set req.http.Accept-Encoding = "gzip";
89 | } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
90 | set req.http.Accept-Encoding = "deflate";
91 | } else {
92 | # unknown algorithm
93 | unset req.http.Accept-Encoding;
94 | }
95 | }
96 |
97 | # Remove all marketing get parameters to minimize the cache objects
98 | if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") {
99 | set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", "");
100 | set req.url = regsub(req.url, "[?|&]+$", "");
101 | }
102 |
103 | # Static files caching
104 | if (req.url ~ "^/(pub/)?(media|static)/") {
105 | # Static files should not be cached by default
106 | #return (pass);
107 |
108 | # But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
109 | unset req.http.Https;
110 | unset req.http.X-Forwarded-Proto;
111 | unset req.http.Cookie;
112 | }
113 |
114 | return (hash);
115 | }
116 |
117 | sub vcl_hash {
118 | if (req.http.cookie ~ "X-Magento-Vary=") {
119 | hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));
120 | }
121 |
122 | # For multi site configurations to not cache each other's content
123 | if (req.http.host) {
124 | hash_data(req.http.host);
125 | } else {
126 | hash_data(server.ip);
127 | }
128 |
129 | # To make sure http users don't see ssl warning
130 | if (req.http.X-Forwarded-Proto) {
131 | hash_data(req.http.X-Forwarded-Proto);
132 | }
133 |
134 |
135 | if (req.url ~ "/graphql") {
136 | call process_graphql_headers;
137 | }
138 | }
139 |
140 | sub process_graphql_headers {
141 | if (req.http.Store) {
142 | hash_data(req.http.Store);
143 | }
144 | if (req.http.Content-Currency) {
145 | hash_data(req.http.Content-Currency);
146 | }
147 | }
148 |
149 | sub vcl_backend_response {
150 |
151 | set beresp.grace = 3d;
152 |
153 | if (beresp.http.content-type ~ "text") {
154 | set beresp.do_esi = true;
155 | }
156 |
157 | if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") {
158 | set beresp.do_gzip = true;
159 | }
160 |
161 | if (beresp.http.X-Magento-Debug) {
162 | set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;
163 | }
164 |
165 | # cache only successfully responses and 404s
166 | if (beresp.status != 200 && beresp.status != 404) {
167 | set beresp.ttl = 0s;
168 | set beresp.uncacheable = true;
169 | return (deliver);
170 | } elsif (beresp.http.Cache-Control ~ "private") {
171 | set beresp.uncacheable = true;
172 | set beresp.ttl = 86400s;
173 | return (deliver);
174 | }
175 |
176 | # validate if we need to cache it and prevent from setting cookie
177 | if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
178 | unset beresp.http.set-cookie;
179 | }
180 |
181 | # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
182 | if (beresp.ttl <= 0s ||
183 | beresp.http.Surrogate-control ~ "no-store" ||
184 | (!beresp.http.Surrogate-Control &&
185 | beresp.http.Cache-Control ~ "no-cache|no-store") ||
186 | beresp.http.Vary == "*") {
187 | # Mark as Hit-For-Pass for the next 2 minutes
188 | set beresp.ttl = 120s;
189 | set beresp.uncacheable = true;
190 | }
191 |
192 | return (deliver);
193 | }
194 |
195 | sub vcl_deliver {
196 | if (resp.http.X-Magento-Debug) {
197 | if (resp.http.x-varnish ~ " ") {
198 | set resp.http.X-Magento-Cache-Debug = "HIT";
199 | set resp.http.Grace = req.http.grace;
200 | } else {
201 | set resp.http.X-Magento-Cache-Debug = "MISS";
202 | }
203 | } else {
204 | unset resp.http.Age;
205 | }
206 |
207 | # Not letting browser to cache non-static files.
208 | if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") {
209 | set resp.http.Pragma = "no-cache";
210 | set resp.http.Expires = "-1";
211 | set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
212 | }
213 |
214 | unset resp.http.X-Magento-Debug;
215 | unset resp.http.X-Magento-Tags;
216 | unset resp.http.X-Powered-By;
217 | unset resp.http.Server;
218 | unset resp.http.X-Varnish;
219 | unset resp.http.Via;
220 | unset resp.http.Link;
221 | }
222 |
223 | sub vcl_hit {
224 | if (obj.ttl >= 0s) {
225 | # Hit within TTL period
226 | return (deliver);
227 | }
228 | if (std.healthy(req.backend_hint)) {
229 | if (obj.ttl + 300s > 0s) {
230 | # Hit after TTL expiration, but within grace period
231 | set req.http.grace = "normal (healthy server)";
232 | return (deliver);
233 | } else {
234 | # Hit after TTL and grace expiration
235 | return (restart);
236 | }
237 | } else {
238 | # server is not healthy, retrieve from cache
239 | set req.http.grace = "unlimited (unhealthy server)";
240 | return (deliver);
241 | }
242 | }
243 |
--------------------------------------------------------------------------------
/config/varnish/original.vcl:
--------------------------------------------------------------------------------
1 | #
2 | # This is an example VCL file for Varnish.
3 | #
4 | # It does not do anything by default, delegating control to the
5 | # builtin VCL. The builtin VCL is called when there is no explicit
6 | # return statement.
7 | #
8 | # See the VCL chapters in the Users Guide for a comprehensive documentation
9 | # at https://www.varnish-cache.org/docs/.
10 |
11 | # Marker to tell the VCL compiler that this VCL has been written with the
12 | # 4.0 or 4.1 syntax.
13 | vcl 4.1;
14 |
15 | # Default backend definition. Set this to point to your content server.
16 | backend default {
17 | .host = "nginx";
18 | .port = "8080";
19 | }
20 |
21 | sub vcl_recv {
22 | # Happens before we check if we have this in cache already.
23 | #
24 | # Typically you clean up the request here, removing cookies you don't need,
25 | # rewriting the request, etc.
26 | }
27 |
28 | sub vcl_backend_response {
29 | # Happens after we have read the response headers from the backend.
30 | #
31 | # Here you clean the response headers, removing silly Set-Cookie headers
32 | # and other mistakes your backend does.
33 | }
34 |
35 | sub vcl_deliver {
36 | # Happens when we have all the pieces we need, and are about to send the
37 | # response to the client.
38 | #
39 | # You can do accounting or modifying the final object here.
40 | }
41 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | nginx:
7 | image: magedin/nginx:1.21.0
8 | user: www
9 | ports:
10 | - "80:8080"
11 | - "443:8443"
12 | links:
13 | - db
14 | - php
15 | environment:
16 | SSL_CA_DIR: /var/www/ssl/ca
17 | SSL_CERT_DIR: /var/www/ssl/certificates
18 | networks:
19 | - magedin
20 | volumes: &appvolumes
21 | - ~/.composer:/var/www/.composer:cached
22 | - dockerlab_appdata:/var/www/html
23 | - ./var/ssl:/var/www/ssl:cached
24 |
25 | php: &php
26 | image: magedin/magento2-php:7.4
27 | user: www
28 | links:
29 | - db
30 | depends_on:
31 | - db
32 | - redis
33 | - elasticsearch
34 | env_file: ./.env
35 | networks:
36 | - magedin
37 | volumes: *appvolumes
38 |
39 | php-debug:
40 | image: magedin/magento2-php-debug:7.4
41 | <<: *php
42 |
43 | db:
44 | image: mariadb:10.4
45 | command: --max_allowed_packet=64M
46 | ports:
47 | - "3306:3306"
48 | env_file: ./.env
49 | networks:
50 | - magedin
51 | volumes:
52 | - dockerlab_dbdata:/var/lib/mysql
53 | - ./var/dumps:/var/dumps
54 |
55 | redis:
56 | image: redis:6.2
57 | networks:
58 | - magedin
59 |
60 | elasticsearch:
61 | image: elasticsearch:7.17.6
62 | ports:
63 | - "9200:9200"
64 | - "9300:9300"
65 | environment:
66 | - discovery.type=single-node
67 | - bootstrap.memory_lock=true
68 | - "ES_JAVA_OPTS=-Xms750m -Xmx750m"
69 | - xpack.security.enabled=false
70 | mem_limit: 4g
71 | networks:
72 | - magedin
73 | volumes:
74 | - dockerlab_esdata:/usr/share/elasticsearch/data
75 |
76 | # Disabling cron by default as it uses higher CPU, enable if needed
77 | #cron:
78 | # image: magedin/magento2-php:7.4
79 | # user: root
80 | # command: /usr/local/bin/cronstart
81 | # tty: true
82 | # links:
83 | # - db
84 | # volumes: *appvolumes
85 |
86 | networks:
87 | magedin:
88 | name: magento_dockerlab
89 |
90 | volumes:
91 | dockerlab_appdata:
92 | dockerlab_dbdata:
93 | dockerlab_ssldata:
94 | dockerlab_esdata:
95 |
--------------------------------------------------------------------------------
/services/.gitignore:
--------------------------------------------------------------------------------
1 | /docker-compose.*.yml
2 | !/docker-compose.blackfire.yml
3 | !/docker-compose.dev.mac.yml
4 | !/docker-compose.dev.yml
5 | !/docker-compose.kibana.yml
6 | !/docker-compose.mailhog.yml
7 | !/docker-compose.rabbitmq.yml
8 | !/docker-compose.varnish.yml
9 | !/docker-compose.elastichq.yml
10 |
11 |
--------------------------------------------------------------------------------
/services/docker-compose.blackfire.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | blackfire:
7 | image: blackfire/blackfire:2
8 | env_file: ./.env
9 | networks:
10 | - magedin
11 |
--------------------------------------------------------------------------------
/services/docker-compose.dev.mac.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | nginx:
7 | volumes: &appvolumes
8 | # To sync your SSH to the container, uncomment the following line:
9 | #- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
10 | - ./config/nginx/conf.d/:/etc/nginx/conf.d/
11 | #- ./config/apache/conf/vhosts:/usr/local/apache2/conf/vhosts
12 |
13 | # Host mounts with performance penalty, only put what is necessary here
14 | - ./src/app/code:/var/www/html/app/code:cached
15 | - ./src/app/design:/var/www/html/app/design:cached
16 | - ./src/app/etc:/var/www/html/app/etc:cached
17 | #- ./src/composer.json:/var/www/html/composer.json:cached
18 | #- ./src/composer.lock:/var/www/html/composer.lock:cached
19 | #- ./src/nginx.conf.sample:/var/www/html/nginx.conf:cached
20 | #- ./src/auth.json:/var/www/html/auth.json:cached
21 | #- ./src/m2-hotfixes:/var/www/html/m2-hotfixes:cached
22 | #- ./src/patches:/var/www/html/patches:cached
23 | #- ./src/var/log:/var/www/html/var/log:cached
24 | #- ./src/var/report:/var/www/html/var/report:cached
25 |
26 | # Linux only: remove the above lines and mount the entire src directory with:
27 | #- ./src:/var/www/html
28 |
29 | php:
30 | volumes: *appvolumes
31 |
32 | # Disabling cron by default as it uses higher CPU, enable if needed
33 | #cron:
34 | # volumes: *appvolumes
35 |
--------------------------------------------------------------------------------
/services/docker-compose.dev.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | nginx:
7 | volumes: &appvolumes
8 | # To sync your SSH to the container, uncomment the following line:
9 | #- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
10 | - ./config/nginx/conf.d/:/etc/nginx/conf.d/
11 | - ./src:/var/www/html
12 |
13 | php:
14 | volumes: *appvolumes
15 |
16 | php-debug:
17 | volumes: *appvolumes
18 |
19 | # Disabling cron by default as it uses higher CPU, enable if needed
20 | #cron:
21 | # volumes: *appvolumes
22 |
--------------------------------------------------------------------------------
/services/docker-compose.elastichq.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | elastichq:
7 | image: elastichq/elasticsearch-hq:latest
8 | depends_on:
9 | - elasticsearch
10 | ports:
11 | - "5000:5000"
12 | environment:
13 | HQ_DEFAULT_URL: http://elasticsearch:9200
14 | env_file: ./.env
15 | networks:
16 | - magedin
17 |
--------------------------------------------------------------------------------
/services/docker-compose.kibana.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | kibana:
7 | image: kibana:7.17.6
8 | depends_on:
9 | - elasticsearch
10 | ports:
11 | - "5601:5601"
12 | env_file: ./.env
13 | networks:
14 | - magedin
15 |
--------------------------------------------------------------------------------
/services/docker-compose.mailhog.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | mailhog:
7 | image: mailhog/mailhog
8 | depends_on:
9 | - php
10 | ports:
11 | - "1025"
12 | - "8025:8025"
13 | networks:
14 | - magedin
15 |
--------------------------------------------------------------------------------
/services/docker-compose.rabbitmq.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | php:
7 | depends_on:
8 | - rabbitmq
9 |
10 | rabbitmq:
11 | image: magedin/rabbitmq:3.8-management
12 | ports:
13 | - "15672:15672"
14 | - "5672:5672"
15 | env_file: ./.env
16 | networks:
17 | - magedin
18 | volumes:
19 | - dockerlab_rabbitmqdata:/var/lib/rabbitmq
20 | - dockerlab_rabbitmqlog:/var/log/rabbitmq
21 | hostname: rabbitmq
22 |
23 | volumes:
24 | dockerlab_rabbitmqdata:
25 | dockerlab_rabbitmqlog:
26 |
--------------------------------------------------------------------------------
/services/docker-compose.varnish.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | varnish:
7 | image: varnish:6
8 | depends_on:
9 | - nginx
10 | ports:
11 | - "8080:80"
12 | - "4443:443"
13 | networks:
14 | - magedin
15 | volumes:
16 | - ./config/varnish/:/etc/varnish
17 |
--------------------------------------------------------------------------------
/var/.dockerlab:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magedin/magento-dockerlab/1bd7ff8cdd58241d9f288fdbeeffd0d2a4ff30eb/var/.dockerlab
--------------------------------------------------------------------------------
/var/.gitignore:
--------------------------------------------------------------------------------
1 | .dockerlab
2 | project.config.yaml
3 |
--------------------------------------------------------------------------------
/var/dumps/.gitignore:
--------------------------------------------------------------------------------
1 | /*.sql
2 | /*.tar.*
3 | /*.gz
4 | /*.zip
--------------------------------------------------------------------------------
/var/ssl/.gitignore:
--------------------------------------------------------------------------------
1 | /*
2 | /.*
3 | !/.gitignore
4 | !/certificates
5 |
--------------------------------------------------------------------------------
/var/ssl/certificates/.gitignore:
--------------------------------------------------------------------------------
1 | /*
2 | /.*
3 | !/.gitignore
4 |
--------------------------------------------------------------------------------
/var/template/docker-compose/custom.yml:
--------------------------------------------------------------------------------
1 | # MagedIn - Magento DockerLab
2 | # (https://github.com/magedin/magento-dockerlab)
3 | version: "3.5"
4 |
5 | services:
6 | php:
7 | # Linux only: host.docker.internal doesn't exist https://github.com/docker/for-linux/issues/264
8 | # Uncomment two lines below & replace IP with result of: docker run --rm alpine ip route | awk 'NR==1 {print $3}'
9 | extra_hosts:
10 | - "host.docker.internal:{{IP}}"
11 | php-debug:
12 | <<: *php
13 |
--------------------------------------------------------------------------------
/var/template/nginx/magento2-ssl.conf:
--------------------------------------------------------------------------------
1 | server {
2 | ssl_certificate /var/www/ssl/certificates/{{host}}.pem;
3 | ssl_certificate_key /var/www/ssl/certificates/{{host}}-key.pem;
4 | include conf.d/include/magento2/location/default_ssl.conf;
5 | include conf.d/{{host}}/magento2-vars.conf;
6 | }
7 |
--------------------------------------------------------------------------------
/var/template/nginx/magento2-vars.conf:
--------------------------------------------------------------------------------
1 | server_name {{host}};
2 |
3 | set $MAGE_ROOT /var/www/html;
4 | set $MAGE_DEBUG_SHOW_ARGS 0;
5 |
6 | set $MAGE_RUN_TYPE {{run_type}};
7 | set $MAGE_RUN_CODE {{run_code}};
8 |
9 | include conf.d/include/magento2/base.conf;
10 |
--------------------------------------------------------------------------------
/var/template/nginx/magento2.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 8080;
3 | include conf.d/{{host}}/magento2-vars.conf;
4 | }
5 |
--------------------------------------------------------------------------------
/var/template/nginx/upstream.conf:
--------------------------------------------------------------------------------
1 | include conf.d/{{host}}/magento2.conf;
2 | include conf.d/{{host}}/magento2-ssl.conf;
3 |
--------------------------------------------------------------------------------
/var/volumes/.gitignore:
--------------------------------------------------------------------------------
1 | /*
2 | /.*
3 | !/.gitignore
4 |
--------------------------------------------------------------------------------