Setting up docker4drupal with multiple projects on Mac

I have recently started testing and using docker4drupal(https://github.com/wodby/docker4drupal/). (I also use DrupalVM(https://www.drupalvm.com/P) and vagrant; but that’s another post.) I setup to be quick and easy.

Setup

You will need:

  • Docker for Mac(https://docs.docker.com/docker-for-mac/)
  • Docker Sync(https://github.com/EugenMayer/docker-sync/) gem install docker-sync
  • 3 files from Docker4Drupal(https://github.com/wodby/docker4drupal/)
    • docker-compose.yml
    • docker-sync.yml
    • traefik.yml
  • 2 or more folders
    • spacely-sprokets
    • cogswell-cogs

Docker Compose Spacely Sprockets (new site)

~/Sites/spacely-sprokets/docker-compose.yml

version: "2"

services:
  mariadb:
    image: wodby/mariadb:10.1-2.3.3
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal
 
  php:
# 1. Images with vanilla Drupal – wodby/drupal:[DRUPAL_VERSION]-[PHP_VERSION]-[STABILITY_TAG].
    image: wodby/drupal:8-7.1-2.4.4
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      DB_HOST: mariadb
      DB_USER: drupal
      DB_PASSWORD: drupal
      DB_NAME: drupal
      DB_DRIVER: mysql
      # PHP_XDEBUG: 1
      # PHP_XDEBUG_DEFAULT_ENABLE: 1
      # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0         # This is needed to respect remote.host setting below
      # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254"  # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254'
    volumes:
       - spacely-sprokets-sync:/var/www/html # Docker-sync

  nginx:
# wodby/drupal-nginx:[DRUPAL_VERSION]-[NGINX_VERSION]-[STABILITY_TAG].
    image: wodby/drupal-nginx:8-1.13-2.4.2
    depends_on:
      - php
    environment:
      NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
    volumes:
       - spacely-sprokets-sync:/var/www/html # Docker-sync
    labels:
      - 'traefik.backend=nginx'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:spacely-sprokets.docker.localhost'

   mailhog:
    image: mailhog/mailhog
    labels:
      - 'traefik.backend=mailhog'
      - 'traefik.port=8025'
      - 'traefik.frontend.rule=Host:mailhog.spacely-sprokets.docker.localhost'
 
volumes:
# Docker-sync for macOS users
   spacely-sprokets-sync:
     external: true

Docker Sync Spacely Sprockets

~/Sites/spacely-sprokets/docker-sync.yml

version: “2”

syncs:
  spacely-sprokets-sync:
src: ‘./‘
sync_userid: ‘82’
sync_excludes: [‘.gitignore’, ‘.git/‘, ‘.idea/‘]

Docker Cogswell Cogs (existing code)

~/Sites/cogswell-cogs/docker-compose.yml

version: "2"

services:
  mariadb:
    image: wodby/mariadb:10.1-2.3.3
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal
      volumes:
       - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here.

  php:
# 2. Images without Drupal – wodby/drupal-php:[PHP_VERSION]-[STABILITY_TAG].
     image: wodby/drupal-php:5.6-2.4.3
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      DB_HOST: mariadb
      DB_USER: drupal
      DB_PASSWORD: drupal
      DB_NAME: drupal
      DB_DRIVER: mysql
      # PHP_XDEBUG: 1
      # PHP_XDEBUG_DEFAULT_ENABLE: 1
      # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0         # This is needed to respect remote.host setting below
      # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254"  # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254'
    volumes:
       - cogswell-cogs-sync:/var/www/html # Docker-sync

   apache:
     image: wodby/drupal-apache:2.4-1.0.2
    depends_on:
      - php
     environment:
       APACHE_LOG_LEVEL: debug
       APACHE_BACKEND_HOST: php
       APACHE_SERVER_ROOT: /var/www/html/www
     volumes:
    - cogswell-cogs-sync-sync:/var/www/html # Docker-sync
     labels:
       - 'traefik.backend=apache'
       - 'traefik.port=80'
       - 'traefik.frontend.rule=Host:drupal.docker.localhost'

  mailhog:
    image: mailhog/mailhog
    labels:
      - 'traefik.backend=mailhog'
      - 'traefik.port=8025'
      - 'traefik.frontend.rule=Host:mailhog.drupal.docker.localhost'

volumes:
 # Docker-sync for macOS users
   cogswell-cogs-sync:
     external: true

Docker Sync Cogswell Cogs

~/Sites/cogswell-cogs/docker-sync.yml

version: “2”

syncs:
  cogswell-cogs-sync:
src: ‘./‘
sync_userid: ‘82’
sync_excludes: [‘.gitignore’, ‘.git/‘, ‘.idea/‘]

Traefik.yml

~/Sites/traefik.yml


version: ‘2’

services:
  traefik:
    image: traefik
    restart: unless-stopped
    command: -c /dev/null –web –docker –logLevel=DEBUG
    networks:
        - spacelysprokets
        - cogswellcogs
        - sites
     ports:
        - ‘80:80’
        - ‘8080:8080’
   volumes:
       - /var/run/docker.sock:/var/run/docker.sock
  portainer:
        image: portainer/portainer
        command: '--no-auth'
        volumes:
            - '/var/run/docker.sock:/var/run/docker.sock'
        labels:
            - traefik.backend=portainer
            - traefik.port=9000
            - 'traefik.frontend.rule=Host:portainer.docker.localhost'
networks:
  spacelysprokets:
    external: 
      name: spacelysprokets_default
  cogswellcogs:
    external:
      name: cogswellcogs_default
  sites:
    external:
      name: sites_default

Commands

Start Cogswell Cogs

cd ~/Sites/cogswell-cogs
docker-sync-stack start

Start Spacely Sprokets

cd ~/Sites/spacely-sprokets
docker-sync-stack start

Start traefik and portainer.

cd ~/Sites
docker-compose -f traefik.yml up -d

Shell access to the site

cd ~/Sites/cogswell-cogs
docker-compose exec --user=82 php sh

Stop docker

cd ~/Sites/cogswell-cogs
docker-compose -f ../traefik.yml stop
docker-compose stop
docker-sync stop

Kill sticky headers

The bookmarklet just finds all fixed-position elements on the page, and removes them. This might remove the navigation, but if you need it back, just hit refresh. That’s why I created a bookmarklet and not a custom user-stylesheet or browser plugin: this is the simplest way to solve the problem.

Source: Kill sticky headers

Health and fitness 

On March 18th Jana and I decided to challenge each other to loose weight. I started out at 218 lbs. on a 6 ft frame. The goal is to get to 190 lbs by Labor Day, the first weekend in September.

On April 3rd I had a physical with a fasting blood test. The doctor said I was 222 lbs. (they weigh with clothes on) and the results of the test gave warning signs of diabetes. The week of my physical I quit pop cold turkey. I have had 12oz of Dr. Pepper since then, drinking only water with MiO or Lemon Lime Sparkling water. I also cut carbs way down, most of the changes started before I got the results of the test.
They scheduled another test on April 11th to test A1C levels. The results for that came back 8, official diabetes levels. If you are unaware A1C is the 3 month glucose average. My doctor wants to retest in mid July to see if the changes I have made lowered that to normal levels.
Before the diet change I had 40-60oz of pop a day. I figured on an average day I had 288 grams of carbs by lunch, which is way above the recommended daily intake.
27 days ago I joined Planet Fitness. I have exercised daily since then. I got an Apple Watch 2 years ago. Before these changes I completed the green ring about once a month, yet I now have a 24 day streak and have lost 9lbs.
I hope these changes will mean I keep diabetes at bay. My energy level is more consistent throughout the day, and I know the food is healthier. However it is still hard to resist the fries and Coke. Though it is a whole new way of life, I believe that this path is the only way forward, given that my body won’t let me eat all the crap I ate when I was younger (lol).
Thanks for your prayers on this journey.

Today I am saddened, Today I am hopeful

Today I am saddened
Today I am saddened
for the women mistreated by misogynistic views and actions
Today I am saddened
for those who have been mistreated by racist views and actions
Today I am saddened
for the LGBTQ community who are just trying to have a voice
Today I am saddened
by the people who show hate over love and compassion
Today I am saddened
for my own sins against humanity
Today I am saddened
for those who think the world has ended
Today I am saddened
for those who think the revolution has started
Today I am saddened
for those who do not know the joy and peace of Jesus
Today I am saddened

Today I am hopeful
Today I am hopeful
that one day soon women will be treated with respect
Today I am hopeful
that racism will fade and die
Today I am hopeful
that the voice of the LGBTQ community will be heard
Today I am hopeful
that people will learn to communicate without hate
Today I am hopeful
that my own sins are forgiven
Today I am hopeful
in the knowledge that the world has NOT ended
Today I am hopeful
in the knowledge that a revolution was started years ago
Today I am hopeful
for those who will know the joy and peace of Jesus I have found
Today I am hopeful

An Overlooked Factor in Creating Positive Change : zen habits

There are lots of factors that are incredibly important in creating any positive change: starting small, taking small steps all along the way, finding motivation and accountability, finding the support of people around you (or finding it online), learning to mindfully notice your urges to quit.These are all super important. But there’s another factor that most people overlook: how you feel about the change.

Source: An Overlooked Factor in Creating Positive Change : zen habits