Add all files needed to bring up VM and run agaric.com locally
This commit is contained in:
parent
52c8b60bac
commit
4d2bc0ee24
742 changed files with 24037 additions and 0 deletions
60
box/provisioning/docker/bake.sh
Executable file
60
box/provisioning/docker/bake.sh
Executable file
|
@ -0,0 +1,60 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Bake a Docker container with Drupal VM.
|
||||
|
||||
# Exit on any individual command failure.
|
||||
set -e
|
||||
|
||||
# Set variables.
|
||||
DRUPALVM_IP_ADDRESS="${DRUPALVM_IP_ADDRESS:-192.168.89.89}"
|
||||
DRUPALVM_MACHINE_NAME="${DRUPALVM_MACHINE_NAME:-drupal-vm}"
|
||||
DRUPALVM_HOSTNAME="${DRUPALVM_HOSTNAME:-localhost}"
|
||||
DRUPALVM_PROJECT_ROOT="${DRUPALVM_PROJECT_ROOT:-/var/www/drupalvm}"
|
||||
|
||||
DRUPALVM_HTTP_PORT="${DRUPALVM_HTTP_PORT:-80}"
|
||||
DRUPALVM_HTTPS_PORT="${DRUPALVM_HTTPS_PORT:-443}"
|
||||
|
||||
DISTRO="${DISTRO:-ubuntu1604}"
|
||||
OPTS="${OPTS:---privileged}"
|
||||
INIT="${INIT:-/lib/systemd/systemd}"
|
||||
|
||||
# Helper function to colorize statuses.
|
||||
function status() {
|
||||
status=$1
|
||||
printf "\n"
|
||||
echo -e -n "\033[32m$status"
|
||||
echo -e '\033[0m'
|
||||
}
|
||||
|
||||
# Set volume options.
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
volume_opts='rw,cached'
|
||||
else
|
||||
volume_opts='rw'
|
||||
fi
|
||||
|
||||
# Run the container.
|
||||
status "Bringing up Docker container..."
|
||||
docker run --name=$DRUPALVM_MACHINE_NAME -d \
|
||||
--add-host "$DRUPALVM_HOSTNAME drupalvm":127.0.0.1 \
|
||||
-v $PWD:$DRUPALVM_PROJECT_ROOT/:$volume_opts \
|
||||
-p $DRUPALVM_IP_ADDRESS:$DRUPALVM_HTTP_PORT:80 \
|
||||
-p $DRUPALVM_IP_ADDRESS:$DRUPALVM_HTTPS_PORT:443 \
|
||||
$OPTS \
|
||||
geerlingguy/docker-$DISTRO-ansible:latest \
|
||||
$INIT
|
||||
|
||||
# Create Drupal directory.
|
||||
docker exec $DRUPALVM_MACHINE_NAME mkdir -p $DRUPALVM_PROJECT_ROOT/drupal
|
||||
|
||||
# Set things up and run the Ansible playbook.
|
||||
status "Running setup playbook..."
|
||||
docker exec --tty $DRUPALVM_MACHINE_NAME env TERM=xterm \
|
||||
ansible-playbook $DRUPALVM_PROJECT_ROOT/tests/test-setup.yml
|
||||
|
||||
status "Provisioning Drupal VM inside Docker container..."
|
||||
docker exec $DRUPALVM_MACHINE_NAME env TERM=xterm ANSIBLE_FORCE_COLOR=true \
|
||||
ansible-playbook $DRUPALVM_PROJECT_ROOT/provisioning/playbook.yml
|
||||
|
||||
status "...done!"
|
||||
status "Visit the Drupal VM dashboard: http://$DRUPALVM_IP_ADDRESS:$DRUPALVM_HTTP_PORT"
|
33
box/provisioning/docker/bin/install-drupal
Executable file
33
box/provisioning/docker/bin/install-drupal
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Install a Drupal site with Drush.
|
||||
#
|
||||
# Usage:
|
||||
# install-drupal [version]
|
||||
# [version] is optional, defaults to 8.4.x. Try 7.x, 7.55, 8.5.x, 8.3.2, etc.
|
||||
|
||||
# Exit on any individual command failure.
|
||||
set -e
|
||||
|
||||
# Setup.
|
||||
DRUPAL_VERSION="${1:-8.4.x}"
|
||||
PROJECT_PATH='/var/www/drupalvm/drupal'
|
||||
|
||||
# Create Drupal project directory.
|
||||
mkdir -p $PROJECT_PATH
|
||||
|
||||
# Download Drupal with Drush.
|
||||
echo "Downloading Drupal $DRUPAL_VERSION"
|
||||
drush dl drupal-$DRUPAL_VERSION \
|
||||
--destination=$PROJECT_PATH \
|
||||
--drupal-project-rename=web
|
||||
|
||||
# Install Drupal with Drush.
|
||||
echo "Installing Drupal"
|
||||
drush si standard --root=$PROJECT_PATH/web -y \
|
||||
--db-url='mysql://drupal:drupal@localhost/drupal' \
|
||||
--site-name='Drupal VM' \
|
||||
--account-name=admin --account-pass=admin
|
||||
|
||||
# Set appropriate permissions.
|
||||
chown -R www-data:www-data $PROJECT_PATH
|
38
box/provisioning/docker/load-image.sh
Executable file
38
box/provisioning/docker/load-image.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Load a Docker image from an archive (tar).
|
||||
#
|
||||
# Required configuration (in config.yml):
|
||||
#
|
||||
# docker_image_name: drupal-vm
|
||||
# docker_image_path: ~/Downloads
|
||||
#
|
||||
|
||||
# Exit on any individual command failure.
|
||||
set -e
|
||||
|
||||
# Include YAML parser.
|
||||
source provisioning/docker/parse-yaml.sh
|
||||
|
||||
# Pretty colors.
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
neutral='\033[0m'
|
||||
|
||||
# Set variables, read from config.yml if available.
|
||||
# TODO: This could definitely be more intelligent!
|
||||
if [ -f 'config.yml' ]; then
|
||||
image_name=$(parse_yaml config.yml docker_image_name)
|
||||
image_path=$(parse_yaml config.yml docker_image_path)
|
||||
else
|
||||
image_name=$(parse_yaml default.config.yml docker_image_name)
|
||||
image_path=$(parse_yaml default.config.yml docker_image_path)
|
||||
fi
|
||||
|
||||
image_full_path="$image_path/$image_name.tar.gz"
|
||||
image_full_path=${image_full_path/#\~/$HOME} # Expand ~ to $HOME.
|
||||
|
||||
# Load the image.
|
||||
printf "\n"${green}"Loading Docker image..."${neutral}"\n"
|
||||
gunzip -c $image_full_path | docker load
|
||||
printf ${green}"...done!"${neutral}"\n"
|
14
box/provisioning/docker/parse-yaml.sh
Executable file
14
box/provisioning/docker/parse-yaml.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Parse a YAML file.
|
||||
#
|
||||
# Usage:
|
||||
# parse_yaml [file-path] [variable-to-retrieve]
|
||||
#
|
||||
# Requires ruby.
|
||||
# @see https://coderwall.com/p/bm_tpa/reading-yaml-files-in-bash-with-ruby
|
||||
# @todo Consider using PHP so user doesn't need to install Ruby.
|
||||
|
||||
function parse_yaml {
|
||||
ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
|
||||
}
|
42
box/provisioning/docker/save-image.sh
Executable file
42
box/provisioning/docker/save-image.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Commit a Docker image and save it to an archive (tar).
|
||||
#
|
||||
# Required configuration (in config.yml):
|
||||
#
|
||||
# docker_container_name: drupal-vm
|
||||
# docker_image_name: drupal-vm
|
||||
# docker_image_path: ~/Downloads
|
||||
#
|
||||
|
||||
# Exit on any individual command failure.
|
||||
set -e
|
||||
|
||||
# Include YAML parser.
|
||||
source provisioning/docker/parse-yaml.sh
|
||||
|
||||
# Pretty colors.
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
neutral='\033[0m'
|
||||
|
||||
# Set variables, read from config.yml if available.
|
||||
# TODO: This could definitely be more intelligent!
|
||||
if [ -f 'config.yml' ]; then
|
||||
container_name=$(parse_yaml config.yml docker_container_name)
|
||||
image_name=$(parse_yaml config.yml docker_image_name)
|
||||
image_path=$(parse_yaml config.yml docker_image_path)
|
||||
else
|
||||
container_name=$(parse_yaml default.config.yml docker_container_name)
|
||||
image_name=$(parse_yaml default.config.yml docker_image_name)
|
||||
image_path=$(parse_yaml default.config.yml docker_image_path)
|
||||
fi
|
||||
|
||||
image_full_path="$image_path/$image_name.tar.gz"
|
||||
image_full_path="${image_full_path/#\~/$HOME}" # Expand ~ to $HOME.
|
||||
|
||||
# Save the image.
|
||||
printf "\n"${green}"Saving Docker container to $image_full_path..."${neutral}"\n"
|
||||
docker commit $container_name $image_name
|
||||
docker save $image_name | gzip -1 > $image_full_path
|
||||
printf ${green}"...done!"${neutral}"\n"
|
15
box/provisioning/docker/vars/docker-hub-overrides.yml
Normal file
15
box/provisioning/docker/vars/docker-hub-overrides.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
hostname_configure: false
|
||||
firewall_enabled: false
|
||||
installed_extras:
|
||||
- adminer
|
||||
- drush
|
||||
- mailhog
|
||||
- pimpmylog
|
||||
# - varnish
|
||||
|
||||
# Don't build or install Drupal inside the container.
|
||||
drupal_build_makefile: false
|
||||
drupal_build_composer: false
|
||||
drupal_build_composer_project: false
|
||||
drupal_install_site: false
|
Loading…
Add table
Add a link
Reference in a new issue