Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Merge pull request #174 from blinkreaction/develop
Browse files Browse the repository at this point in the history
Release v1.5.0
  • Loading branch information
lmakarov authored Oct 10, 2016
2 parents df21fba + e99ce44 commit 8ae732e
Show file tree
Hide file tree
Showing 33 changed files with 1,350 additions and 95 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "tests/helpers/bats-support"]
path = tests/helpers/bats-support
url = https://github.com/ztombol/bats-support.git
[submodule "tests/helpers/bats-assert"]
path = tests/helpers/bats-assert
url = https://github.com/ztombol/bats-assert.git
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright © 2015-2016 Blink Reaction

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 15 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

Docker and Docker Compose based environment for Drupal.

------------------------- IMPORTANT ANNOUNCEMENT -------------------------

This project is being retired and replaced with a new one: [Docksal](https://github.com/docksal/docksal).
Existing users are advised to switch to Docksal.

--------------------------------------------------------------------------


**For a fully working example of Drude setup take a look at:**
- [Drupal 7 sample project](https://github.com/blinkreaction/drude-d7-testing)
- [Drupal 8 sample project](https://github.com/blinkreaction/drude-d8-testing)
Expand Down Expand Up @@ -85,45 +93,23 @@ Tools available inside the **cli** container:
- [Drupal settings](/docs/drupal-settings.md)
- [Overriding default PHP/MySQL/etc. settings](/docs/settings.md)
- [Running multiple projects](/docs/multiple-projects.md)
- [Public access](/docs/public-access.md)
- [DB sandbox mode](/docs/db-sandbox.md)
- [MySQL DB access for external tools](/docs/db-access.md)
- [Debugging with Xdebug and PhpStorm](/docs/xdebug.md)
- [Extending dsh with custom commands](/docs/custom-commands.md)

### Third party utililies
- [Debugging with Xdebug and PhpStorm](/docs/xdebug.md)
- [Using PHP Code Sniffer (phpcs, phpcbf)](/docs/phpcs.md)
- [Using Blackfire profiler](/docs/blackfire.md)
- [Public access via ngrok](/docs/public-access.md)
- [Using Behat](/docs/behat.md)
- [Sending and capturing e-mail](/docs/mail.md)
- [Enabling Varnish support](/docs/varnish.md)
- [Enabling Apache Solr support](/docs/apache-solr.md)
- [Using PHP Code Sniffer (phpcs, phpcbf)](/docs/phpcs.md)
- [Extending dsh with custom commands](/docs/custom-commands.md)
- [Using Sass](/docs/sass.md)
- [Using custom ssh keys (with or without passwords) via ssh-agent](/docs/ssh-agent.md)

<a name="troubleshooting"></a>
## Troubleshooting

See [Troubleshooting](/docs/troubleshooting.md) section of the docs.


## License

The MIT License (MIT)

Copyright © 2016 Blink Reaction

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
81 changes: 31 additions & 50 deletions bin/dsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

DSH_VERSION=1.20.3
DSH_VERSION=1.20.7

# Console colors
red='\033[0;91m'
Expand Down Expand Up @@ -793,48 +793,26 @@ vmstat ()
# @param $1 -D, -l or path to custom key
ssh_add () {
# Check if ssh-agent container is running
local running=$(docker inspect --format="{{ .State.Running }}" ssh-agent 2> /dev/null)
if [ $? -eq 0 ] && [ "$running" == "true" ]; then
local running=$(docker inspect --format="{{ .State.Running }}" ssh-agent 2>/dev/null)
[[ "$running" != "true" ]] && return

local ssh_path="$HOME/.ssh"
# Home folder mount in boot2docker
if ! is_linux; then
ssh_path="/.home/.ssh"
fi
local key_path=""

case "$1" in
"")
if docker exec -it ssh-agent ssh-add -l > /dev/null; then
return; # Some key is present
fi
;;
-D)
docker run --rm --volumes-from=ssh-agent -it "blinkreaction/ssh-agent:${DRUDE_ITAG}" ssh-add -D
exit 1
;;
-l)
# We do a sed hack here to strip out '/root/.ssh' from the key path in the output from ssh-add, since this path may confuse people.
docker run --rm --volumes-from=ssh-agent -it "blinkreaction/ssh-agent:${DRUDE_ITAG}" ssh-add -l 2>&1 | sed 's/\/root\/.ssh\///g'
exit 1
;;
*)
key_path="/root/.ssh/$1"
# We check $HOME here regardless Linux or Mac/Windows (boot2docker)
# $HOME is mounted as /.home in boot2docker
if [ ! -f "$HOME/.ssh/$1" ]; then
echo-red "SSH key file not found: $HOME/.ssh/$1"
exit 1
fi
;;
esac

