Skip to content

Instantly share code, notes, and snippets.

@beeradb
Last active March 7, 2017 01:00
Show Gist options
  • Save beeradb/e67995bed62f8d9b823c2bc89caac6ea to your computer and use it in GitHub Desktop.
Save beeradb/e67995bed62f8d9b823c2bc89caac6ea to your computer and use it in GitHub Desktop.
ddev local plugin outline

Creating a fresh ddev site without a local import

Check out the git repository and config a ddev site.

$ cd ~/Projects
$ git clone <git-url>/drud-d8.git
$ cd drud-d8 
$ ddev config
Name (drud-d8):
Type [drupal7, drupal8, wordpress]: drupal8
Docroot location: src

Your ddev configuration has been written to .ddev/config.yaml

Inspect contents of ddev.yaml and ddev-compose.yaml

$ pwd
/Users/username/Projects/drud-d8

$ # Renamed to config.yaml to avoid stuttering.
$ cat .ddev/config.yaml
---
version: 1
name: drud-d8
type: drupal8
docroot: src
webimage: drud/nginx-php-fpm7:0.1.0
dbimage: drud/mysql-local:5.6-0.1.0

$ # ddev-compose would use env vars to populate container names, as to preserve any user customizations.
$ cat .ddev/ddev-compose.yaml
version: '2'
services:
  drud-d8-db:
    container_name: drud-d8-db
    image: $DRUD_DBIMAGE
    volumes:
      - "./data:/db"
    restart: always
    environment:
      MYSQL_DATABASE: data
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "3306"
  drud-d8-web:
    container_name: drud-d8-web
    image: $DRUD_WEBIMAGE
    volumes:
      - "./src:/var/www/html"
    restart: always
    depends_on:
      - drud-d8-db
    links:
      - drud-d8-db:db
    ports:
      - "80"
      - "8025"
    working_dir: "/var/www/html/docroot"
    environment:
      # I'm pretty sure we don't actually need DEPLOY_NAME here, but I've left it in case existing containers may rely on it.
      - DEPLOY_NAME=local
      - VIRTUAL_HOST=drud-d8.ddev.local
networks:
  default:
    external:
      name: ddev_default

Reconfigure an existing site

$ pwd
/Users/username/Projects/drud-d8

$ ddev config
Existing configuration detected. Using defaults from /Users/username/Projects/drud-d8/.ddev/config.yaml

Name (drud-d8):
Type [drupal7, drupal8, wordpress] (drupal8):
Docroot location (src): src

Your ddev configuration has been written to .ddev/config.yaml

Deal with bad configuration file.

$ pwd
/Users/username/Projects/drud-d8

$ ddev config
Existing configuration exists at /Users/username/Projects/drud-d8/.ddev/config.yaml but cannot be read. Please delete the file and re-run "ddev config".

Start Site

$ ddev start

Successfully added drud-d8
Your application can be reached at: http://drud-d8.ddev.local
You can run "ddev describe" to get additional information about your site, such as database credentials.

List Sites

$ ddev list
1 site found.
NAME      	DOCROOT	                                TYPE  	URL                                	STATUS
drud-d8   	/Users/username/Projects/drud-d8/src 	drupal8	http://drud-d8.ddev.local   		running

Describe View

Global describe with sitename argument

$ pwd
/Users/username
$ ddev describe drud-d8

NAME      	DOCROOT	                                TYPE  	URL                                	STATUS
drud-d8   	/Users/username/Projects/drud-d8/src 	drupal8	http://drud-d8.ddev.local   		running

MySQL Credentials
-----------------
Username:     	root
Password:     	root
Database name:	data

Other Services
--------------
MailHog:    	http://drud-d8.ddev.local:8025
PHPMyAdmin: 	http://drud-d8.ddev.local:8026

From within the working directory

$ pwd
/Users/username/Projects/drud-d8
$ ddev describe

NAME        DOCROOT                                 TYPE    URL                                 STATUS
drud-d8     /Users/username/Projects/drud-d8/src 	drupal8 http://drud-d8.ddev.local       running

MySQL Credentials
-----------------
Username:     	root
Password:     	root
Database name:	data

Other Services
--------------
MailHog:      http://drud-d8.ddev.local:8025
PHPMyAdmin:   http://drud-d8.ddev.local:8026

Pull in data from an external source

Generate Import config

$ pwd
/Users/username/Projects/drud-d8

$ ddev import
No import configuration found, would you like to create one? (y/N): y
# This list gets defined by plugins
Import Source (local, pantheon, s3): pantheon

# Everything below here is defined by a plugin.
You have the following sites, please choose one to import from.

Selection 	NAME          	ID
1         	techingyouout 	test
2         	techingyouout 	dev
3         	techingyouout 	live

Please select the import source [1-3]: 2
Please select the import destination directory [data]: data

Import config written to ddev.yaml

Would you like to import now? (y/N): y
Getting Resources......
Importing Data.........
Import successful. Your application can be reached at: http://drud-d8.ddev.local

Inspect import config

$ cat ddev.yaml
---
name: drud-d8
type: drupal8
docroot: src
webimage: drud/nginx-php-fpm7:0.1.0
dbimage: drud/mysql-local:5.6-0.1.0
import-config:
	platform: pantheon
	sitename: techingyouout
	site-id: dev
	destination-dir: data

Import again

Thoughts: this could be used between feature branches, or just periodically as needed by developers.

$ pwd
/Users/username/Projects/drud-d8/src/modules

$ ddev import

SOURCE   	NAME          	ID
pantheon 	techingyouout 	dev

Local data and file assets will be overwritten if you choose to continue. Perform import now (y/N)? y
Getting Resources......
Importing Data.........
Import successful. Your application can be reached at: http://drud-d8.ddev.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment