From f1bec6aae83a9f4fb38f8104cc0ea7f44ed3816d Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Tue, 31 Jul 2018 15:04:26 +1000 Subject: [PATCH 1/8] Default database credentials to match docker-compose values --- src/Handler.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Handler.php b/src/Handler.php index 128d2ed..f2373f2 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -128,10 +128,10 @@ public function modifySettingsFile() if (!(strpos(file_get_contents($root . '/sites/default/settings.php'), 'START SHEPHERD CONFIG') !== false)) { $shepherdSettings = "\n/**\n * START SHEPHERD CONFIG\n */\n" . "\$databases['default']['default'] = array (\n" . - " 'database' => getenv('DATABASE_NAME'),\n" . - " 'username' => getenv('DATABASE_USER'),\n" . - " 'password' => getenv('DATABASE_PASSWORD_FILE') ? file_get_contents(getenv('DATABASE_PASSWORD_FILE')) : getenv('DATABASE_PASSWORD'),\n" . - " 'host' => getenv('DATABASE_HOST'),\n" . + " 'database' => getenv('DATABASE_NAME') ?: 'drupal',\n" . + " 'username' => getenv('DATABASE_USER') ?: 'user',\n" . + " 'password' => getenv('DATABASE_PASSWORD_FILE') ? file_get_contents(getenv('DATABASE_PASSWORD_FILE')) : 'password',\n" . + " 'host' => getenv('DATABASE_HOST') ?: '127.0.0.1',\n" . " 'port' => getenv('DATABASE_PORT') ?: '3306',\n" . " 'driver' => getenv('DATABASE_DRIVER') ?: 'mysql',\n" . " 'prefix' => getenv('DATABASE_PREFIX') ?: '',\n" . @@ -149,7 +149,7 @@ public function modifySettingsFile() "\$settings['install_profile'] = getenv('SHEPHERD_INSTALL_PROFILE') ?: 'standard';\n" . "if (getenv('REDIS_ENABLED')) {\n" . " \$settings['redis.connection']['interface'] = 'PhpRedis';\n" . - " \$settings['redis.connection']['host'] = getenv('REDIS_HOST') ?: 'redis';\n" . + " \$settings['redis.connection']['host'] = getenv('REDIS_HOST') ?: '127.0.0.1';\n" . " // Always set the fast backend for bootstrap, discover and config, otherwise\n" . " // this gets lost when redis is enabled.\n" . " \$settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast';\n" . From 1a7288ede2592199dd5e0579d33e734e0bb16cfb Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Tue, 31 Jul 2018 15:04:44 +1000 Subject: [PATCH 2/8] Replace config-sync directory with config-export directory --- src/Handler.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Handler.php b/src/Handler.php index f2373f2..98793bf 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -141,8 +141,7 @@ public function modifySettingsFile() "\$settings['file_private_path'] = getenv('PRIVATE_DIR') ?: '/shared/private';\n" . "\$settings['file_temporary_path'] = getenv('TMP_DIR') ?: '/shared/tmp';\n" . "\$settings['hash_salt'] = getenv('HASH_SALT') ?: '" . str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(random_bytes(55))) . "';\n" . - "\$config_directories['sync'] = getenv('CONFIG_SYNC_DIRECTORY') ?: 'sites/default/files/config_".str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(random_bytes(55))) . "/sync';\n" . - "if (! is_dir(\$app_root . '/' . \$config_directories['sync'])) mkdir(\$app_root . '/' . \$config_directories['sync'], 0777, true);\n" . + "\$config_directories['sync'] = getenv('CONFIG_SYNC_DIRECTORY') ?: DRUPAL_ROOT . '/../config-export';\n" . "\$settings['shepherd_site_id'] = getenv('SHEPHERD_SITE_ID');\n" . "\$settings['shepherd_url'] = getenv('SHEPHERD_URL');\n" . "\$settings['shepherd_token'] = getenv('SHEPHERD_TOKEN_FILE') ? file_get_contents(getenv('SHEPHERD_TOKEN_FILE')) : getenv('SHEPHERD_TOKEN');\n\n" . From ed3c18e554b4e7b52a87f11abdc720bea4ee720e Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Tue, 31 Jul 2018 15:24:36 +1000 Subject: [PATCH 3/8] Split docker compose files into linux and mac based solutions. --- docker-compose.linux.yml | 45 ++++++++++++++++++++++++++++++++ docker-compose.osx.yml | 55 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 42 ------------------------------ 3 files changed, 100 insertions(+), 42 deletions(-) create mode 100644 docker-compose.linux.yml create mode 100644 docker-compose.osx.yml delete mode 100644 docker-compose.yml diff --git a/docker-compose.linux.yml b/docker-compose.linux.yml new file mode 100644 index 0000000..048829b --- /dev/null +++ b/docker-compose.linux.yml @@ -0,0 +1,45 @@ +version: '3' +services: + web: + image: uofa/apache2-php7-dev:shepherd + # This makes the container run on the same network stack as your + # workstation. Meaning that you can interact on "localhost". + network_mode: host + environment: + SITE_TITLE: WCMS D8 + SITE_MAIL: site@example.com + SITE_ADMIN_EMAIL: admin@example.com + SITE_ADMIN_USERNAME: admin + SITE_ADMIN_PASSWORD: password + PUBLIC_DIR: /shared/public + HASH_SALT: random-hash + CONFIG_SYNC_DIRECTORY: /shared/private/random-hash/sync + SHEPHERD_SITE_ID: 2 + SHEPHERD_URL: http://shepherd.test + SHEPHERD_TOKEN: super-secret-token + SHEPHERD_INSTALL_PROFILE: ua + REDIS_ENABLED: 1 + SHEPHERD_SECRET_PATH: /code/private + XDEBUG_CONFIG: "remote_host=127.0.0.1" + PHP_IDE_CONFIG: serverName=localhost + volumes: + - .:/code + - ./shared:/shared + - $HOME/.ssh/id_rsa:/root/.ssh/id_rsa + + db: + image: mariadb + network_mode: host + environment: + MYSQL_DATABASE: drupal + MYSQL_USER: user + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: super-secret-password + + mail: + image: mailhog/mailhog + network_mode: host + + redis: + image: redis:alpine + network_mode: host diff --git a/docker-compose.osx.yml b/docker-compose.osx.yml new file mode 100644 index 0000000..a7f70e2 --- /dev/null +++ b/docker-compose.osx.yml @@ -0,0 +1,55 @@ +version: '3' +services: + web: + image: uofa/apache2-php7-dev:shepherd + # You will notice that we are forwarding port which do not belong to PHP. + # We have to declare them here because these "sidecar" services are sharing + # THIS containers network stack. + ports: + - "80:80" + - "3306:3306" + - "8025:8025" + environment: + SITE_TITLE: WCMS D8 + SITE_MAIL: site@example.com + SITE_ADMIN_EMAIL: admin@example.com + SITE_ADMIN_USERNAME: admin + SITE_ADMIN_PASSWORD: password + PUBLIC_DIR: /shared/public + HASH_SALT: random-hash + CONFIG_SYNC_DIRECTORY: /shared/private/random-hash/sync + SHEPHERD_SITE_ID: 2 + SHEPHERD_URL: http://shepherd.test + SHEPHERD_TOKEN: super-secret-token + SHEPHERD_INSTALL_PROFILE: ua + REDIS_ENABLED: 1 + SHEPHERD_SECRET_PATH: /code/private + XDEBUG_CONFIG: "remote_host=docker.for.mac.localhost" + PHP_IDE_CONFIG: serverName=localhost + volumes: + - .:/code + - ./shared:/shared + - $HOME/.ssh/id_rsa:/root/.ssh/id_rsa + + xdebug: + image: nickschuch/d4m-tcp-forwarder + network_mode: host + environment: + - PORT=9000 + + db: + image: mariadb + network_mode: service:web + environment: + MYSQL_DATABASE: drupal + MYSQL_USER: user + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: super-secret-password + + mail: + image: mailhog/mailhog + network_mode: service:web + + redis: + image: redis:alpine + network_mode: service:web diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index a2ae1c5..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: '3' -services: - web: - image: uofa/apache2-php7-dev:shepherd - hostname: ${PROJECT} - environment: - SITE_TITLE: Drupal site - SITE_MAIL: site@example.com - SITE_ADMIN_EMAIL: admin@example.com - SITE_ADMIN_USERNAME: admin - SITE_ADMIN_PASSWORD: password - VIRTUAL_HOST: ${PROJECT}.${DOMAIN} - SSH_AUTH_SOCK: ${CONTAINER_SSH_AUTH_SOCK} - DATABASE_HOST: db - DATABASE_PORT: 3306 - DATABASE_NAME: drupal - DATABASE_USER: user - DATABASE_PASSWORD: password - PRIVATE_DIR: /shared/private - TMP_DIR: /shared/tmp - PUBLIC_DIR: /shared/public - HASH_SALT: random-hash - CONFIG_SYNC_DIRECTORY: /shared/private/random-hash/sync - SHEPHERD_INSTALL_PROFILE: standard - volumes: - - .:/code - - ./shared:/shared - - ${HOST_SSH_AUTH_SOCK_DIR}:/ssh - db: - image: mariadb - environment: - MYSQL_DATABASE: drupal - MYSQL_USER: user - MYSQL_PASSWORD: password - MYSQL_ROOT_PASSWORD: super-secret-password - mail: - image: helder/mailcatcher - environment: - - VIRTUAL_HOST=mail.${PROJECT}.${DOMAIN} -volumes: - shared: - ssh: From 08abb6bac0991889a1e1fced461f540052bdaee2 Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Tue, 31 Jul 2018 15:25:05 +1000 Subject: [PATCH 4/8] Heavily simplify dsh with new docker compose --- dsh | 310 ++---------------------------------------------------------- 1 file changed, 10 insertions(+), 300 deletions(-) diff --git a/dsh b/dsh index c13cd1f..216c8e5 100755 --- a/dsh +++ b/dsh @@ -4,17 +4,6 @@ set -euo pipefail IFS=$'\n\t' -# Set the docker machine to be used by the project. Ignored on Linux. -MACHINE='default' - -# Set the top level domain used to by nginx-proxy to direct traffic to -# conatiners. The TLDs 'local' and 'localhost' are reserved in macOS, and 'dev' -# exists in global DNS, which may cause issues reassigning it with dnsmasq. -export DOMAIN=${DOMAIN:-'test'} - -# Nginx proxy exposed port. Useful when using something other than 80. -export NGINX_PORT=$(docker port nginx-proxy | awk -F ':' '{print $2}') - # Used as the prefix for docker networking, container naming and nginx hostname. export PROJECT=$(basename ${PWD}) # docker-compose stopped stripping chars from project name in 1.21.0. @@ -27,13 +16,10 @@ fi # Determine the OS type of the host machine. if [ "$(uname)" == "Darwin" ]; then HOST_TYPE='mac' - # On macOS ths SSH Sock directory is actually a named docker volume. - export HOST_SSH_AUTH_SOCK_DIR="ssh" - export CONTAINER_SSH_AUTH_SOCK="/ssh/auth/sock" + export DOCKER_COMPOSE_FILE='docker-compose.osx.yml' else HOST_TYPE='linux' - export HOST_SSH_AUTH_SOCK_DIR=$(dirname ${SSH_AUTH_SOCK}) - export CONTAINER_SSH_AUTH_SOCK=/ssh/$(basename ${SSH_AUTH_SOCK}) + export DOCKER_COMPOSE_FILE='docker-compose.linux.yml' fi # Setup some functions to output warnings. @@ -58,11 +44,9 @@ fi # Command: ./dsh start # Configures environment then brings up project using docker-compose.yml file. dsh_start() { - setup notice "Starting project containers." - docker-compose up -d - setup_xdebug - export URL="http://${PROJECT}.${DOMAIN}$(if [ ! $NGINX_PORT -eq '80' ]; then echo ":$NGINX_PORT"; fi)" + docker-compose -f ${DOCKER_COMPOSE_FILE} up -d + export URL="http://127.0.0.1" notice "Please wait about 10 seconds for the database to settle. You can now access the site from ${URL}. Project files are available in /code, You may need to build and install your @@ -78,59 +62,20 @@ dsh_shell() { dsh_start fi - # Execute project specific setup - dsh_project - - # @note This logic could be moved to a script that's added to the dev image. - # Add host machine user to web container if it doesn't already exist. - if ! docker exec ${PROJECT}_web_1 id -u ${USER} > /dev/null 2>&1; then - notice "Setting up user $USER on web container." - # Add user with local $USER name to container. - docker exec ${PROJECT}_web_1 adduser --disabled-password --uid ${UID} \ - --gecos ${USER} --home /home/${USER} ${USER} > /dev/null - # Add local .gitconfig to user's home dir on container. - docker cp ${HOME}/.gitconfig ${PROJECT}_web_1:/home/${USER}/ - # Allow sudo without password for user. - docker exec ${PROJECT}_web_1 /bin/bash -c "echo '${USER} ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/${USER}" - fi - - docker exec --interactive --tty --user ${USER} \ - --env SSH_AUTH_SOCK=${CONTAINER_SSH_AUTH_SOCK} \ - --env LINES=$(tput lines) --env COLUMNS=$(tput cols) \ - ${DSH_PROJECT[@]:-} \ - --env TERM=xterm-256color \ - ${PROJECT}_web_1 ${@:-/bin/bash} + docker-compose -f ${DOCKER_COMPOSE_FILE} exec web /bin/bash } # Command: ./dsh stop # Stops project and brings down network after disconnecting nginx proxy. dsh_stop() { - # If mac, ensure that docker-machine vars are available - # Need this check if working with multiple terminal sessions. - if [ ${HOST_TYPE} == 'mac' ]; then - setup_docker_machine - fi - notice "Stopping containers." - docker-compose stop + docker-compose -f ${DOCKER_COMPOSE_FILE} stop } -# Command: ./dsh stop +# Command: ./dsh purge # Stops project, then takes down containers and removes volumes if possible. dsh_purge() { - dsh_stop - if docker network ls | grep "\s${PROJECT}_default" > /dev/null; then - notice "Disconnecting nginx proxy from network." - set +e - docker network disconnect ${PROJECT}_default nginx-proxy - notice "Removing network." - docker network rm ${PROJECT}_default - set -e - fi - notice "Taking down containers, removing volumes if possible." - set +e - docker-compose down -v - set -e + docker-compose -f ${DOCKER_COMPOSE_FILE} down -v } # Command: ./dsh status @@ -144,15 +89,7 @@ dsh_status() { # Command: ./dsh logs # Tails logs from web container. dsh_logs() { - # If mac, ensure that docker-machine vars are available - # Need this check if working with multiple terminal sessions. - if [ ${HOST_TYPE} == 'mac' ]; then - setup_docker_machine - fi - - if docker ps | grep "\s${PROJECT}_web_1" > /dev/null; then - docker logs --follow --tail 1 ${PROJECT}_web_1 - fi + docker-compose -f ${DOCKER_COMPOSE_FILE} logs -f web } dsh_project() { @@ -163,230 +100,11 @@ dsh_project() { set -e } -setup() { - if [ ${HOST_TYPE} == 'mac' ]; then - # If Docker for Mac isn't running, assume Docker Machine. - if [[ ! $(docker version --format "{{.Server.KernelVersion}}") == *-moby ]]; then - setup_docker_machine - fi - setup_ssh_agent_proxy - fi - setup_nginx_proxy - setup_docker_network - setup_nginx_connect -} - -setup_docker_machine() { - set +e - STATUS=$(docker-machine status ${MACHINE}) - - # Check if the docker machine exists already, create one if not. - if [[ $? == 1 ]]; then - notice "No ${MACHINE} environment found." - create_machine - fi - set -e - - if [[ ${STATUS} == 'Stopped' ]]; then - notice "Docker machine not running, starting now." - docker-machine start ${MACHINE} - fi - - if [[ ${STATUS} == 'Saved' ]]; then - notice "Docker machine in saved state, restarting now." - docker-machine start ${MACHINE} - fi - - if [[ ${STATUS} == 'Error' ]]; then - notice "Docker machine vm does not exist but docker-machine still has it registered, remove then create." - docker-machine rm ${MACHINE} - create_machine - fi - - notice "Loading vars for docker machine." - eval "$(docker-machine env ${MACHINE})" -} - -setup_ssh_agent_proxy() { - if docker ps -a | grep "ssh-agent" > /dev/null; then - docker start ssh-agent > /dev/null - else - notice "Creating ssh agent proxy." - docker run -u ${UID} -d -v ${PROJECT}_${HOST_SSH_AUTH_SOCK_DIR}:/ssh --name=ssh-agent whilp/ssh-agent - - # Add all ssh keys from host machine to the agent proxy. - CURRENT_SSH_KEYS=$(ssh-add -l | awk '{print $3}') - notice "Adding ssh keys to agent proxy." - docker run -u ${UID} --rm -v ${PROJECT}_${HOST_SSH_AUTH_SOCK_DIR}:/ssh \ - -v ${HOME}:${HOME} -it whilp/ssh-agent ssh-add ${CURRENT_SSH_KEYS} - fi - - if ! docker ps | grep "ssh-agent" > /dev/null; then - error "whilp/ssh-agent could not be started." - fi -} - -setup_docker_network() { - if ! docker network ls | grep "\s${PROJECT}_default" > /dev/null; then - notice "Creating docker network for project." - docker network create ${PROJECT}_default - fi -} - -setup_nginx_proxy() { - # Nginx proxy is not needed for CI. - if [ -n "${GITLAB_CI+1}" ]; then - return; - fi - - if docker ps -a | grep "nginx-proxy" > /dev/null; then - docker start nginx-proxy > /dev/null - else - # Configuration is only applied when the container is created. - docker run -d -p 80:80 \ - -v /var/run/docker.sock:/tmp/docker.sock:ro \ - -v $(pwd)/dsh_proxy.conf:/etc/nginx/conf.d/dsh_proxy.conf \ - --restart always --name nginx-proxy \ - jwilder/nginx-proxy - fi - - if ! docker ps | grep "nginx-proxy" > /dev/null; then - error "jwilder/nginx-proxy could not be started." - else - # Update the nginx port as it wasn't running initially. - export NGINX_PORT=$(docker port nginx-proxy | awk -F ':' '{print $2}') - fi -} - -setup_nginx_connect() { - set +e - # Test to make sure its not already on the network. - if ! docker network inspect ${PROJECT}_default | grep "nginx-proxy" > /dev/null; then - notice "Connecting nginx-proxy to the network." - docker network connect ${PROJECT}_default nginx-proxy - fi - set -e -} - -dsh_setup_dnsmasq() { - set +e - if [ ${HOST_TYPE} == 'mac' ]; then - notice "Attempting to configure dnsmasq." - WEB_HOST_IP="127.0.0.1" - if [[ $(docker version --format "{{.Server.KernelVersion}}") != *-moby ]]; then - eval "$(docker-machine env ${MACHINE})" - WEB_HOST_IP=$(docker-machine ip ${MACHINE}) - fi - - # Test to see if dnsmasq.conf exists. - if [ ! -f /usr/local/etc/dnsmasq.conf ]; then - notice "Creating missing dnsmasq.conf file." - # Copy example file across. - mkdir -p /usr/local/etc - touch /usr/local/etc/dnsmasq.conf - fi - notice "Writing dnsmasq config: *.${DOMAIN} traffic to ${WEB_HOST_IP}." - echo "address=/${DOMAIN}/${WEB_HOST_IP}" > /usr/local/etc/dnsmasq.conf - - # Write resolver if none exists. - if [ ! -f /etc/resolver/${DOMAIN} ]; then - notice "Creating missing resolver config for ${DOMAIN}." - mkdir -p /etc/resolver - sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/'${DOMAIN}'' - fi - - # Restart dnsmasq. - notice "Restarting dnsmasq with homebrew services." - sudo brew services stop dnsmasq - sudo brew services start dnsmasq - else - ping -c 1 ${PROJECT}.${DOMAIN} 2>&1 > /dev/null - if [[ $? != 0 ]]; then - notice "Attempting to configure dnsmasq" - if [ ! -f /etc/dnsmasq.d/${DOMAIN} ]; then - echo "address=/${DOMAIN}/127.0.0.1" | sudo tee -a /etc/dnsmasq.d/${DOMAIN} > /dev/null - notice "Restarting dnsmasq" - sudo service dnsmasq restart - else - error "Dnsmasq not configured, please configure manually. Read readme documentation for further information." - fi - fi - fi - set -e -} - -setup_xdebug() { - HOST_IP=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1) - notice "Configuring xdebug to connect to host at: ${HOST_IP}." - # Get the PHP VERSION, so we edit the correct ini file. - PHP_VERSION=$(docker exec -t ${PROJECT}_web_1 php -r "echo PHP_VERSION;" | awk -F '-' '{print $1}' | awk -F '.' '{print $1"."$2}') - docker exec -t "${PROJECT}_web_1" sed -i "s/^xdebug\.remote_host=.*$/xdebug.remote_host=${HOST_IP}/" "/etc/php/${PHP_VERSION}/mods-available/xdebug.ini" - set +e - docker exec -t -u root "${PROJECT}_web_1" apachectl graceful 2> /dev/null - set -e -} - -create_machine() { - notice "Creating new machine." - docker-machine create --driver virtualbox --engine-insecure-registry registry.${DOMAIN}:5000 ${MACHINE} - # If docker-machine-nfs is not present, error out - if ! type "docker-machine-nfs" > /dev/null; then - error "Please install 'docker-machine-nfs' using\n $ brew install docker-machine-nfs" - exit 1 - fi - - # Use nfs, configure all directories to root. - docker-machine-nfs ${MACHINE} -f --nfs-config="-alldirs -maproot=0" - docker-machine ssh ${MACHINE} ln -s $(pwd)/code code - docker-machine ssh ${MACHINE} sudo mv code /code - - # Reconfigure dnsmasq due to possible docker machine IP change. - dsh_setup_dnsmasq -} - -# Command: ./dsh install -# Installs project dependencies for Mac. -dsh_install_tools() { - # For macOS, linux ppl please add your tests here. - if [ ${HOST_TYPE} != 'mac' ]; then - error "Only for mac users, you yourself before wrecking thou self \n \n ... fool!" - exit - fi - - if ! which brew > /dev/null; then - error "Missing homebrew, please install. \n http://brew.sh/" - exit; - else - notice "You have homebrew installed!" - fi - - if ! which docker-machine > /dev/null; then - error "Missing the docker toolbox, please install. \n https://www.docker.com/products/docker-toolbox" - exit; - else - notice "You have the docker toolbox installed!" - fi - - if ! which docker-machine-nfs > /dev/null; then - warning "Missing docker-machine-nfs \n Now attempting to install docker-machine-nfs with homebrew \n" - brew install docker-machine-nfs - else - notice "You have docker-machine-nfs installed!" - fi - - if ! brew ls --versions dnsmasq > /dev/null; then - warning "Missing dnsmasq \n Now attempting to install dnsmasq with homebrew \n" - brew install dnsmasq - exit; - else - notice "You have dnsmasq installed" - fi -} # Command: ./dsh pull # Fetches all images used by the project. dsh_pull() { - docker-compose pull + docker-compose -f ${DOCKER_COMPOSE_FILE} pull docker pull jwilder/nginx-proxy docker pull uofa/utility-php7 } @@ -395,9 +113,7 @@ dsh_help() { printf "\nUsage: dsh COMMAND\n\n Commands:\n \thelp\tShow this help.\n -\tinstall\tInstall dependencies and tools for development.\n \tpurge\tPurge the docker containers, network and proxy and remove all data.\n -\tsetup_dns\tConfigures dnsmasq.\n \tshell\tStart a shell which is connected to the containers and can be used to run commands.\n \tstart\tStart the docker containers, network and proxy.\n \tstatus\tShow the status of this projects containers.\n @@ -416,9 +132,6 @@ case ${COMMAND} in h*|-h|--help) dsh_help ;; - i*) - dsh_install_tools - ;; l*) dsh_logs ;; @@ -431,9 +144,6 @@ case ${COMMAND} in r*) dsh_shell ${@:2} ;; - se*) - dsh_setup_dnsmasq - ;; sh*|ss*) dsh_shell ${@:2} ;; From ae32fe3b67c1c212a12d8ce8882e6a09b93c1b8e Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Wed, 1 Aug 2018 09:15:26 +1000 Subject: [PATCH 5/8] Remove old containers and commands --- dsh | 6 ------ dsh_proxy.conf | 1 - 2 files changed, 7 deletions(-) delete mode 100644 dsh_proxy.conf diff --git a/dsh b/dsh index 216c8e5..08bb67f 100755 --- a/dsh +++ b/dsh @@ -100,13 +100,10 @@ dsh_project() { set -e } - # Command: ./dsh pull # Fetches all images used by the project. dsh_pull() { docker-compose -f ${DOCKER_COMPOSE_FILE} pull - docker pull jwilder/nginx-proxy - docker pull uofa/utility-php7 } dsh_help() { @@ -141,9 +138,6 @@ case ${COMMAND} in pur*) dsh_purge ;; - r*) - dsh_shell ${@:2} - ;; sh*|ss*) dsh_shell ${@:2} ;; diff --git a/dsh_proxy.conf b/dsh_proxy.conf deleted file mode 100644 index 86bda51..0000000 --- a/dsh_proxy.conf +++ /dev/null @@ -1 +0,0 @@ -client_max_body_size 100m; From 1b056bfa63d6c0e87b2ab8d7ca5deb1ed2b570eb Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Fri, 3 Aug 2018 12:06:29 +1000 Subject: [PATCH 6/8] Pass through COLUMNS and LINES env vars --- dsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dsh b/dsh index 08bb67f..ad9e671 100755 --- a/dsh +++ b/dsh @@ -62,7 +62,10 @@ dsh_shell() { dsh_start fi - docker-compose -f ${DOCKER_COMPOSE_FILE} exec web /bin/bash + docker-compose -f ${DOCKER_COMPOSE_FILE} exec \ + -e COLUMNS="$(tput cols)" \ + -e LINES="$(tput lines)" \ + web /bin/bash } # Command: ./dsh stop From f1bee4430331cdddb7cb7e2447156431e0803e2a Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Fri, 3 Aug 2018 12:23:54 +1000 Subject: [PATCH 7/8] Fix passing command to dsh shell --- dsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dsh b/dsh index ad9e671..f6782fa 100755 --- a/dsh +++ b/dsh @@ -2,7 +2,6 @@ # `set +e` is used to continue on errors throughout this script. set -euo pipefail -IFS=$'\n\t' # Used as the prefix for docker networking, container naming and nginx hostname. export PROJECT=$(basename ${PWD}) @@ -65,7 +64,7 @@ dsh_shell() { docker-compose -f ${DOCKER_COMPOSE_FILE} exec \ -e COLUMNS="$(tput cols)" \ -e LINES="$(tput lines)" \ - web /bin/bash + web ${@:-/bin/bash} } # Command: ./dsh stop From e6bb38cb5a9111df741b481f2f6e070f3b8a0c94 Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Fri, 3 Aug 2018 13:13:08 +1000 Subject: [PATCH 8/8] Swap to new images --- docker-compose.linux.yml | 2 +- docker-compose.osx.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.linux.yml b/docker-compose.linux.yml index 048829b..f3bd4be 100644 --- a/docker-compose.linux.yml +++ b/docker-compose.linux.yml @@ -1,7 +1,7 @@ version: '3' services: web: - image: uofa/apache2-php7-dev:shepherd + image: uofa/apache2-php7-dev:foundation # This makes the container run on the same network stack as your # workstation. Meaning that you can interact on "localhost". network_mode: host diff --git a/docker-compose.osx.yml b/docker-compose.osx.yml index a7f70e2..446cb79 100644 --- a/docker-compose.osx.yml +++ b/docker-compose.osx.yml @@ -1,7 +1,7 @@ version: '3' services: web: - image: uofa/apache2-php7-dev:shepherd + image: uofa/apache2-php7-dev:foundation # You will notice that we are forwarding port which do not belong to PHP. # We have to declare them here because these "sidecar" services are sharing # THIS containers network stack.