echo "Press ENTER or CTRL+C to skip entering passphrase."
# $ssh_path is mounted as /root/.ssh in the ssh-agent containers.
# When $key_path is empty, ssh-agent will be looking for both id_rsa and id_dsa in the home directory.
# We do a sed hack here to strip out '/root/.ssh' from the key path in the output from ssh-add, since this path may confuse people.
docker run --rm --volumes-from=ssh-agent -it -v "$ssh_path:/root/.ssh" "blinkreaction/ssh-agent:${DRUDE_ITAG}" ssh-add "$key_path" 2>&1 | sed 's/\/root\/.ssh\///g'
local ssh_path="$HOME/.ssh"
local key_path=""
# Home folder mount in boot2docker
if ! is_linux; then
ssh_path="/.home/.ssh"
fi

# When no arguments provided, check if ssh-agent already has at least one identity. If so, stop here.
docker exec ssh-agent ssh-add -l >/dev/null
if [[ $1 == "" && $? == 0 ]]; then return; fi

ssh_arg="$@"
if [[ $1 != "-l" && $1 != "-D" && $ssh_arg != "" ]]; then ssh_arg="/.ssh/$@"; fi

# When $key_path is empty, ssh-agent will be looking for both id_rsa and id_dsa in the home directory.
$winpty_cmd docker run --rm -it --volumes-from=ssh-agent -v "$ssh_path:/.ssh" "blinkreaction/ssh-agent:${DRUDE_ITAG}" ssh-add "$ssh_arg"
return $?
}

#----- Installations and updates -----
Expand Down Expand Up @@ -883,7 +861,7 @@ install_proxy_service ()
docker rm -f vhost-proxy >/dev/null 2>&1 || true
docker run -d --name vhost-proxy --label "group=system" --restart=always --privileged --userns=host \
-p 80:80 -p 443:443 \
-v /var/run/docker.sock:/tmp/docker.sock \
-v /var/run/docker.sock:/var/run/docker.sock \
"blinkreaction/nginx-proxy:${DRUDE_ITAG}" >/dev/null 2>&1
}

Expand Down Expand Up @@ -931,9 +909,14 @@ install_ubuntu ()
fi

echo-green "Installing Docker..."
sudo service docker stop && \
curl -sSL https://get.docker.com/ | sh && \
sudo usermod -aG docker $(whoami)
# Stop docker dervice if it exists
if sudo service docker status 2>/dev/null; then
echo "Stopping docker service..."
sudo service docker stop 2>/dev/null
fi
curl -sSL https://get.docker.com/ | sh && \
sudo usermod -aG docker $(whoami)
sudo service docker start 2>/dev/null
sudo docker version
if_failed "Docker installation/upgrade has failed."

