Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/.vagrant/
/vendor/

/composer.lock
16 changes: 16 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.define "replicator-dev"
config.vm.hostname = "replicator"
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant", create: true, mount_options: ["dmode=777,fmode=777"]

# Get rid of ubuntu-xenial-16.04-cloudimg-console.log
config.vm.provider "virtualbox" do |vb|
vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
end

# Provision the box.
config.vm.provision :shell, privileged: false, path: "./scripts/vagrant/provision.sh"
config.vm.provision :shell, privileged: false, path: "./scripts/vagrant/up.sh", run: "always"
end
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@
"require-dev": {
"squizlabs/php_codesniffer": "^3.3",
"phpcompatibility/php-compatibility": "^8.2",
"wp-coding-standards/wpcs": "^1.0"
"wp-coding-standards/wpcs": "^1.0",
"johnpbloch/wordpress": "^4.9"
},
"scripts": {
"wpcs": [
"vendor/bin/phpcs src"
],
"wp": [
"./scripts/vagrant/wp-cli.sh"
]
},
"extra": {
"wordpress-install-dir": "docker/data/www/wp"
}
}
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'

services:

mysql:
image: mysql:5
volumes:
- "./docker/data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: password

phpfpm:
image: 10up/phpfpm
depends_on:
- mysql
volumes:
- ".:/var/www/html/wp-cli-replicator"
- "./docker/data/www:/var/www/html"
- "./docker/config/php-fpm/php.ini:/usr/local/etc/php/php.ini"
restart: always
7 changes: 7 additions & 0 deletions docker/config/php-fpm/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Custom PHP settings

upload_max_filesize = 100M
post_max_size = 100M

[mail function]
sendmail_path = /usr/sbin/ssmtp -t
3 changes: 3 additions & 0 deletions docker/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!/www
!.gitignore
1 change: 1 addition & 0 deletions docker/data/www/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/wp/
40 changes: 40 additions & 0 deletions scripts/vagrant/provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -e

# Always land in the synced directory. Should we change the home directory instead?
echo "cd /vagrant" >> ~/.bashrc

# Map wp to wp-cli inside the container.
sudo ln -s /vagrant/scripts/vagrant/wp-cmd.sh /usr/local/bin/wp

# Map binary name to source URL.
REPOS=(
"docker-compose,https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m`"
"composer,https://getcomposer.org/download/1.7.2/composer.phar"
)

# Add Docker repo.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get update
sudo apt-get install -y \
docker-ce avahi-daemon zip unzip php-cli php-curl php-dom php-zip php-zip

# Ensure we can run docker commands without extra permissions.
sudo usermod -a -G docker "$USER"

# Install various binary scripts.
for repo_set in "${REPOS[@]}"; do
while IFS=',' read -ra repo; do
dest_path="/usr/local/bin/${repo[0]}"

if [ ! -f "$dest_path" ]; then
echo "Installing ${repo[1]} to $dest_path"

sudo curl -sL "${repo[1]}" -o "$dest_path"
sudo chmod +x "$dest_path"
fi
done <<< "$repo_set"
done
9 changes: 9 additions & 0 deletions scripts/vagrant/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# TODO Remove sudo once we figure out how to reload user groups.
sudo docker-compose -f /vagrant/docker-compose.yml up --detach --remove-orphans

# Install WordPress.
. /vagrant/scripts/vagrant/wp-install.sh

echo "Environment is ready!"
4 changes: 4 additions & 0 deletions scripts/vagrant/wp-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

# wp is an alias we defined during provision.
vagrant ssh -c "wp ${*:1}"
3 changes: 3 additions & 0 deletions scripts/vagrant/wp-cmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker-compose --file /vagrant/docker-compose.yml exec -T --user www-data phpfpm wp "${@:1}"
6 changes: 6 additions & 0 deletions scripts/vagrant/wp-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

wp core install \
--title="Replicator CLI" \
--admin_user=admin \
[email protected]