├── plugins
└── .gitkeep
├── plugins_old
├── Backend
│ └── .gitkeep
├── Core
│ └── .gitkeep
└── Frontend
│ └── .gitkeep
├── dev-ops
├── docker
│ ├── containers
│ │ ├── redis
│ │ │ └── Dockerfile
│ │ ├── mysql
│ │ │ ├── grant.sql
│ │ │ ├── remote-access.cnf
│ │ │ ├── performance-schema.cnf
│ │ │ ├── dev.cnf
│ │ │ └── Dockerfile
│ │ ├── php7
│ │ │ ├── timezone-berlin.ini
│ │ │ ├── server-apache2-run-as.conf
│ │ │ ├── php-config.ini
│ │ │ ├── xdebug.ini
│ │ │ ├── server-apache2-vhosts.conf
│ │ │ ├── Dockerfile
│ │ │ └── wait-for-it.sh
│ │ ├── elastic-search
│ │ │ ├── Dockerfile
│ │ │ └── elasticsearch.yml
│ │ └── scriptcreator.sh
│ └── actions
│ │ ├── stop.sh
│ │ ├── ssh-es.sh
│ │ ├── ssh.sh
│ │ ├── ssh-mysql.sh
│ │ ├── ssh-redis.sh
│ │ ├── destroy.sh
│ │ ├── status.sh
│ │ └── start.sh
└── common
│ ├── actions
│ ├── es-on.sh
│ ├── csrf-on.sh
│ ├── es-off.sh
│ ├── csrf-off.sh
│ ├── debug-off.sh
│ ├── debug-on.sh
│ ├── init-themes.sh
│ ├── init.sh
│ ├── init-vcs.sh
│ └── init-plugins.sh
│ └── ConfigHelper.php
├── psh.phar
├── sw.phar
├── .travis.yml
├── .editorconfig
├── .gitignore
├── .psh.yaml.dist
├── docker-compose.yml
└── README.md
/plugins/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/plugins_old/Backend/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/plugins_old/Core/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/plugins_old/Frontend/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/redis/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM redis:4
2 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/mysql/grant.sql:
--------------------------------------------------------------------------------
1 | GRANT ALL ON *.* TO 'app'@'%';
2 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/php7/timezone-berlin.ini:
--------------------------------------------------------------------------------
1 | date.timezone=Europe/Berlin
--------------------------------------------------------------------------------
/psh.phar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shopwareArchive/shopware-docker/HEAD/psh.phar
--------------------------------------------------------------------------------
/sw.phar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shopwareArchive/shopware-docker/HEAD/sw.phar
--------------------------------------------------------------------------------
/dev-ops/docker/containers/mysql/remote-access.cnf:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | bind-address = 0.0.0.0
3 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/mysql/performance-schema.cnf:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | performance_schema = ON
3 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/php7/server-apache2-run-as.conf:
--------------------------------------------------------------------------------
1 | User app-shell
2 | Group app-shell
3 |
4 |
--------------------------------------------------------------------------------
/dev-ops/docker/actions/stop.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | docker-compose down
4 | echo "All containers stopped"
--------------------------------------------------------------------------------
/dev-ops/docker/containers/elastic-search/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM docker.elastic.co/elasticsearch/elasticsearch:5.5.2
2 |
--------------------------------------------------------------------------------
/dev-ops/docker/actions/ssh-es.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TTY: docker exec -i -u __USERKEY__ -t __ES_ID__ bash
4 |
--------------------------------------------------------------------------------
/dev-ops/docker/actions/ssh.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TTY: docker exec -i -u __USERKEY__ -t __APP_ID__ bash
4 |
--------------------------------------------------------------------------------
/dev-ops/docker/actions/ssh-mysql.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TTY: docker exec -i -u __USERKEY__ -t __MYSQL_ID__ bash
4 |
--------------------------------------------------------------------------------
/dev-ops/docker/actions/ssh-redis.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TTY: docker exec -i -u __USERKEY__ -t __REDIS_ID__ bash
4 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/php7/php-config.ini:
--------------------------------------------------------------------------------
1 | phar.readonly=0
2 | short_open_tag = Off
3 |
4 | max_execution_time=0
5 | memory_limit=-1
6 |
7 | upload_max_filesize = 100M
8 | post_max_size = 100M
9 |
--------------------------------------------------------------------------------
/dev-ops/common/actions/es-on.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: enable elasticsearch
3 |
4 | php -r "require_once __DIR__(sic!).'/dev-ops/common/ConfigHelper.php'; ConfigHelper::enableElasticSearch();"
--------------------------------------------------------------------------------
/dev-ops/docker/actions/destroy.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Removing all docker container caches:"
4 | docker-compose kill
5 | docker rm $(docker ps -a -q)
6 | docker rmi --force $(docker images -q)
--------------------------------------------------------------------------------
/dev-ops/common/actions/csrf-on.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: enable csrf protection
3 |
4 | php -r "require_once __DIR__(sic!).'/dev-ops/common/ConfigHelper.php'; ConfigHelper::enableCsrfProtection();"
--------------------------------------------------------------------------------
/dev-ops/common/actions/es-off.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: disable elasticsearch
3 |
4 | php -r "require_once __DIR__(sic!).'/dev-ops/common/ConfigHelper.php'; ConfigHelper::disableElasticSearch();"
--------------------------------------------------------------------------------
/dev-ops/docker/actions/status.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | printf "\nDocker containers status:"
4 | docker ps --format "table{{.ID}}\t{{.Names}}\t{{.Status}}"
5 | printf "\nNetwork status:"
6 | docker network ls
--------------------------------------------------------------------------------
/dev-ops/common/actions/csrf-off.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: disable csrf protection
3 |
4 | php -r "require_once __DIR__(sic!).'/dev-ops/common/ConfigHelper.php'; ConfigHelper::disableCsrfProtection();"
--------------------------------------------------------------------------------
/dev-ops/common/actions/debug-off.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: disable debug values in config.php
3 |
4 | php -r "require_once __DIR__(sic!).'/dev-ops/common/ConfigHelper.php'; ConfigHelper::disableDebug();"
--------------------------------------------------------------------------------
/dev-ops/common/actions/debug-on.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: enable debug values in config.php
3 |
4 | php -r "require_once __DIR__(sic!).'/dev-ops/common/ConfigHelper.php'; ConfigHelper::enableDebug();"
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | php:
3 | - '7.0'
4 | - '7.1'
5 | - '7.2'
6 | env:
7 | - DOCKER_COMPOSE_VERSION=1.23.2
8 | services:
9 | - docker
10 |
11 | script:
12 | - ./psh.phar docker:start
--------------------------------------------------------------------------------
/dev-ops/common/actions/init-themes.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: executes on app_webserver to link local frontend themes
3 |
4 | I: find shopware/themes/Frontend/ -type l | xargs -r rm
5 | ls themes/ | while read file; do ln -s ../../../themes/$file shopware/themes/Frontend/$file; done
--------------------------------------------------------------------------------
/dev-ops/common/actions/init.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: executes on app_webserver to provision your environment
3 |
4 | rm -rf ./shopware
5 | ./sw.phar install:release -r __SW-VERSION__ -i ./shopware --db-host __DB_HOST__ --db-user __DB_USER__ --db-password __DB_PASSWORD__ --db-name __DB_NAME__ --shop-host __SW_HOST__
6 |
--------------------------------------------------------------------------------
/dev-ops/docker/actions/start.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME}"
4 |
5 | dev-ops/docker/containers/scriptcreator.sh
6 | docker-compose build && docker-compose up -d
7 | wait
8 |
9 | echo "All containers started successfully"
10 | echo "Web server IP: http://localhost:8083"
11 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # This is the top-most .editorconfig file; do not search in parent directories.
2 | root = true
3 |
4 | # All files.
5 | [*]
6 | end_of_line = lf
7 | indent_style = space
8 | indent_size = 4
9 | charset = utf-8
10 | trim_trailing_whitespace = true
11 | insert_final_newline = false
12 |
13 | [*.md]
14 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /.psh.yaml
3 | /.psh.yaml.override
4 | /shopware
5 |
6 | # dev-ops
7 | /docker-compose.override.yml
8 | /dev-ops/docker/containers/mysql/createuser.sh
9 | /dev-ops/docker/containers/php7/createuser.sh
10 | /dev-ops/docker/_volumes
11 | !dev-ops/docker/_volumes/.gitkeep
12 | /plugins/
13 | !/plugins/.gitkeep
14 | /plugins_old/
15 | !/plugins_old/.gitkeep
--------------------------------------------------------------------------------
/dev-ops/docker/containers/php7/xdebug.ini:
--------------------------------------------------------------------------------
1 | zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
2 |
3 | xdebug.remote_enable=1
4 | xdebug.remote_handler=dbgp
5 | xdebug.remote_host=172.17.0.1
6 | xdebug.remote_port=9000
7 | xdebug.remote_autostart=0
8 | xdebug.remote_connect_back=1
9 |
10 | xdebug.profiler_output_dir = "/var/www/shopware/build/artifacts"
--------------------------------------------------------------------------------
/dev-ops/docker/containers/mysql/dev.cnf:
--------------------------------------------------------------------------------
1 | ; bcremer
2 | [mysqld]
3 | innodb_buffer_pool_size = 2G
4 | innodb_flush_log_at_trx_commit = 0
5 | innodb_log_buffer_size = 64M
6 | innodb_log_file_size = 512M
7 | innodb_flush_method = O_DIRECT
8 | innodb_doublewrite = 0
9 | innodb_checksums = 0
10 |
11 | query_cache_size=0
12 | join_buffer_size=256K
13 | table_open_cache=128
14 |
15 | max_connections=10000
--------------------------------------------------------------------------------
/dev-ops/docker/containers/php7/server-apache2-vhosts.conf:
--------------------------------------------------------------------------------
1 |
2 | DocumentRoot /var/www/shopware/shopware/
3 |
4 | SetEnv SHOPWARE_ENV=dev
5 |
6 |
7 | Options Indexes FollowSymLinks MultiViews
8 | AllowOverride All
9 | Order allow,deny
10 | allow from all
11 |
12 |
13 | ErrorLog /var/log/apache2/server.error.log
14 | CustomLog /var/log/apache2/server.access.log combined
15 | LogLevel debug
16 |
17 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/mysql/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mysql:5.7
2 |
3 | RUN apt-get update \
4 | && apt-get install --no-install-recommends -y \
5 | vim \
6 | netcat-openbsd
7 |
8 | ADD dev.cnf /etc/mysql/conf.d/dev.cnf
9 | ADD remote-access.cnf /etc/mysql/conf.d/remote-access.cnf
10 | ADD performance-schema.cnf /etc/mysql/conf.d/performance-schema.cnf
11 | COPY createuser.sh /tmp/createuser.sh
12 | RUN chmod +rwx /tmp/createuser.sh
13 | RUN /tmp/createuser.sh
14 |
15 | COPY grant.sql /docker-entrypoint-initdb.d/grant.sql
16 |
--------------------------------------------------------------------------------
/.psh.yaml.dist:
--------------------------------------------------------------------------------
1 | paths:
2 | - dev-ops/common/actions
3 |
4 | const:
5 | DB_USER: "app"
6 | DB_PASSWORD: "app"
7 | DB_HOST: "mysql"
8 | DB_NAME: "shopware"
9 | SW_HOST: "localhost:8083"
10 | SW-BRANCH: "5.4"
11 | SW-VERSION: "latest"
12 |
13 | dynamic:
14 | USERKEY: echo "$(id -u):$(id -g)"
15 | APP_ID: docker-compose ps -q app_server
16 | MYSQL_ID: docker-compose ps -q app_mysql
17 | ES_ID: docker-compose ps -q app_es
18 | REDIS_ID: docker-compose ps -q app_redis
19 | DOCKER_HTTP_PROXY: echo $HTTP_PROXY
20 |
21 | environments:
22 | docker:
23 | paths:
24 | - "dev-ops/docker/actions"
25 |
--------------------------------------------------------------------------------
/dev-ops/docker/containers/php7/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM webdevops/php-apache-dev:7.2
2 |
3 | ENV COMPOSER_HOME=/.composer
4 | ENV WEB_DOCUMENT_ROOT=/var/www/shopware/shopware
5 |
6 | COPY wait-for-it.sh /usr/local/bin/
7 | COPY php-config.ini /usr/local/etc/php/conf.d/
8 | COPY xdebug.ini /usr/local/etc/php/conf.d/
9 | COPY createuser.sh /addExternalUser
10 |
11 | # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199
12 | RUN mkdir -p /usr/share/man/man1
13 |
14 | RUN apt-get update && apt-get install -y ant mysql-client
15 |
16 | RUN chmod +x /usr/local/bin/wait-for-it.sh \
17 | && ln -s /app/psh.phar /bin/psh
18 |
19 | WORKDIR /var/www/shopware
20 |
--------------------------------------------------------------------------------
/dev-ops/common/actions/init-vcs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: executes on app_webserver to provision a vcs environment
3 |
4 | rm -rf ./shopware
5 | git clone --depth 1 -b __SW-BRANCH__ https://github.com/shopware/shopware.git
6 |
7 | cd shopware/ && composer install && composer dump-autoload --optimize
8 |
9 | ant -f shopware/build/build.xml -Ddb.user=__DB_USER__ -Ddb.password=__DB_PASSWORD__ -Ddb.host=__DB_HOST__ -Ddb.name=__DB_NAME__ -Dapp.host=__SW_HOST__ build-cache-dir build-config build-database build-generate-attributes build-snippets-deploy build-theme-initialize build-create-admin-account build-install-lock-file build-disable-firstrunwizard install-git-hooks
10 |
11 | shopware/bin/console sw:firstrunwizard:disable
--------------------------------------------------------------------------------
/dev-ops/common/actions/init-plugins.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #DESCRIPTION: executes on app_webserver to install the local plugins
3 |
4 | I: find shopware/custom/plugins/ -type l | xargs rm
5 | I: find shopware/engine/Shopware/Plugins/Local/ -type l | xargs rm -r
6 | ls plugins/ | while read file; do ln -s ../../../plugins/$file shopware/custom/plugins/$file; done
7 | ls plugins_old/ | while read file; do ln -s ../../../../../plugins_old/$file shopware/engine/Shopware/Plugins/Local/; done
8 | shopware/bin/console sw:plugin:refresh
9 | shopware/bin/console sw:plugin:list
10 | I: ls plugins/ | while read file; do shopware/bin/console sw:plugin:uninstall $file; done;
11 | ls plugins/ | while read file; do shopware/bin/console sw:plugin:install --activate $file; done;
--------------------------------------------------------------------------------
/dev-ops/docker/containers/scriptcreator.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4 |
5 | USERID=$(id -u)
6 | GROUP=$(id -g)
7 |
8 |
9 | cat > $DIR/php7/createuser.sh <> /etc/sudoers
18 | DELIM
19 |
20 | echo "Created "$DIR/php7/createuser.sh
21 |
22 | cat > $DIR/mysql/createuser.sh <> /etc/sudoers
31 | DELIM
32 |
33 | echo "Created "$DIR/mysql/createuser.sh
--------------------------------------------------------------------------------
/dev-ops/docker/containers/elastic-search/elasticsearch.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ## Default Elasticsearch configuration from elasticsearch-docker.
3 | ## from https://github.com/elastic/elasticsearch-docker/blob/master/build/elasticsearch/elasticsearch.yml
4 | #
5 | cluster.name: "docker-cluster"
6 | network.host: 0.0.0.0
7 |
8 | # minimum_master_nodes need to be explicitly set when bound on a public IP
9 | # set to 1 to allow single node clusters
10 | # Details: https://github.com/elastic/elasticsearch/pull/17288
11 | discovery.zen.minimum_master_nodes: 1
12 |
13 | ## Use single node discovery in order to disable production mode and avoid bootstrap checks
14 | ## see https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html
15 | #
16 | discovery.type: single-node
17 |
18 | ## Disable X-Pack
19 | ## see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html
20 | ## https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html#xpack-enabling
21 | #
22 | xpack.security.enabled: false
23 | xpack.monitoring.enabled: false
24 | xpack.ml.enabled: false
25 | xpack.graph.enabled: false
26 | xpack.watcher.enabled: false
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 |
3 | services:
4 | app_server:
5 | build: dev-ops/docker/containers/php7
6 | volumes:
7 | - ~/.composer/cache:/var/www/composer-cache-dir:Z
8 | - .:/project:Z
9 | - .:/var/www/shopware:Z
10 | links:
11 | - app_mysql:mysql
12 | environment:
13 | TERM: xterm
14 | COMPOSER_CACHE_DIR: /var/www/composer-cache-dir
15 | ports:
16 | - "8083:80"
17 |
18 | app_mysql:
19 | build: dev-ops/docker/containers/mysql
20 | volumes:
21 | - ./dev-ops/docker/_volumes/app-mysql-data:/var/lib/mysql:Z
22 | environment:
23 | MYSQL_ROOT_PASSWORD: root
24 | MYSQL_USER: app
25 | MYSQL_PASSWORD: app
26 |
27 | app_es:
28 | build: dev-ops/docker/containers/elastic-search
29 | volumes:
30 | - ./dev-ops/docker/containers/elastic-search/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:Z
31 | - ./dev-ops/docker/_volumes/app-es-data:/usr/share/elasticsearch/data:Z
32 | ports:
33 | - "9200:9200"
34 | - "9300:9300"
35 | environment:
36 | TERM: xterm
37 | ES_JAVA_OPTS: "-Xmx256m -Xms256m"
38 |
39 | app_redis:
40 | build: dev-ops/docker/containers/redis
41 | volumes:
42 | - ./dev-ops/docker/_volumes/app-redisdata:/data:Z
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/shopwareLabs/shopware-docker)
2 |
3 | Docker Shopware Box
4 | ====================
5 |
6 | ## Installation
7 |
8 | Docker (min. Version 1.12) have to be installed on your local machine:
9 |
10 | - [Docker](https://docs.docker.com/engine/installation/linux/)
11 |
12 | ## Usage
13 |
14 | Clone the repository to your local machine.
15 |
16 | $ git clone https://github.com/shopwareLabs/shopware-docker
17 | $ cd shopware-docker
18 |
19 | Boot up your docker containers with psh.phar:
20 |
21 | $ ./psh.phar docker:start
22 |
23 | The first boot may take a while, so feel free to get a cup of coffee.
24 |
25 | Your machine will be available at [http://localhost:8083/](http://localhost:8083/)
26 | All required tools like the LAMP stack are already installed.
27 |
28 | - MySQL user: `app`, password: `app`
29 |
30 | To SSH into the created Container:
31 |
32 | $ ./psh.phar docker:ssh
33 |
34 | ## Installing Shopware
35 |
36 | SSH first into your VM:
37 |
38 | $ ./psh.phar docker:ssh
39 |
40 | Call the init script:
41 |
42 | $ ./psh.phar init
43 |
44 | This will download the latest release version of shopware and install it into /var/www/shopware/shopware
45 |
46 | If you want an older shopware version just add --sw-version to the init script:
47 |
48 | $ ./psh.phar init --sw-version=5.2.26
49 |
50 | #### For plugin development
51 |
52 | For plugin development there is a script `init-vcs` to initialize and install shopware through github.
53 |
54 | $ ./psh.phar init-vcs --sw-branch=5.2
55 |
56 | The plugin(s) you want to start development should be located in `./plugins` (Only new plugin system is supported). They can be installed and linked into the Shopware checkout by executing
57 |
58 | $ ./psh.phar init-plugins
59 |
60 |
61 | This can be used together with our [`plugin-dev-tools`](https://github.com/shopwareLabs/plugin-dev-tools) as the `local` environment.
62 |
63 | #### Access
64 |
65 | Configure your online store in a web browser with the credentials demo/demo:
66 |
67 | - Backend: [http://localhost:8083/backend/](http://localhost:8083/backend/)
68 |
69 | You can then access your storefront at:
70 |
71 | - Front-end: [http://localhost:8083/](http://localhost:8083/)
72 |
73 | ## Troubleshooting
74 |
75 | If the elasticsearch or redis container didn't start make sure that the directory dev-ops/docker/_volumes/app-esdata|app-redisdata has chmod 777.
76 |
--------------------------------------------------------------------------------
/dev-ops/common/ConfigHelper.php:
--------------------------------------------------------------------------------
1 | true,
13 | 'number_of_replicas' => 0,
14 | 'number_of_shards' => null,
15 | 'client' => [
16 | 'hosts' => [
17 | 'app_es:9200',
18 | ],
19 | ],
20 | ];
21 |
22 | self::saveConfig($config);
23 | }
24 |
25 | public static function enableDebug()
26 | {
27 | $config = self::getConfig(self::CONFIG_PATH);
28 |
29 | $config['errorHandler'] = [
30 | 'throwOnRecoverableError' => true,
31 | ];
32 |
33 | $config['front'] = [
34 | 'noErrorHandler' => true,
35 | 'throwExceptions' => true,
36 | 'disableOutputBuffering' => true,
37 | 'showException' => true,
38 | ];
39 |
40 | $config['model'] = [
41 | 'cacheProvider' => 'array',
42 | ];
43 |
44 | $config['phpsettings'] = [
45 | 'error_reporting' => E_ALL,
46 | 'display_errors' => 1,
47 | ];
48 |
49 | self::saveConfig($config);
50 | }
51 |
52 | public static function enableCsrfProtection()
53 | {
54 | $config = self::getConfig(self::CONFIG_PATH);
55 |
56 | if (isset($config['csrfprotection'])) {
57 | unset($config['csrfprotection']);
58 | }
59 |
60 | self::saveConfig($config);
61 | }
62 |
63 | public static function disableElasticSearch()
64 | {
65 | $config = self::getConfig(self::CONFIG_PATH);
66 |
67 | if (isset($config['es'])) {
68 | unset($config['es']);
69 | }
70 |
71 | self::saveConfig($config);
72 | }
73 |
74 | public static function disableDebug()
75 | {
76 | $config = self::getConfig(self::CONFIG_PATH);
77 |
78 | if (isset($config['errorHandler'])) {
79 | unset($config['errorHandler']);
80 | }
81 |
82 | if (isset($config['front'])) {
83 | unset($config['front']);
84 | }
85 |
86 | if (isset($config['model'])) {
87 | unset($config['model']);
88 | }
89 |
90 | if (isset($config['phpsettings'])) {
91 | unset($config['phpsettings']);
92 | }
93 |
94 | self::saveConfig($config);
95 | }
96 |
97 | public static function disableCsrfProtection()
98 | {
99 | $config = self::getConfig(self::CONFIG_PATH);
100 |
101 | $config['csrfprotection'] = [
102 | 'frontend' => false,
103 | 'backend' => false,
104 | ];
105 |
106 | self::saveConfig($config);
107 | }
108 |
109 | private static function getConfig($configPath)
110 | {
111 | if (!file_exists($configPath)) {
112 | throw new RuntimeException('please install shopware first!');
113 | }
114 |
115 | return include $configPath;
116 | }
117 |
118 | private static function saveConfig($config)
119 | {
120 | $configFile = '&2; fi }
7 |
8 | usage()
9 | {
10 | cat << USAGE >&2
11 | Usage:
12 | $cmdname host:port [-s] [-t timeout] [-- command args]
13 | -h HOST | --host=HOST Host or IP under test
14 | -p PORT | --port=PORT TCP port under test
15 | Alternatively, you specify the host and port as host:port
16 | -s | --strict Only execute subcommand if the test succeeds
17 | -q | --quiet Don't output any status messages
18 | -t TIMEOUT | --timeout=TIMEOUT
19 | Timeout in seconds, zero for no timeout
20 | -- COMMAND ARGS Execute command with args after the test finishes
21 | USAGE
22 | exit 1
23 | }
24 |
25 | wait_for()
26 | {
27 | if [[ $TIMEOUT -gt 0 ]]; then
28 | echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
29 | else
30 | echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
31 | fi
32 | start_ts=$(date +%s)
33 | while :
34 | do
35 | if [[ $ISBUSY -eq 1 ]]; then
36 | nc -z $HOST $PORT
37 | result=$?
38 | else
39 | (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
40 | result=$?
41 | fi
42 | if [[ $result -eq 0 ]]; then
43 | end_ts=$(date +%s)
44 | echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds"
45 | break
46 | fi
47 | sleep 1
48 | done
49 | return $result
50 | }
51 |
52 | wait_for_wrapper()
53 | {
54 | # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
55 | if [[ $QUIET -eq 1 ]]; then
56 | timeout $BUSYTIMEFLAG $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
57 | else
58 | timeout $BUSYTIMEFLAG $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
59 | fi
60 | PID=$!
61 | trap "kill -INT -$PID" INT
62 | wait $PID
63 | RESULT=$?
64 | if [[ $RESULT -ne 0 ]]; then
65 | echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT"
66 | fi
67 | return $RESULT
68 | }
69 |
70 | # process arguments
71 | while [[ $# -gt 0 ]]
72 | do
73 | case "$1" in
74 | *:* )
75 | hostport=(${1//:/ })
76 | HOST=${hostport[0]}
77 | PORT=${hostport[1]}
78 | shift 1
79 | ;;
80 | --child)
81 | CHILD=1
82 | shift 1
83 | ;;
84 | -q | --quiet)
85 | QUIET=1
86 | shift 1
87 | ;;
88 | -s | --strict)
89 | STRICT=1
90 | shift 1
91 | ;;
92 | -h)
93 | HOST="$2"
94 | if [[ $HOST == "" ]]; then break; fi
95 | shift 2
96 | ;;
97 | --host=*)
98 | HOST="${1#*=}"
99 | shift 1
100 | ;;
101 | -p)
102 | PORT="$2"
103 | if [[ $PORT == "" ]]; then break; fi
104 | shift 2
105 | ;;
106 | --port=*)
107 | PORT="${1#*=}"
108 | shift 1
109 | ;;
110 | -t)
111 | TIMEOUT="$2"
112 | if [[ $TIMEOUT == "" ]]; then break; fi
113 | shift 2
114 | ;;
115 | --timeout=*)
116 | TIMEOUT="${1#*=}"
117 | shift 1
118 | ;;
119 | --)
120 | shift
121 | CLI=("$@")
122 | break
123 | ;;
124 | --help)
125 | usage
126 | ;;
127 | *)
128 | echoerr "Unknown argument: $1"
129 | usage
130 | ;;
131 | esac
132 | done
133 |
134 | if [[ "$HOST" == "" || "$PORT" == "" ]]; then
135 | echoerr "Error: you need to provide a host and port to test."
136 | usage
137 | fi
138 |
139 | TIMEOUT=${TIMEOUT:-15}
140 | STRICT=${STRICT:-0}
141 | CHILD=${CHILD:-0}
142 | QUIET=${QUIET:-0}
143 |
144 | # check to see if timeout is from busybox?
145 | # check to see if timeout is from busybox?
146 | TIMEOUT_PATH=$(realpath $(which timeout))
147 | if [[ $TIMEOUT_PATH =~ "busybox" ]]; then
148 | ISBUSY=1
149 | BUSYTIMEFLAG="-t"
150 | else
151 | ISBUSY=0
152 | BUSYTIMEFLAG=""
153 | fi
154 |
155 | if [[ $CHILD -gt 0 ]]; then
156 | wait_for
157 | RESULT=$?
158 | exit $RESULT
159 | else
160 | if [[ $TIMEOUT -gt 0 ]]; then
161 | wait_for_wrapper
162 | RESULT=$?
163 | else
164 | wait_for
165 | RESULT=$?
166 | fi
167 | fi
168 |
169 | if [[ $CLI != "" ]]; then
170 | if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
171 | echoerr "$cmdname: strict mode, refusing to execute subprocess"
172 | exit $RESULT
173 | fi
174 | exec "${CLI[@]}"
175 | else
176 | exit $RESULT
177 | fi
--------------------------------------------------------------------------------