Expand Down Expand Up @@ -1241,7 +1224,7 @@ check_for_updates ()
_bash ()
{
# Interactive shell requires a tty.
# On Windows we assume we run interactively via winpty (console.exe).
# On Windows we assume we run interactively via winpty.
if ! is_tty; then
echo "Interactive bash console in a non-interactive enveronment!? Nope, won't happen."
return 1
Expand All @@ -1264,10 +1247,8 @@ _run ()
local winpty_cmd
# Running docker exec interactively on Windows requires workarounds
if is_windows; then
# Workaround - run docker exec via winpty (console.exe) to get a tty console in cygwin.
if is_binary_found 'console'; then
winpty_cmd='console'
elif is_binary_found 'winpty'; then
# Workaround - run docker exec via winpty to get a tty console in cygwin.
if is_binary_found 'winpty'; then
winpty_cmd='winpty'
else
echo-red 'Winpty binary is missing.'
Expand Down
2 changes: 1 addition & 1 deletion bin/dsh-bash-complete
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _dsh_completion()
{
local cur=${COMP_WORDS[COMP_CWORD]} #current word part
local prev=${COMP_WORDS[COMP_CWORD-1]} #previous word
local compwords=$(dsh bash_comp_words $prev) #get completions for previos word
local compwords=$(dsh bash_comp_words $prev) #get completions for previous word
if [ ! $? -eq 0 ]; then
return 1;
else
Expand Down
49 changes: 49 additions & 0 deletions docs/behat.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ Open *Run/Debug Configurations* (menu item *Run->Edit Configurations...*). In th

Choose Test Runner option *Defined in the configuration file*.

Or you can choose `behat.yml` from your host machine (use *File* option in this case). It makes no difference.

### Run tests

On the PhpStorm panel choose Behat debug configuration and run it:
Expand All @@ -226,6 +228,37 @@ run any feature tests by right clicking on it and choosing **Run 'feature-name'*

![](img/behat-test-features.png)

#### Known issue
On this step you can see an error:

> [PDOException]
> SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

In this case check Drupal `settings.php`. Please don't use variables for DB settings:
```PHP
# Drude DB connection settings.
$databases['default']['default'] = array (
'database' => getenv('DB_1_ENV_MYSQL_DATABASE'),
'username' => getenv('DB_1_ENV_MYSQL_USER'),
'password' => getenv('DB_1_ENV_MYSQL_PASSWORD'),
'host' => getenv('DB_1_PORT_3306_TCP_ADDR'),
'driver' => 'mysql',
);
```

Use only values - something like this:

```PHP
# Drude DB connection settings.
$databases['default']['default'] = array (
'database' => 'drupal',
'username' => 'drupal',
'password' => '123',
'host' => 'db',
'driver' => 'mysql',
);
```

## Using host selenium2-driver

You can use selenium from your host machine instead of the selenium in a container.
Expand Down Expand Up @@ -256,3 +289,19 @@ default:
```

`192.168.10.1` is your machine's IP in Drude subnet.

If you use host selinium driver, please don't use selenium2 node - check and comment `browser` container config in your docker-compose.yml file:

```yml
# selenium2 node
# Uncomment the service definition section below and the link in the web service above to start using selenium2 driver for Behat tests requiring JS support.
#browser:
# hostname: browser
# image: selenium/standalone-chrome
# ports:
# - "4444"
# environment:
# - DOMAIN_NAME=drude-d7-testing.browser.docker
```

If you use host selinium driver and selenium from docker container, behat will use configuration from `docker:` part of `behat.common.yml` instead of `default:` part in `behat.yml`. And it will not work.
45 changes: 45 additions & 0 deletions docs/blackfire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Using Blackfire profiler

## Setup

1. Register with https://blackfire.io.

2. Add `blackfire` service in `docker-compose.yml` and configure API keys:

**Option 1:** Use [Blackfire Docker instructions](https://blackfire.io/docs/integrations/docker) to get a snippet that you can put in a `.bash_rc`/etc. file globally. Uncomment respective lines in `docker-compose.yml`.

**Option 2:** Grab **server** API keys from your [profile page](https://blackfire.io/account).
Uncomment respective lines in `docker-compose.yml` and replace `Server ID` and `Server Token` with your API keys.

```yml
blackfire:
image: blackfire/blackfire
environment:
# Option 1: exposes host's BLACKFIRE_SERVER_ID and TOKEN environment variables.
#- BLACKFIRE_SERVER_ID
#- BLACKFIRE_SERVER_TOKEN
# Option 2: use global environment credentials.
#- BLACKFIRE_SERVER_ID=<Server ID>
#- BLACKFIRE_SERVER_TOKEN=<Server Token>
# Log verbosity level (4: debug, 3: info, 2: warning, 1: error).
#- BLACKFIRE_LOG_LEVEL=4
```

3. For `docker-compose.yml` files using version 1:

Note: if you do not see `version: 2` in the beginning of your `docker-compose.yml` file, then proceed.
Add a link in the `cli` service definition:

```yml
...
links:
...
- blackfire
...
```

4. Apply new configuration with `dsh up`

5. Follow instruction to install and use blackfire via a [Chrome extension](https://blackfire.io/docs/integrations/chrome).

See [blackfire.io](https://blackfire.io/docs/introduction) for more docs on using blackfire including support for other browsers.
19 changes: 7 additions & 12 deletions docs/mail.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,20 @@ Sending/capturing email support can be added via [MailHog](https://github.com/ma
Apply new configuration with `dsh up`
2. Install and configure sSMPT in `cli`
2. Add to `.drude/etc/php5/php.ini` in the project repo
Replace `<project_name>` with your project name.
```
dsh exec "sudo apt-get update && sudo apt-get install ssmtp -y"
dsh exec "sudo sed -i -e '/mailhub=/c mailhub=mail.<project_name>.docker:1025' -e '/#FromLineOverride=/c FromLineOverride=YES' /etc/ssmtp/ssmtp.conf"
; Mail settings
sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr=mail.<project_name>.docker:1025'
```
3. Configure `sendmail_path` in `php.ini`
Add to `.drude/etc/php5/php.ini` in the project repo
Note: if using `version 2` docker-compose file format, then you may use this instead
```
; Mail settings
sendmail_path = "/usr/sbin/ssmtp -t"
sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr=mail:1025'
```
MailHog web UI will be available at `http://webmail.<project_name>.drude`
These instructions are temporary. Tread them as a POC for using MailHog with Drude.
Steps 2 has to be performed any time the cli container gets reconfigured, updated or reset.
Loading

0 comments on commit 8ae732e

Please sign in to comment.