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 #81 from blinkreaction/develop
Browse files Browse the repository at this point in the history
Release v1.2.4
  • Loading branch information
Leonid Makarov committed Jan 20, 2016
2 parents ddecba7 + 364ff27 commit 6503725
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 135 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 1.2.4 (2016-01-20)

- Bump dsh to v1.10.3
- Fixed "tput: No value for $TERM and no -T specified" in noninteractive (CI) environments
- Fixed "Error response from daemon: no such id: bash" on Windows
- Restructured and updated docs with setup instructions per use case

## 1.2.3 (2015-12-04)

- Bump dsh to v1.9.3
- Fix in _set_cli_uid for non-interactive sessions

## 1.2.2 (2015-12-04)

- Fix a really tiny typo in the README.
- Bump dsh to v1.9.2
- Fix DRUDE_SET_UID usage (experimental) when combined with DRUDE_DC_PROJECT.

## 1.2.1 (2015-11-17)

- Droped /cygdrive prefix on Windows
Expand Down
130 changes: 35 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,118 +3,51 @@
Docker and Docker Compose based environment for Drupal.

**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)
- [Drupal 7 sample project](https://github.com/blinkreaction/drude-d7-testing)
- [Drupal 8 sample project](https://github.com/blinkreaction/drude-d8-testing)


## System requirements

Please review [system requirements](docs/system-requirements.md) before proceeding with the setup.
Please review [system requirements](/docs/system-requirements.md) before proceeding with the setup.


<a name="setup"></a>
## Setup

Initial configuration is done once per project (e.g. by a team lead) and committed into the project repo.
`docker-compose.yml` file and an optional `.drude` folder are good indicators that a project is using Drude.

Drude expects a particular [directory structure](docs/system-requirements.md). Please review it before proceeding with the setup.

### Step 0: Install Babun (Windows only)

[Babun](http://babun.github.io) is a very nice Linux-type shell for Windows.
Install it as a regular user (do not use admin command prompt).
**Drude is not tested and may not work with any other shell on Windows.**
1. [Drude environment setup](/docs/drude-env-setup.md)

This is done **one time per host** and shoudl be performed by everyone.

### Step 1: Install dsh (Drude Shell Helper)
2. [Configure a project to use Drude](/docs/drude-project-setup.md)

dsh will automate the rest of the setup steps and will be used to control a Drude powered environment.
This is done **one time per project** and should be performed by the the project TL.

sudo curl -L https://raw.githubusercontent.com/blinkreaction/drude/master/bin/dsh -o /usr/local/bin/dsh
sudo chmod +x /usr/local/bin/dsh
3. [Initialize a Drude powered project](/docs/drude-project-init.md)

dsh works and is supported on Mac, Windows (in Babun shell), Linux and [boot2docker-vagrant](https://github.com/blinkreaction/boot2docker-vagrant).
Follow these instructions to initiallize a Drude powered project.

### Step 2: Mac

1. Edit `settings.php` for your site (see [Drupal settings](#drupal-settings) below).
2. Open Terminal and cd into `<projects/your-drupal-site>`

2.1) If you have never used Drude before run:
```
dsh install
```
This will install/update all required prerequisites: [Homebrew](http://brew.sh/), [Homebrew-cask](https://github.com/caskroom/homebrew-cask), VirtualBox, Vagrant, docker, docker-compose.
2.2) If you are already using Drude on other projects and just need to initialize a new one run:
```
dsh install drude
```
This will ony download latest `docker-compose.yml` with default containers' settings.
3. Start VM and containers with `dsh up`
<a name="updates"></a>
## Updates

### Step 2: Windows
1. Updating dsh. It is recommended to **always update dsh before updating Drude**
as new version of dsh may contain changes or improvements to the update process. Anywhere run:

1. Make sure your `projects` folder is **not** inside `%USERPROFILE%/.babun` installation folder.
2. Edit `settings.php` for your site (see [Drupal settings](#drupal-settings) below).
3. **In Babun shell** cd into `<projects/your-drupal-site>`
3.1) If you have never used Drude before run:
```
dsh install
```
This will install/update all required prerequisites: [Chocolatey](https://chocolatey.org/), VirtualBox, Vagrant, docker, docker-compose.
3.2) If you are already using Drude on other projects and just need to initialize a new one run:
```
dsh install drude
dsh self-update
```
This will ony download latest `docker-compose.yml` with default containers' settings.
4. Start VM and containers with `dsh up`
### Step 2: Linux

1. [Install Docker](https://docs.docker.com/compose/install/#install-docker)
2. [Install Docker Compose](https://docs.docker.com/compose/install/#install-compose)
3. Edit `settings.php` for the site (see [Drupal settings](#drupal-settings) below).
4. If you don't have your `docker-compose.yml` and would like to initialize a new Drude project cd `<projects/your-drupal-site>` and run:
2. Updating Drude. Run the following from the `<projects/your-drupal-site>` folder:

```
dsh install drude
dsh update
```
This will ony download latest `docker-compose.yml` with default containers' settings.
5. Start containers with `dsh up`
<a name="updates"></a>
## Updates
1. Updating Dsh. It **recommended to always update Dsh before updating Drude** as new version of Dsh may contain changes or improvements to update process. Anywhere run
dsh self-update
2. Updating Drude. Run the following from the `<projects/your-drupal-site>` folder:
dsh update
**Note**: if docker image for database container was updated then container will be re-created and you will need to _re-import your database._
**Note**: if the docker image for the database container was updated then the container will be re-created and you will need to _re-import your database._
**Note Windows and Mac users:** if boot2docker VM image was updated then update will warn you that VM will be re-created. It means you will have to _re-import your databases._
<a name="drupal-settings"></a>
## Drupal settings
Below you will find instructions on configuring you Drupal project to work with Drude.
Some settings are required, others are optional or enahncements. Please review carefully.
**Required**
- [DB connection settings](docs/drupal-settings.md#db)
- [File permissions fix](docs/drupal-settings.md#file-permissions)
**Optional**
- [Memcache settings](docs/drupal-settings.md#memcache)
<a name="dsh"></a>
## Drude Shell Helper (dsh)
Expand All @@ -127,13 +60,16 @@ See `dsh help` for a complete list.
`dsh` detects the environment it's launched in and will automatically start the boot2docker VM and launch containers as necessary.
It runs on Mac/Linux directly. On Windows `dsh` runs inside the Babun Shell.
<a name="cli"></a>
## Console tools (cli)
**cli** container is meant to serve as a single console to access all necessary command line tools.
The **cli** container is meant to serve as a single console to access all necessary command line tools.
You can access **cli** container's console with `dsh`:
dsh bash
```
dsh bash
```
Tools available inside the **cli** container:
Expand All @@ -143,21 +79,25 @@ Tools available inside the **cli** container:
- git, wget, zip, mysql-client
- python
<a name="instructions"></a>
## Instructions and tutorials
- [Running multiple projects](docs/multiple-projects.md)
- [Overriding default PHP/MySQL/etc. settings](docs/settings.md)
- [Public access](docs/public-access.md)
- [DB sandbox mode](docs/db-sandbox.md)
- [Using Behat](docs/behat.md)
- [Zero-configuration Debugging with Xdebug and PhpStorm](docs/xdebug.md)
- [MySQL DB access for external tools](docs/db-access.md)
- [Drupal settings](/docs/drupal-settings.md)
- [Running multiple projects](/docs/multiple-projects.md)
- [Overriding default PHP/MySQL/etc. settings](/docs/settings.md)
- [Public access](/docs/public-access.md)
- [DB sandbox mode](/docs/db-sandbox.md)
- [Using Behat](/docs/behat.md)
- [Zero-configuration Debugging with Xdebug and PhpStorm](/docs/xdebug.md)
- [MySQL DB access for external tools](/docs/db-access.md)
<a name="troubleshooting"></a>
## Troubleshooting
See [Troubleshooting](docs/troubleshooting.md) section of the docs.
See [Troubleshooting](/docs/troubleshooting.md) section of the docs.
## License
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.1
1.2.4
54 changes: 30 additions & 24 deletions bin/dsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

DSH_VERSION=1.9.3
DSH_VERSION=1.10.3

help ()
{
Expand Down Expand Up @@ -83,12 +83,21 @@ fi
# Check whether shell is interactive (otherwise we are running in a non-interactive script environment)
is_tty ()
{
# Override option via $DRUDE_IS_TTY (true|false) env variable.
if [[ $DRUDE_IS_TTY == 'true' ]]; then
return 0;
fi
if [[ $DRUDE_IS_TTY == 'false' ]]; then
return 1;
fi

# disable interactive shell on windows for now
# known Docker issue: https://github.com/docker/docker/issues/12469
res=$(uname | grep 'CYGWIN_NT')
if [[ "$res" != '' ]]; then
return 1;
fi

[[ "$(/usr/bin/tty || true)" != "not a tty" ]]
}

Expand All @@ -101,15 +110,7 @@ testing_warn ()
}

#---------------- Docker Compose Global Settings ----------------------
DC_FILE=''
DC_PROJECT=''
DEFAULT_DOCKER_HOST='tcp://192.168.10.10:2375'
if [[ ! $DRUDE_DC_FILE == "" ]]; then
DC_FILE="-f $DRUDE_DC_FILE"
fi
if [[ ! $DRUDE_DC_PROJECT == "" ]]; then
DC_PROJECT="-p $DRUDE_DC_PROJECT"
fi

# Display dsh version
# @option --short - Display only the version number
Expand All @@ -123,11 +124,11 @@ version ()
fi
}

# Pass global project and file settings to docker-compose.
# Use this function for every docker-compose invocation.
docker_compose ()
{
docker-compose $DC_FILE $DC_PROJECT $*
# Trim CR(\r) from the output, otherwise there will be issues passing it to the docker binary on Windows.
docker-compose $* | tr -d '\r'
}

#-------------------------- Helper functions --------------------------------
Expand Down Expand Up @@ -230,11 +231,11 @@ clean_string ()
echo ${cleaned}
}

# get mysql connection string
# Get mysql connection string
get_mysql_connect ()
{
# get connection string and cleanup residue that is leftover
echo $(clean_string "$(_run drush sql-connect)")
# Run drush forcing tty to false to avoid colored output string from drush.
echo "$(DRUDE_IS_TTY=false _run drush sql-connect)"
}

#----------------------- Basics check functions -----------------------------
Expand Down Expand Up @@ -711,10 +712,10 @@ install_boot2docker ()
install_drude ()
{
testing_warn
docker_compose=$(curl -kfsS "https://raw.githubusercontent.com/blinkreaction/drude/$DRUDE_BRANCH/docker-compose.yml")
docker_compose_yml=$(curl -kfsS "https://raw.githubusercontent.com/blinkreaction/drude/$DRUDE_BRANCH/docker-compose.yml")
if_failed "Could not get latest docker-compose.yml version."

echo "$docker_compose" | tee "docker-compose.yml" >/dev/null
echo "$docker_compose_yml" | tee "docker-compose.yml" >/dev/null
if_failed "Could not write to docker-compose.yml"
echo-green "Latest version of docker-compose.yml was downloaded."
}
Expand Down Expand Up @@ -892,7 +893,7 @@ _bash ()
container_name="$1"
fi
local container_id
container_id='$(docker_compose ps -q '$container_name')';
container_id=$(docker_compose ps -q $container_name);
# Drop /cygdrive prefix if the working directory is opened as /cygdrive/<driveletter>/.. instead of /<driveletter>..
cwd=$(pwd); cwd=${cwd#/cygdrive}
command="cd $cwd && docker exec -it $container_id bash -i";
Expand All @@ -914,19 +915,19 @@ _bash ()
container_name="$1"
fi
local container_id
container_id=$(clean_string $(docker_compose ps -q $container_name))
container_id=$(docker_compose ps -q $container_name)
docker exec -it $container_id bash -i
fi
}

# Run a command in container in project root
# param $* command with it's params to run
# Run a command in the cli container in the project root
# @param $* command with it's params to run
run ()
{
if is_docker && is_docker_compose ; then
check_docker_running
cd $(yml_get_path)
container_id=$(clean_string $(docker_compose ps -q cli))
container_id=$(docker_compose ps -q cli)

if is_tty ; then
# need to use $* here to finally resolve slash-escaped string if any.
Expand All @@ -938,11 +939,16 @@ run ()
fi
}

# Run a command in container changing dir to the same folder
# param $* command with it's params to run
# Run a command in the cli container changing dir to the same folder
# @param $* command with it's params to run
_run ()
{
local COLS=$(tput cols) #get client window width
#get client window width for interactive sessions
local COLS=''
if is_tty ; then
COLS=$(tput cols)
fi

if is_yml_absent ; then return 2; fi
if is_docker && is_docker_compose ; then
local path=$(get_current_relative_path)
Expand Down
8 changes: 4 additions & 4 deletions docs/directory-structure.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Directory structure

Drude enforces a directory structure where you have an arbitrary located and named `projects` folder.
All you projects go into subfolders under the `projects` folder.
All your projects go into subfolders under the `projects` folder.

dsh will install necessary boot2docker-vagrant VM files (`Vagrantfile` and `vagrant.yml`) into the `projects` folder.
`dsh` will install the necessary boot2docker-vagrant VM files (`Vagrantfile` and `vagrant.yml`) into the `projects` folder.

```
+ ...
- projects
|--- your-drupal-site
|--- drupal-site
| docker-compose.yml
| docroot
| ...
|
|--- your-another-drupal-site
|--- another-drupal-site
| .drude
| docker-compose.yml
| docroot
Expand Down
Loading

0 comments on commit 6503725

Please sign in to comment.